Skip to content

API: declarations prevent subclassing/extending public classes #793

@scottslewis

Description

@scottslewis

I would like to extend the McpAsyncServer, McpSyncServer and the stateless versions to extend the behavior of these servers via a new MCP extension under development.

Currently, these classes, and a couple of classes that their constructors depend upon (McpServerFeatures.Sync and Async) are package protected meaning that only the code in the sdk can use these constructors, effectively preventing the creation of subclasses.

Environment

version 0.18.0.SNAPSHOT of sdk as of 2/14/2026
Please provide as many details as possible: Spring MCP version, Java version, which vector store you use if any, etc

Expected behavior

Ability to declare subclasses of McpSyncServer, McpAsyncServer, and stateless analogs. Subclass constructors must call the superclass constructor and so currently cannot be from outside of io.modelcontextprotocol package namespace.

Minimal Complete Reproducible example

The follow code will not compile, because the superclass (McpAsyncServer) constructor is package private.

	class AsyncToolGroupServer extends McpAsyncServer {

		public AsyncToolGroupServer(McpServerTransportProvider mcpTransportProvider, McpJsonMapper jsonMapper,
				Async features, Duration requestTimeout, McpUriTemplateManagerFactory uriTemplateManagerFactory,
				JsonSchemaValidator jsonSchemaValidator) {
			super(mcpTransportProvider, jsonMapper, features, requestTimeout, uriTemplateManagerFactory, jsonSchemaValidator);
		}
}

fix pr forthcoming

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions