Frontmatter
| id | 7949 |
| title | Refactor Shared Tool Validation Service for MCP Client and Server |
| state | Closed |
| labels | enhancementairefactoring |
| assignees | tobiu |
| createdAt | Nov 30, 2025, 2:50 PM |
| updatedAt | Nov 30, 2025, 3:29 PM |
| githubUrl | https://github.com/neomjs/neo/issues/7949 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 7931 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Nov 30, 2025, 3:29 PM |
Refactor Shared Tool Validation Service for MCP Client and Server
tobiu assigned to @tobiu on Nov 30, 2025, 2:51 PM
tobiu added parent issue #7931 on Nov 30, 2025, 2:51 PM

tobiu
Nov 30, 2025, 3:29 PM
Input from Gemini 2.5 pro:
✦ I have successfully completed the refactoring for issue #7949.
Achievements
- Shared Service: Relocated
toolService.mjstoai/mcp/toolService.mjs, making it accessible to both Server and Client components.- Hybrid Validation: Implemented
validateToolInput(toolName, args, schema)which supports:
- Internal Zod Validation: Uses robust Zod schemas derived from
openapi.yaml(when initialized, e.g., in Servers).- External JSON Schema Validation: Falls back to a lightweight JSON Schema validator (when Zod schemas are unavailable, e.g., in Clients connecting to external servers).
- Integration:
- Updated
Neo.ai.mcp.client.Clientto use the sharedvalidateToolInput.- Updated
github-workflow,knowledge-base, andmemory-coreservers to use the shared service.Future Work (Singleton Refactoring)
We identified that
toolService.mjsis currently a singleton module. This prevents a single process (like an Agent) from initializing multiple internal server contexts (Zod schemas) simultaneously.
- Current Impact:
Client.mjsuses the JSON Schema fallback for validation, which is functional and safe.- Next Step: A follow-up ticket will be created to refactor
toolService.mjsinto a Class-based service to support multiple instances per process, enabling Zod validation on the Client side for multiple internal servers.I am closing this ticket as the primary goal of sharing the validation logic and structure is complete.
tobiu closed this issue on Nov 30, 2025, 3:29 PM
tobiu cross-referenced by #7950 on Nov 30, 2025, 3:38 PM
Context
We implemented basic client-side validation in #7946. However, the validation logic is currently fragmented. We want to unify it by moving the tool service to a shared location.
Goal
Refactor
ai/mcp/server/toolService.mjsto be a shared resource for both Clients and Servers.Requirements
ai/mcp/server/toolService.mjsone folder level up (toai/mcp/toolService.mjs) to allow shared access.validateToolInput(): Implement a shared methodvalidateToolInput(toolName, args, schema)within the shared service.Neo.ai.mcp.client.Clientand the MCP Servers to import and use this shared service for validation.Deliverables
ai/mcp/toolService.mjs.Client.mjsand Server implementations.