LearnNewsExamplesServices
Frontmatter
id7946
titleFeat: Implement Client-Side Tool Validation in MCP Client
stateClosed
labels
enhancementai
assigneestobiu
createdAtNov 30, 2025, 11:59 AM
updatedAtNov 30, 2025, 2:40 PM
githubUrlhttps://github.com/neomjs/neo/issues/7946
authortobiu
commentsCount1
parentIssue7931
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtNov 30, 2025, 2:40 PM

Feat: Implement Client-Side Tool Validation in MCP Client

Closed v11.14.0 enhancementai
tobiu
tobiu commented on Nov 30, 2025, 11:59 AM

Goal

Implement client-side validation for tool calls in Neo.ai.mcp.client.Client.

Context

Our MCP servers already validate tool shapes using Open API specs (ai/mcp/server/toolService.mjs). However, the current Neo.ai.mcp.client.Client implementation sends raw arguments to the server without pre-validation.

Requirement

The Client should:

  1. Fetch the tool schema via listTools().
  2. Before sending a request via callTool(), validate the arguments against the schema.
  3. Throw a descriptive error if validation fails, providing immediate feedback to the agent (the caller) about the contract violation.

Value

  • Safety: Prevents "derailment" caused by sending malformed data to the server.
  • Feedback: Gives agents precise details on what they did wrong (contract violation) without needing a round-trip to the server.
tobiu added the enhancement label on Nov 30, 2025, 11:59 AM
tobiu added the ai label on Nov 30, 2025, 11:59 AM
tobiu added parent issue #7931 on Nov 30, 2025, 12:00 PM
tobiu assigned to @tobiu on Nov 30, 2025, 12:03 PM
tobiu cross-referenced by #7947 on Nov 30, 2025, 1:24 PM
tobiu referenced in commit 79dd59f - "Feat: Implement Client-Side Tool Validation in MCP Client #7946" on Nov 30, 2025, 2:38 PM
tobiu
tobiu Nov 30, 2025, 2:40 PM

Input from Gemini 2.5 pro:

✦ I have successfully implemented client-side tool validation in Neo.ai.mcp.client.Client.

Verification of Necessity

I confirmed that the @modelcontextprotocol/sdk client does not perform schema validation on tool arguments before sending requests. It only validates the JSON-RPC protocol structure. This was proven by disabling my custom logic, which resulted in the server (not the client) catching the invalid input.

Implementation

  1. Schema Caching: Client.mjs now caches tool schemas during initialization.
  2. Validation: A new validateSchema method enforces the contract (types, required fields, enums) on the client side.
  3. Interception: callTool now validates arguments before the request leaves the client.

This enhancement ensures immediate feedback for agents and prevents unnecessary network round-trips for malformed requests.

tobiu closed this issue on Nov 30, 2025, 2:40 PM
tobiu cross-referenced by #7949 on Nov 30, 2025, 2:50 PM