Description
Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.
Expected Behavior
The MCP client should:
- Properly validate its state and server capabilities before operations
- Only expose client-appropriate methods
- Handle protocol version negotiation clearly
Example of expected validation:
// Client should validate state before operations
public Mono<McpSchema.CallToolResult> callTool(McpSchema.CallToolRequest request) {
if (!this.isInitialized()) {
return Mono.error(new McpError("Client must be initialized before calling tools"));
}
if (this.serverCapabilities.tools() == null) {
return Mono.error(new McpError("Server does not provide tools capability"));
}
return this.mcpSession.sendRequest(...);
}
Current Behavior
- Client operations don't validate initialization state or server capabilities, potentially leading to runtime errors
- Client exposes server-side notification methods that shouldn't be called by clients:
// These methods should not exist in client
public Mono<Void> sendResourcesListChanged()
public Mono<Void> promptListChangedNotification()
- Protocol version handling lacks clear documentation and validation
Context
This issue affects developers using the MCP client in several ways:
- Lack of validation can lead to confusing runtime errors when client isn't properly initialized
- Exposed server methods can lead to protocol violations if called by client applications
- Unclear protocol version handling can cause compatibility issues
Current workaround:
- Developers must manually check initialization state and capabilities before operations, but this is error-prone and leads to duplicated code.