Skip to content

Improve MCP Client Validation and Protocol Compliance #13

@tzolov

Description

@tzolov

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:

  1. Properly validate its state and server capabilities before operations
  2. Only expose client-appropriate methods
  3. 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

  1. Client operations don't validate initialization state or server capabilities, potentially leading to runtime errors
  2. 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()
  1. 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.

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions