This page shows how to build ShardingSphere-MCP from source, connect to a ShardingSphere-Proxy logical database prepared by the user, and verify metadata reads and read-only SQL queries over HTTP.
JAVA_HOME or PATH.curl for HTTP requests.Run from the repository root:
./mvnw -pl distribution/mcp -am -DskipTests package
Enter the distribution directory:
cd distribution/mcp/target/apache-shardingsphere-mcp-${version}
Expected result:
bin/, conf/, and lib/.${version} with the built distribution version, such as 5.5.4-SNAPSHOT.Edit conf/mcp-http.yaml and point runtimeDatabases to an existing ShardingSphere-Proxy logical database:
runtimeDatabases:
"<logic-database>":
databaseType: MySQL
jdbcUrl: "jdbc:mysql://<proxy-host>:<proxy-port>/<logic-database>"
username: "<proxy-username>"
password: "<proxy-password>"
driverClassName: "com.mysql.cj.jdbc.Driver"
Replace <logic-database>, <proxy-host>, <proxy-port>, <proxy-username>, and <proxy-password> with the actual ShardingSphere-Proxy connection information.
If the target database driver is not packaged, copy the corresponding JDBC driver jar to plugins/ before startup.
Unix-like systems:
bin/start.sh > logs/mcp-http.log 2>&1 & MCP_PID=$!
Windows:
start "ShardingSphere MCP" cmd /c "bin\start.bat > logs\mcp-http.log 2>&1"
The default configuration file is conf/mcp-http.yaml, and the default endpoint is http://127.0.0.1:18088/mcp.
The Unix-like example starts the MCP Server in the background and stores the process id in MCP_PID so it can be stopped at the end.
curl -i -sS http://127.0.0.1:18088/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
--data '{"jsonrpc":"2.0","id":"init-1","method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl-client","version":"1.0.0"}}}'
Expected result:
MCP-Session-Id.MCP-Protocol-Version.Notify the server that the client has completed initialization:
curl -i -sS http://127.0.0.1:18088/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Session-Id: <MCP-Session-Id value>' \
-H 'MCP-Protocol-Version: <MCP-Protocol-Version value>' \
--data '{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}'
Expected result:
202.curl -sS http://127.0.0.1:18088/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Session-Id: <MCP-Session-Id value>' \
-H 'MCP-Protocol-Version: <MCP-Protocol-Version value>' \
--data '{"jsonrpc":"2.0","id":"resource-1","method":"resources/read","params":{"uri":"shardingsphere://databases"}}'
Expected result:
text/event-stream.data: line.<logic-database>.curl -sS http://127.0.0.1:18088/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Session-Id: <MCP-Session-Id value>' \
-H 'MCP-Protocol-Version: <MCP-Protocol-Version value>' \
--data '{
"jsonrpc":"2.0",
"id":"tool-1",
"method":"tools/call",
"params":{
"name":"database_gateway_search_metadata",
"arguments":{
"database":"<logic-database>",
"query":"<metadata-keyword>",
"object_types":["table","view"]
}
}
}'
Expected result:
curl -sS http://127.0.0.1:18088/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Session-Id: <MCP-Session-Id value>' \
-H 'MCP-Protocol-Version: <MCP-Protocol-Version value>' \
--data '{
"jsonrpc":"2.0",
"id":"tool-2",
"method":"tools/call",
"params":{
"name":"database_gateway_execute_query",
"arguments":{
"database":"<logic-database>",
"sql":"SELECT * FROM <table-name> LIMIT 10",
"max_rows":10
}
}
}'
Expected result:
result_kind is result_set.statement_class is query.columns, rows, or row_objects.Unix-like systems:
curl -sS -D - -o /dev/null \
-X DELETE http://127.0.0.1:18088/mcp \
-H 'MCP-Session-Id: <MCP-Session-Id value>' \
-H 'MCP-Protocol-Version: <MCP-Protocol-Version value>'
kill "${MCP_PID}"
Windows:
curl -sS -D - -o NUL ^
-X DELETE http://127.0.0.1:18088/mcp ^
-H "MCP-Session-Id: <MCP-Session-Id value>" ^
-H "MCP-Protocol-Version: <MCP-Protocol-Version value>"
Then press Ctrl+C in the ShardingSphere MCP startup window, or close that window, to stop the MCP Server process.
Expected result:
200.