Skip to content

feat(ai/mcp): expose serverInfo from MCP initialize handshake#13825

Closed
alexzurbonsen wants to merge 4 commits intovercel:mainfrom
alexzurbonsen:feat/pass-server-info
Closed

feat(ai/mcp): expose serverInfo from MCP initialize handshake#13825
alexzurbonsen wants to merge 4 commits intovercel:mainfrom
alexzurbonsen:feat/pass-server-info

Conversation

@alexzurbonsen
Copy link
Copy Markdown

@alexzurbonsen alexzurbonsen commented Mar 25, 2026

Background

Motivation: I would like to use the title (name respectively) in a UI.

Summary

Exposes the MCP server's serverInfo (containing name, version, and optional title) as a readonly property on ai sdk's MCPClient. Previously, this was parsed during initialization but discarded.

MCP Specs:

The (spec page)[https://modelcontextprotocol.io/specification/2025-11-25] lists (schema.ts)[https://github.com/modelcontextprotocol/modelcontextprotocol/blob/a0d7bf599d56dfc0c73a2752dc68995bf0e72bb8/schema/2025-11-25/schema.ts#L530] as authoritative reference.

The Implementation type is defined here:
https://github.com/modelcontextprotocol/modelcontextprotocol/blob/a0d7bf599d56dfc0c73a2752dc68995bf0e72bb8/schema/2025-11-25/schema.ts#L552

and used in:
clientInfo: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/a0d7bf599d56dfc0c73a2752dc68995bf0e72bb8/schema/2025-11-25/schema.ts#L263
serverInfo: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/a0d7bf599d56dfc0c73a2752dc68995bf0e72bb8/schema/2025-11-25/schema.ts#L287

Manual Verification

From examples/mcp run the examples from the second commit of this branch.

Terminal 1: pnpm tsx src/server-info/server.ts
Terminal 2: pnpm tsx src/server-info/client.ts

See the client logging serverInfo: { name: 'my-weather-server', version: '2.1.0' }

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Related Issues

`MCPClient` now exposes the server's `serverInfo` (containing
`name`, `version`, and optional `title`) as a readonly property.
Previously, this was parsed during initialization but discarded.

Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>
Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>
@tigent tigent bot added ai/mcp related to `@ai-sdk/mcp` package feature New feature or request labels Mar 25, 2026
@alexzurbonsen
Copy link
Copy Markdown
Author

@aayush-kapoor or @lgrammel: could you give this PR a review? You have touched some of the files before. Thank you :)

@aayush-kapoor
Copy link
Copy Markdown
Collaborator

could you link to the official docs as a reference?

@alexzurbonsen
Copy link
Copy Markdown
Author

could you link to the official docs as a reference?

Sure, I updated the PR description.

Copy link
Copy Markdown
Collaborator

@aayush-kapoor aayush-kapoor left a comment

Choose a reason for hiding this comment

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

there wwre just a couple of things that i wanted to change so have continued this in #14288. will mark this as closed - thanks for raising!

aayush-kapoor added a commit that referenced this pull request Apr 10, 2026
## Background

introduced in #13825 

we used to capture the `serverInfo` in the schema but never surface it
through to the client. only `result.capabilities` was stored and
`result.serverInfo` was thrown away. there was no field on the client to
hold it and no property on the MCPClient interface to access it

## Summary

- added `title` field to `ClientOrServerImplementationSchema` to align
with [MCP
spec](https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation)
- exposed `serverInfo` via a getter function 

## Manual Verification

verified by running the client and server under
`examples/mcp/src/server-info`

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
vercel-ai-sdk bot pushed a commit that referenced this pull request Apr 10, 2026
## Background

introduced in #13825 

we used to capture the `serverInfo` in the schema but never surface it
through to the client. only `result.capabilities` was stored and
`result.serverInfo` was thrown away. there was no field on the client to
hold it and no property on the MCPClient interface to access it

## Summary

- added `title` field to `ClientOrServerImplementationSchema` to align
with [MCP
spec](https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation)
- exposed `serverInfo` via a getter function 

## Manual Verification

verified by running the client and server under
`examples/mcp/src/server-info`

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/mcp related to `@ai-sdk/mcp` package feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants