Skip to content

feat: MCP SDK >=1.19 compatibility\n\n- upgrade @modelcontextprotocol…#38

Open
antoan wants to merge 5 commits intoadeze:masterfrom
antoan:fix/json-schema-tools
Open

feat: MCP SDK >=1.19 compatibility\n\n- upgrade @modelcontextprotocol…#38
antoan wants to merge 5 commits intoadeze:masterfrom
antoan:fix/json-schema-tools

Conversation

@antoan
Copy link

@antoan antoan commented Oct 22, 2025

…/sdk to ^1.20.1\n- convert Zod input schemas to JSON Schema for registerTool\n- fallback to minimal {type:'object'} schema for safety\n- ensure getManifest emits JSON-Schema-friendly tool definitions\n

…/sdk to ^1.20.1\n- convert Zod input schemas to JSON Schema for registerTool\n- fallback to minimal {type:'object'} schema for safety\n- ensure getManifest emits JSON-Schema-friendly tool definitions\n
@gemini-code-assist
Copy link

Summary of Changes

Hello @antoan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on updating the project's integration with the Model Context Protocol (MCP) SDK to support versions 1.19 and above. The primary goal is to ensure that tool registration and manifest generation processes are fully compatible with the new SDK's JSON Schema requirements for tool input definitions, enhancing robustness and future-proofing the application.

Highlights

  • SDK Upgrade: The @modelcontextprotocol/sdk dependency has been upgraded to version ^1.20.1 to ensure compatibility with newer MCP SDK features and requirements.
  • JSON Schema Compatibility: Tool input schemas, previously defined using Zod, are now explicitly converted or represented as JSON Schema objects for registerTool and getManifest methods, aligning with the updated SDK's expectations.
  • Minimal Input Schema Fallback: A generic, minimal { type: "object", properties: {}, additionalProperties: true } schema is now used as a fallback for tool inputs, ensuring safety and broad compatibility when a more specific JSON Schema isn't directly derived.
  • Manifest Generation: The getManifest method has been refactored to always construct a JSON-Schema-friendly manifest, including explicit resource definitions, rather than relying on a conditional SDK method.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to add compatibility with MCP SDK >=1.19 by updating dependencies and adapting to the new schema requirements. The dependency updates are correct, but the implementation for converting Zod schemas to JSON schemas is incomplete. Currently, it uses a generic placeholder schema, which will prevent tools from being used correctly. My review includes critical suggestions to properly implement the schema conversion using zod-to-json-schema. I've also suggested an improvement to the new helper script to make it more robust.

Comment on lines 517 to 521
const tools = toolConfigs.map((config) => ({
name: config.name,
description: config.description,
inputSchema: { type: "object", properties: {}, additionalProperties: true },
}));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The manifest generation for tools is using a generic, empty inputSchema. This defeats the purpose of schema definition, as clients (like language models) won't know what parameters a tool accepts. The PR description mentions converting Zod schemas to JSON schemas, and zodToJsonSchema is even imported, but this implementation doesn't use it. You should use the imported zodToJsonSchema function to convert each tool's Zod schema into a proper JSON schema. It's also good practice to wrap this conversion in a try...catch block and fall back to the generic schema only if the conversion fails, as intended by the PR description.

        const tools = toolConfigs.map((config) => {
            let inputSchema: any;
            try {
                inputSchema = zodToJsonSchema(config.inputSchema);
            } catch (e) {
                console.error(`Failed to convert Zod schema to JSON Schema for tool "${config.name}" in manifest:`, e);
                inputSchema = { type: "object", properties: {}, additionalProperties: true };
            }
            return {
                name: config.name,
                description: config.description,
                inputSchema,
            };
        });

Comment on lines 572 to 573

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The inputSchema is hardcoded to a generic object, which means the MCP server won't have the actual schema for tool input validation and discovery. The PR's goal is to convert Zod schemas to JSON schemas, but this is not being done. You should use zodToJsonSchema to perform the conversion. A try...catch block is recommended to handle any potential conversion errors and fall back to a generic schema, as mentioned in the PR description.

            let inputSchema: any;
            try {
                // Convert Zod schema to a JSON Schema object compatible with MCP SDK >= 1.19
                inputSchema = zodToJsonSchema(config.inputSchema);
            } catch (e) {
                console.error(`Failed to convert Zod schema to JSON Schema for tool "${config.name}":`, e);
                // Fallback to minimal schema for safety
                inputSchema = { type: "object", properties: {}, additionalProperties: true };
            }

Comment on lines +3 to +8
const svc = new RaindropMCPService();
const server = svc.getServer();
const tools = (server)._tools || [];
for (const t of tools) {
console.log(JSON.stringify({ name: t.name, type: t.inputSchema?.type, inputSchema: t.inputSchema }, null, 2));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This script accesses the private _tools property of the server. It's better to use the public listTools() method available on the RaindropMCPService instance. This avoids relying on internal implementation details that might change in the future. Note that listTools() is an async method, so the script needs to be adapted to handle the promise.

Suggested change
const svc = new RaindropMCPService();
const server = svc.getServer();
const tools = (server)._tools || [];
for (const t of tools) {
console.log(JSON.stringify({ name: t.name, type: t.inputSchema?.type, inputSchema: t.inputSchema }, null, 2));
}
async function printTools() {
const svc = new RaindropMCPService();
const tools = await svc.listTools();
for (const t of tools) {
console.log(JSON.stringify({ name: t.name, type: t.inputSchema?.type, inputSchema: t.inputSchema }, null, 2));
}
}
printTools().catch(console.error);

…efault zod for legacy clients\n- json for MCP SDK 1.19+ validators\n
- Goose 1.11+ requires JSON Schema (no more Zod shapes)
- Remove conditional logic; toObjectJsonSchema() always applied
- Simplifies codebase and aligns with MCP SDK 1.19+ requirements
- zod-to-json-schema 3.24.6 is incompatible with Zod 4.x
- Zod 4.x was producing invalid JSON Schema (type: 'string' for z.object())
- Downgraded zod from ^4.1.9 to ^3.23.8
- Simplified toObjectJsonSchema() function - now works correctly
- Validated with MCP Inspector: all tools pass schema validation
- Goose 1.11.1 still fails with 'keyValidator._parse' error (client bug)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments