Skip to content

fix(schema): remove null nextCursor from MCP#116

Open
rozzilla wants to merge 2 commits intoplatformatic:mainfrom
rozzilla:fix/schema/remove-null-nextCursor-from-MCP
Open

fix(schema): remove null nextCursor from MCP#116
rozzilla wants to merge 2 commits intoplatformatic:mainfrom
rozzilla:fix/schema/remove-null-nextCursor-from-MCP

Conversation

@rozzilla
Copy link

The handleToolsList, handleResourcesList, and handlePromptsList handlers
explicitly set nextCursor: undefined in their response objects. When Fastify
serializes these through fast-json-stringify, undefined values are converted
to null, producing "nextCursor": null in the JSON output.

This violates the MCP specification JSON Schema,
which defines nextCursor as:

"nextCursor": {
  "description": "An opaque token representing the pagination position after the last returned result.",
  "type": "string"
}

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

When Fastify
serializes these through fast-json-stringify, undefined values are converted
to null, producing "nextCursor": null in the JSON output.

I'm relatively certain this is not the case, at least alone.

@rozzilla
Copy link
Author

When Fastify
serializes these through fast-json-stringify, undefined values are converted
to null, producing "nextCursor": null in the JSON output.

I'm relatively certain this is not the case, at least alone.

this is the error I received from the tool when I tried to connect to @platformatic/mcp:

{
    "error": {
        "type": "invalid_request_error",
        "message": "Error fetching remote server metadata: [\n  {\n    \"expected\": \"string\",\n    \"code\": \"invalid_type\",\n    \"path\": [\n      \"nextCursor\"\n    ],\n    \"message\": \"Invalid input: expected string, received null\"\n  }\n]"
    }
}

I suspect, but I can't garantee 100%, though this is coming exactly from fast-json-stringify

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

The tests you added pass without the changes in src.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@rozzilla rozzilla requested a review from mcollina March 20, 2026 17:39
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.

2 participants