使用说明
Lucene+MySQL MCP服务器
该项目将MySQL表索引到Lucene中,并仅从Lucene提供搜索/查找API。它还公开了MCP工具(包括原始的ping/pong/ding/dong工具以及特定于表的搜索/查找工具)以及REST端点。
配置
创建或编辑 config.yaml 在repo根目录中:
server:
host: 0.0.0.0
port: 8080
lucene:
index_path: "./data/index"
mysql:
host: 127.0.0.1
port: 3306
database: droptruck_db
username: web_app_sa
password: web_app_sa
摄入(构建指数)
运行一次以构建Lucene索引:
mvn -f server/pom.xml clean compile exec:java \
-Dexec.mainClass=org.vectora.server.McpServerApp \
-Dexec.args="--config ./config.yaml --ingest"
这将:
- 读取MySQL表
- 将Lucene索引写入
data/index/
运行服务器(无摄入)
索引存在后:
mvn -f server/pom.xml clean compile exec:java \
-Dexec.mainClass=org.vectora.server.McpServerApp \
-Dexec.args="--config ./config.yaml"
如果缺少索引,服务器将在启动时自动摄取。
HTTP端点
列出工具:
curl http://localhost:8080/tools
健康:
curl http://localhost:8080/health
搜索:
curl "http://localhost:8080/search?query=your+search+terms"
可选搜索筛选器:
table(例如。&table=employees)created_at_from/created_at_to(ISO-8601或历元毫秒)limit(默认值50,最大值500)
示例:
# basic keyword search
curl "http://localhost:8080/search?query=truck"
# table-specific search
curl "http://localhost:8080/search?table=indents&query=truck"
# last 3 months of `indents` (adjust the date as needed)
curl "http://localhost:8080/search?table=indents&query=&created_at_from=2025-11-03T00:00:00Z"
# explicit date range
curl "http://localhost:8080/search?table=indents&query=&created_at_from=2026-01-01T00:00:00Z&created_at_to=2026-02-01T00:00:00Z"
# epoch millis date range
curl "http://localhost:8080/search?table=indents&query=&created_at_from=1704067200000&created_at_to=1706745600000"
# limit results
curl "http://localhost:8080/search?table=indents&query=truck&limit=25"
行查找(任何表):
curl http://localhost:8080/{table}/{id}
备注
- 所有回复仅由Lucene提供。
- 每当DB/app代码更改时重新摄取。
- 如果端口8080正在使用中,请更改
server.port在config.yaml. - MCP传输暴露在
/mcp(例如。http://localhost:8080/mcp).