BlazeSQL MCP服务器
blaze-sql-server 是BlazeSQL自然语言查询API的安全默认MCP服务器和CLI。
它支持两种模式:
serve:作为用于Cursor、Claude Desktop、Codex和其他MCP客户端的MCP stdio服务器运行query:直接从shell执行单个BlazeSQL请求
亮点
- MCP工具:暴露
blazesql_query - CLI命令:
serve,query,doctor,help,version - 安全默认值:仅HTTPS远程端点、有界超时、编辑日志记录、上限格式化输出
- 验证:运行时配置验证和BlazeSQL响应形状验证
- 工具:
pnpm、CI、自动化测试和项目级mcporter配置
需求
- Node.js
>=20.11.0 pnpm>=10- BlazeSQL API密钥
安装
pnpm install
cp .env.sample .env至少设置:
BLAZE_API_KEY=YOUR_API_KEY_HERE可选环境变量:
BLAZE_API_ENDPOINTBLAZE_REQUEST_TIMEOUT_MSBLAZE_MAX_RESPONSE_CHARSBLAZE_LOG_LEVELBLAZE_ALLOW_INSECURE_ENDPOINT
构建
pnpm build作为MCP服务器运行
为了向后兼容,运行不带参数的二进制文件会启动stdio服务器:
node build/index.js明确地:
node build/index.js serve暴露的MCP工具是:
blazesql_querydb_id:BlazeSQL数据库IDnatural_language_request:发送到BlazeSQL的提示
与MCPorter一起使用
MCPorter 可以通过以下位置的项目级配置自动发现此服务器 config/mcporter.json.
从项目根:
npx mcporter list
npx mcporter call blazesql.blazesql_query db_id:"your_db_id" natural_language_request:"show me total users"随时随地临时使用:
npx mcporter call --stdio "node /path/to/blaze-sql-mcp-server/build/index.js" --name blazesql blazesql.blazesql_query db_id:"your_db_id" natural_language_request:"total sales last month"以CLI运行
打印帮助:
node build/index.js --help运行直接查询:
node build/index.js query --db-id db_demo --request "show me total users by city"使用位置参数:
node build/index.js query db_demo "show me total users by city"从stdin读取请求:
printf 'show me total users by city\n' | node build/index.js query db_demo --stdin可用输出格式:
node build/index.js query db_demo "show me total users by city" --format markdown
node build/index.js query db_demo "show me total users by city" --format text
node build/index.js query db_demo "show me total users by city" --format json诊断
检查运行时配置:
node build/index.js doctor
node build/index.js doctor --jsondoctor 在共享终端中运行是安全的:它从不打印原始API密钥。
验证
pnpm typecheck
pnpm test
pnpm checkMCP客户端配置
stdio命令示例:
/absolute/path/to/node /absolute/path/to/blaze-sql-mcp-server/build/index.js因为二进制默认为 serve,MCP客户端不需要额外的子命令。
设计说明
CLI形状有意遵循由以下工具推广的单一用途命令模式 mcporter:一个可预测的命令界面,直接使用shell,以及一个明显的机器可读模式。
