Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-mcp): send server instructions with createMCPServer #2271

Closedchirag-zenskar(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2271/headopened View on GitHub

Showing 7 changed files with 36 additions and 2 deletions (loading 4).

x
0 of 7 viewed, 7 left
5 additions and 0 deletions.changeset/ai-mcp-server-instructions.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-mcp': minor
+---
+​
+`createMCPServer` takes an `instructions` option. The server sends it to the client as the MCP `instructions` field, in the `initialize` result on spec 2025 and in the `server/discover` result on spec 2026-07-28. Without it, the server sends no `instructions`.
14 additions and 0 deletionsdocs/mcp/server.mdModified
View file
@@ -224,6 +224,20 @@
```
​
+### Send instructions to the client
+​
+Pass `instructions` to tell a client how to use the server, for example how its tools relate or which one to call first. The server sends the text in the `instructions` field of the `initialize` result on spec 2025 and of the `server/discover` result on spec 2026-07-28. A client or host may add it to the model's context. Without `instructions`, the server sends none.
+​
+```ts
+import { createMCPServer } from '@tanstack/ai-mcp/server'
+​
+const server = createMCPServer({
+ name: 'notes',
+ version: '1.0.0',
+ instructions: 'Call `search_notes` before `read_note`. A note id is stable.',
+})
+```
+​
### 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`.