ShardingSphere-MCP can run from the standalone distribution built from source or from the official OCI image.
Build the distribution:
./mvnw -pl distribution/mcp -am -DskipTests package
The distribution directory contains:
bin/: startup scripts.conf/: default configuration and logging configuration.lib/: MCP Server dependencies and built-in MCP feature plugins.plugins/: external JDBC drivers or extra MCP feature plugin jars.logs/: runtime logs.Official MCP Registry metadata lives in mcp/server.json.
The published server name is io.github.apache/shardingsphere-mcp.
The OCI image shape is:
ghcr.io/apache/shardingsphere-mcp:<version>
Before using the OCI image, prepare a custom configuration file.
When HTTP mode runs in a container, bindHost should bind to a network interface that the container can expose, such as 0.0.0.0:
transport:
type: STREAMABLE_HTTP
http:
bindHost: 0.0.0.0
port: 18088
endpointPath: /mcp
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"
Run in HTTP mode with a custom configuration file and plugin directory:
docker run --rm -p 18088:18088 \
-e SHARDINGSPHERE_MCP_CONFIG=/opt/shardingsphere-mcp/conf/custom-mcp-http.yaml \
-v /path/to/mcp-http.yaml:/opt/shardingsphere-mcp/conf/custom-mcp-http.yaml:ro \
-v /path/to/plugins:/opt/shardingsphere-mcp/plugins:ro \
ghcr.io/apache/shardingsphere-mcp:${latest.release.version}
When running in STDIO mode, set transport.type in the configuration file to STDIO:
docker run --rm -i \
-e SHARDINGSPHERE_MCP_CONFIG=/opt/shardingsphere-mcp/conf/custom-mcp-stdio.yaml \
-v /path/to/mcp-stdio.yaml:/opt/shardingsphere-mcp/conf/custom-mcp-stdio.yaml:ro \
-v /path/to/plugins:/opt/shardingsphere-mcp/plugins:ro \
ghcr.io/apache/shardingsphere-mcp:${latest.release.version}
Configure runtimeDatabases according to the target capability boundary:
The built-in HTTP Server does not provide authentication or authorization. For remote access, place it in a trusted network or behind a reverse proxy or gateway that handles:
HTTP binding recommendations:
127.0.0.1 for local debugging.The following example uses Nginx to illustrate the minimum layout in which the outer entry handles HTTPS while ShardingSphere-MCP continues to serve plain HTTP on a controlled network interface. Other reverse proxies, ingress controllers, ALBs, or API gateways can follow the same boundary.
ShardingSphere-MCP configuration example:
transport:
type: STREAMABLE_HTTP
http:
bindHost: 127.0.0.1
port: 18088
endpointPath: /mcp
sessionAttributionSource:
subjectHeader: X-ShardingSphere-MCP-Subject
sourceHeader: X-ShardingSphere-MCP-Source
attributeHeaderPrefix: X-ShardingSphere-MCP-Attribute-
Nginx example:
server {
listen 443 ssl http2;
server_name mcp.example.com;
ssl_certificate /etc/nginx/certs/mcp.crt;
ssl_certificate_key /etc/nginx/certs/mcp.key;
location /mcp {
proxy_pass http://127.0.0.1:18088/mcp;
proxy_http_version 1.1;
proxy_pass_request_headers off;
proxy_set_header Host $host;
proxy_set_header Content-Type $http_content_type;
proxy_set_header Accept $http_accept;
proxy_set_header MCP-Session-Id $http_mcp_session_id;
proxy_set_header MCP-Protocol-Version $http_mcp_protocol_version;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
The important points of this layout are:
When the outer gateway already identifies the caller, let it overwrite the session attribution headers before forwarding the request. The MCP Runtime then binds the resulting attribution to the session context. Keep the header names and prefix aligned with transport.http.sessionAttributionSource in the Configuration document.
Nginx example:
location /mcp {
proxy_pass http://127.0.0.1:18088/mcp;
proxy_http_version 1.1;
proxy_pass_request_headers off;
proxy_set_header Host $host;
proxy_set_header Content-Type $http_content_type;
proxy_set_header Accept $http_accept;
proxy_set_header MCP-Session-Id $http_mcp_session_id;
proxy_set_header MCP-Protocol-Version $http_mcp_protocol_version;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-ShardingSphere-MCP-Subject $remote_user;
proxy_set_header X-ShardingSphere-MCP-Source gateway-nginx;
proxy_set_header X-ShardingSphere-MCP-Attribute-Environment production;
}
Follow these rules when wiring attribution:
subjectHeader represents the external subject, such as a trial user, a commercial customer identifier, or an internal caller identity.sourceHeader identifies the request source, such as gateway-nginx, internal-alb, or another trusted ingress name.attributeHeaderPrefix can carry a small amount of non-sensitive context such as environment, region, or integration channel; do not pass passwords, keys, or tokens through these headers.sessionAttributionSource.After wiring the gateway, continue with the health checks below to confirm that:
After deployment, verify that ShardingSphere-MCP is truly usable instead of stopping at “the HTTP port is reachable”:
Service process and endpoint are reachable
http://<bind-host>:<port><endpointPath> matches the client configuration.MCP protocol is ready
initialize and read capabilities.Runtime databases are ready
shardingsphere://runtime and confirm that the transport, runtime database summary, and readiness details are visible.database_gateway_validate_runtime_database, or run a minimal task such as “Show tables in <logic-database>” from the AI application to confirm that the configured runtime database is usable.logs/mcp.log.logs/mcp.log for diagnostics.shardingsphere://runtime exposes the current transport, runtime database summary, readiness details, and basic diagnostics.When reporting an issue to an operator or troubleshooter, collect at least:
runtimeDatabases.logs/mcp.log.For symptom-oriented diagnosis, failure categories, and runtime protection guidance, see Troubleshooting. For direct MCP protocol debugging, see the Custom Integration Appendix.
