Skip to content

Conversation

nielthiart
Copy link
Contributor

The response from the server was not matching the expected InitializeResult schema 1.

  1. The serverInfo field contained a description that was not part of the schema.
  2. The capabilities field was incorrectly nested in serverInfo.
  3. The capabilities field in the response included resources, even though this server does not support resources.

This change also adds an instructions field to the response, which provides guidance on how to use the server.

The SDK takes care of registering capabilities 2, so we don't need to add this when instantiating the server object.

Response does not match InitializeResult schema:

{
  "capabilities": {
    "tools": {
      "listChanged": true
    }
  },
  "serverInfo": {
    "name": "Context7",
    "version": "1.0.13",
    "description": "Retrieves up-to-date documentation and code examples for any library.",
    "capabilities": {
      "resources": {},
      "tools": {}
    }
  }
}

Response matches InitializeResult schema:

{
  "capabilities": {
    "tools": {
      "listChanged": true
    }
  },
  "serverInfo": {
    "name": "Context7",
    "version": "1.0.13"
  },
  "instructions": "Use this server to retrieve up-to-date documentation and code examples for any library."
}

Fixes #282

Footnotes

  1. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-03-26/schema.ts#L179-L193

  2. https://github.com/modelcontextprotocol/typescript-sdk/blob/2cf4f0ca86ff841aca53ac8ef5f3227ba3789386/src/server/mcp.ts#L101

The response from the server was not matching the expected `InitializeResult` schema [^1].

1. The `serverInfo` field contained a `description` that was not part of the schema.
2. The `capabilities` field was incorrectly nested in `serverInfo`.
3. The `capabilities` field in the response included `resources`, even though this server does not support resources.

This change also adds an `instructions` field to the response, which provides guidance on how to use the server.

The SDK takes care of registering capabilities [^2], so we don't need to add this when instantiating the `server` object.

Response does not match `InitializeResult` schema:

```json
{
  "capabilities": {
    "tools": {
      "listChanged": true
    }
  },
  "serverInfo": {
    "name": "Context7",
    "version": "1.0.13",
    "description": "Retrieves up-to-date documentation and code examples for any library.",
    "capabilities": {
      "resources": {},
      "tools": {}
    }
  }
}
```

Response matches `InitializeResult` schema:

```json
{
  "capabilities": {
    "tools": {
      "listChanged": true
    }
  },
  "serverInfo": {
    "name": "Context7",
    "version": "1.0.13"
  },
  "instructions": "Use this server to retrieve up-to-date documentation and code examples for any library."
}
```

[^1]: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-03-26/schema.ts#L179-L193

[^2]: https://github.com/modelcontextprotocol/typescript-sdk/blob/2cf4f0ca86ff841aca53ac8ef5f3227ba3789386/src/server/mcp.ts#L101

Fixes upstash#282
Copy link
Collaborator

@enesgules enesgules left a comment

Choose a reason for hiding this comment

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

This is great Niel thank you!

@enesgules enesgules merged commit d2083b9 into upstash:master Jun 13, 2025
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.

Minor: InitializeResult MCP schema mismatch in Context7 server response

2 participants