This repository was archived by the owner on Jun 28, 2026. It is now read-only.
fix(mcp): register custom tools with a Zod input schema#243
Open
valentingoulier wants to merge 1 commit into
Open
fix(mcp): register custom tools with a Zod input schema#243valentingoulier wants to merge 1 commit into
valentingoulier wants to merge 1 commit into
Conversation
`registerCustomTools` passed a plain `{ type, description }` object as the
tool input schema through the legacy `server.tool()` API. Since
@modelcontextprotocol/sdk 1.26 the SDK validates that argument and throws
`Tool <name> expected a Zod schema or ToolAnnotations, but received an
unrecognized object`, crashing the server on startup — `@primeng/mcp` is
the first to hit it because `get_migration_guide` is a custom tool.
Translate the lightweight `{ type, description, required?, default? }`
parameter format into a Zod raw shape and register through `registerTool`,
consistent with every other tool in this package. Honors `required`/
`default` and works on both the pinned SDK (1.25.x) and current (1.29.x).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes a startup crash in @primeuix/mcp when used with newer @modelcontextprotocol/sdk versions by registering framework-specific custom tools using a Zod input schema (matching the SDK’s post-1.26 validation rules and the rest of this package’s tool registrations).
Changes:
- Added Zod import and a small mapper (
customParameterSchema) to translate custom parametertypestrings into Zod schemas. - Updated
registerCustomToolsto build az.ZodRawShapefrom the lightweight{ type, description, required?, default? }parameter format. - Switched custom tool registration from the legacy
server.tool(...)overload toserver.registerTool(...)with{ description, inputSchema }.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
#228 {
"command": "npx",
"args": [
"-y",
"-p",
"@primevue/mcp@4.5.5",
"-p",
"@modelcontextprotocol/sdk@1.27.1",
"primevue-mcp"
]
}It looks like @modelcontextprotocol/sdk >= 1.28.0 introduces API incompatibilities, so pinning @modelcontextprotocol/sdk@1.27.1 works around the issue for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
@primeng/mcp(which depends on@primeuix/mcp) crashes on startup:Reproduced with
@modelcontextprotocol/sdk1.29.0. Because@primeuix/mcpdeclares"@modelcontextprotocol/sdk": "^1.25.2", fresh/npxinstalls resolve the latest 1.x and hit the crash.Root cause
registerCustomTools(packages/mcp/src/index.ts) registers framework-specific tools through the legacyserver.tool(name, description, paramsObject, cb)overload, passing a plain object:As of
@modelcontextprotocol/sdk1.26,McpServer.tool()validates that third argument: it must be a Zod raw shape orToolAnnotations. A{ type, description }object is neither (its values are objects), so the SDK throws "expected a Zod schema or ToolAnnotations, but received an unrecognized object". PrimeNG'sget_migration_guideis the first custom tool registered, so that's where the crash surfaces.Every other tool in this package already uses
server.registerTool(name, { description, inputSchema }, cb)with a Zod shape — onlyregisterCustomToolsstill used the old path.Fix
Translate the lightweight
{ type, description, required?, default? }parameter format into a Zod raw shape and register viaregisterTool, consistent with the rest of the package:type→z.string()/z.number()/z.boolean()/z.array(...)/z.record(...).optional()unlessrequired: truedefaultVerification
mainwith SDK 1.29.0.createPrimeMcpServerregisters the custom tools without throwing on both SDK 1.29.0 and 1.25.2 (the declared floor).tsupbuild (ESM +dtstype-check) passes; Prettier clean against the repo config.🤖 Generated with Claude Code