Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-mcp): serve and call MCP extensions with createMCPServer setup and MCPClient.request #1848

Mergedargjentsahiti(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/1848/headmerged by tombeckenham View on GitHub

Showing 14 changed files with 74 additions and 0 deletions (loading 11).

x
0 of 14 viewed, 14 left
5 additions and 0 deletions.changeset/ai-mcp-extension-setup.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-mcp': minor
+---
+​
+Serve and call MCP extensions. `createMCPServer` takes a `setup` function. It gets each SDK `McpServer` before it connects, so a server can declare an extension in `capabilities.extensions` and add handlers for its methods. `MCPClient.request` sends any request with the SDK `Client.request`, including the methods of an extension.
34 additions and 0 deletionsdocs/mcp/server.mdModified
View file
@@ -170,6 +170,40 @@
```
​
+## Serve an MCP extension
+​
+An [MCP extension](https://modelcontextprotocol.io/extensions/overview) adds methods that the core spec does not have. For example, the [Skills extension](https://modelcontextprotocol.io/extensions/skills/overview) adds `skills/list` and `skills/get`. A client uses an extension only when the server lists it in `capabilities.extensions`.
+​
+Pass `setup` to get each SDK `McpServer` before it connects. Declare the extension there, then add a handler for each of its methods:
+​
+```ts
+import { createMCPServer } from '@tanstack/ai-mcp/server'
+import { z } from 'zod'
+​
+const server = createMCPServer({
+ name: 'notes',
+ version: '1.0.0',