本页说明如何在 Claude Code 中接入已经启动的 ShardingSphere-MCP HTTP Server,或由 Claude Code 拉起本地 STDIO MCP Server。ShardingSphere-MCP 是 Apache ShardingSphere 提供的 MCP Server,用于把数据库元数据访问、受控 SQL 查询和数据库治理能力暴露给支持 MCP 的 AI 客户端和平台。
database_gateway_validate_runtime_database 进行接入前校验。http://127.0.0.1:18088/mcp,或访问你实际配置的 MCP Server 地址。使用 HTTP MCP Server:
claude mcp add --transport http shardingsphere http://127.0.0.1:18088/mcp
如果希望当前用户的所有 Claude Code 项目都可使用该 MCP Server,可以使用用户级配置:
claude mcp add --transport http --scope user shardingsphere http://127.0.0.1:18088/mcp
也可以在项目根目录创建 .mcp.json:
{
"mcpServers": {
"shardingsphere": {
"type": "http",
"url": "http://127.0.0.1:18088/mcp"
}
}
}
如果希望 Claude Code 在本地拉起 ShardingSphere-MCP 进程,可以使用 STDIO:
claude mcp add --transport stdio shardingsphere -- \
/path/to/apache-shardingsphere-mcp/bin/start.sh \
/path/to/apache-shardingsphere-mcp/conf/mcp-stdio.yaml
将 /path/to/apache-shardingsphere-mcp 替换为实际发行包目录。
识别成功:
claude mcp list,确认 shardingsphere 已出现在 MCP Server 列表中。/mcp
调用成功:
<logic-database> 中有哪些表。orders 表的列和索引。database_gateway_validate_runtime_database。shardingsphere server name 应只对应一种接入方式;如果需要同时保留 HTTP 与 STDIO,建议使用不同的 server name。