This chapter is for developers who want to extend ShardingSphere-MCP. For installation and usage, see the User Manual. For the protocol surface, see the Reference.
The MCP path is organized as api + support + features + core + bootstrap:
mcp/api: public tool/resource handler contracts, descriptor types, protocol responses, and MCP protocol exceptions.mcp/support: database metadata, execution, capability, workflow contexts, models, facades, SPI, and reusable helpers.mcp/features/encrypt: Encrypt MCP feature.mcp/features/mask: Mask MCP feature.mcp/core: handler discovery, registry, request scope, session, SQL execution trace, metadata discovery, and runtime context.mcp/bootstrap: MCP Java SDK based bootstrap, HTTP/STDIO transport, configuration loading, and lifecycle management.distribution/mcp: standalone packaging, startup scripts, configuration, and Dockerfile.test/e2e/mcp: end-to-end contract validation.mcp/bootstrap only publishes the aggregated protocol surface. It should not hard-code concrete feature business logic.
Recommended path for a new feature:
mcp/features/<feature>.mcp/api.mcp/support when database metadata, SQL execution, or workflow support is needed.mcp/core only when service-level handler context is needed.mcp/bootstrap.MCPHandlerProvider.getToolHandlers() and getResourceHandlers().MCPWorkflowDefinitionProvider on the same provider.org.apache.shardingsphere.mcp.api.MCPHandlerProvider under src/main/resources/META-INF/services/.META-INF/shardingsphere-mcp/mcp-descriptors.If the feature should be shipped as an official default capability:
mcp/features/pom.xml.distribution/mcp/pom.xml.If the feature is optional, place the built jar under the distribution plugins/ directory.
When adding a public tool:
MCPToolHandler<T extends MCPHandlerContext>.When adding a public resource:
MCPResourceHandler<T extends MCPHandlerContext>.When runtime code needs the descriptor for a handler, resolve it from MCPDescriptorCatalogIndex by canonical tool name or resource URI template.
Do not duplicate descriptor fields inside handlers.
MCPServiceHandlerContext for service-level handlers.MCPDatabaseHandlerContext for database metadata or execution handlers.MCPWorkflowHandlerContext for workflow handlers.shardingsphere://features/<feature>/... namespace.Descriptors should explain how models should use the protocol surface, not merely repeat tool names or URIs.
Maintain:
Tool annotations are only client hints. They do not replace runtime validation, SQL safety checks, user approval, or server-side authorization.
