You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`ping` sends a `ping` request and resolves with the empty result the server returns; the SDK answers a `ping` on both sides automatically, so neither side registers a handler.
A server that stops answering rejects the call with an `SdkError` coded `REQUEST_TIMEOUT` once `timeout` elapses.
188
+
189
+
`ping` is a 2025-era method — see [Protocol versions](../protocol-versions.md).
190
+
172
191
## Recap
173
192
174
193
-`listTools`, `listResources`, `listResourceTemplates`, and `listPrompts` aggregate every page; `{ cursor }` fetches a single raw page and `listMaxPages` caps the walk.
175
194
-`callTool` returns `content` for the model and, when the tool declares an `outputSchema`, `structuredContent` for your application.
176
195
-`readResource({ uri })` and `getPrompt({ name, arguments })` follow the same list-then-fetch shape as tools.
177
196
-`complete()` returns the server's suggestions for a prompt or resource-template argument.
178
197
-`onprogress` in the request options streams progress updates without changing the call's return type.
198
+
-`ping()` checks that the server still answers; both sides answer pings automatically.
`requestedSchema` reaches the client unchanged, `default` included; the end user submits the prefilled `pdf` or picks `csv`. An accept with `format` left out still returns:
A client that declares `elicitation: { form: { applyDefaults: true } }` — an SDK flag, not a protocol capability — fills defaulted fields the end user leaves out before the accept reaches your handler; the output above is that case.
163
+
:::
164
+
126
165
## Send the end user to a URL
127
166
128
167
**URL mode** replaces the form with a browser flow: pass `url` and a unique `elicitationId` instead of `requestedSchema`.
@@ -181,5 +220,6 @@ Elicitation only works against a client that declared the `elicitation` capabili
181
220
-`ctx.mcpReq.elicitInput` sends an `elicitation/create` request mid-handler and resolves with the end user's answer.
182
221
- Form mode carries a `message` and a flat JSON-Schema `requestedSchema`; the SDK validates accepted content against it.
183
222
-`result.action` is `accept`, `decline`, or `cancel`; `result.content` is present only on accept.
223
+
-`default` on a `requestedSchema` field prefills the form; a client that declares `applyDefaults` fills the field in when the end user leaves it out.
184
224
- URL mode hands the end user a browser flow — use it for anything sensitive.
185
225
- Calls against a client that never declared the `elicitation` capability fail before reaching the wire.
Copy file name to clipboardExpand all lines: docs/servers/prompts.md
+42-1Lines changed: 42 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,47 @@ server.registerPrompt(
116
116
117
117
The host hands the messages to the model in order, so the trailing `assistant` message becomes the start of its reply. `content` accepts the same union a tool result does: `text`, `image`, `audio`, `resource_link`, and `resource`.
118
118
119
+
## Add an image to a message
120
+
121
+
An `image` block carries base64 `data` and a `mimeType`; pair it with a `text` block that says what to do with the image.
`audio` takes the same shape: base64 `data` plus `mimeType`.
159
+
119
160
## Embed a resource in a message
120
161
121
162
`type: 'resource'` puts a resource's contents inside a message. Register the resource as usual — see [Resources](./resources.md) — and embed the same `uri`, `mimeType`, and `text` in the prompt.
@@ -201,5 +242,5 @@ The client sends `completion/complete` with the characters typed so far; the SDK
201
242
-`argsSchema` is one Zod object: the advertised argument list, argument validation, and the callback's argument types.
202
243
- Arguments that fail the schema reject `prompts/get` with a `-32602` protocol error; the callback never runs.
203
244
- The callback returns `{ messages }`; each message names a `role` and one `content` block.
204
-
- A message can embed a registered resource's contents with `type: 'resource'`.
245
+
- A message can carry an `image` (base64 `data` plus `mimeType`) or embed a registered resource's contents with `type: 'resource'`.
Copy file name to clipboardExpand all lines: docs/servers/tools.md
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,6 +129,69 @@ Calling `product-details` with `{ name: 'Travel mug' }` returns both renderings:
129
129
130
130
The wire encoding of structured results differs by protocol era — see [Protocol versions](../protocol-versions.md).
131
131
132
+
## Return other content types
133
+
134
+
One result can mix content blocks: `image` and `audio` carry base64 `data` with a `mimeType`; `resource` embeds a resource's contents inline; `resource_link` names a resource by `uri` without its bytes.
Copy file name to clipboardExpand all lines: docs/serving/legacy-clients.md
+35-2Lines changed: 35 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,12 +91,45 @@ Behind an Express body parser the Node stream is already drained: build the `Req
91
91
92
92
The v2 server never serves the HTTP+SSE transport. An SSE server moving to v2 moves to Streamable HTTP — `createMcpHandler` above — as part of the [v2 upgrade](../migration/upgrade-to-v2.md).
93
93
94
-
The client side keeps `SSEClientTransport`, so a v2 `Client` still reaches old SSE servers. For a server deployment that cannot move yet, a frozen v1 copy of the transport ships as `@modelcontextprotocol/server-legacy/sse` (deprecated).
94
+
The client side keeps `SSEClientTransport`, so a v2 `Client` still reaches old SSE servers. For a server deployment that cannot move yet, a frozen v1 copy of the transport ships as `@modelcontextprotocol/server-legacy/sse` (deprecated, planned for removal in v3).
95
+
96
+
Mount the frozen transport on two Express routes: `GET /sse` opens the stream and `POST /messages` delivers each client message to the session its `sessionId` query names. `createMcpExpressApp` takes the same options as on the [Express](./express.md) page: binding beyond localhost drops the default `Host`/`Origin` validation, so name the hosts you serve in `allowedHosts`, and raise `jsonLimit` above Express's 100kb default, since the SSE transport itself accepts messages up to 4mb.
Each `GET /sse` connects a fresh instance from `buildServer` and answers with an `endpoint` event naming `/messages?sessionId=…`; the client POSTs every JSON-RPC message there and reads responses off the stream.
95
128
96
129
## Recap
97
130
98
131
- Both entry points serve 2025-era clients from the same factory by default; `legacy: 'reject'` makes an endpoint modern-only.
99
132
- The default HTTP posture is per request and stateless: legacy `GET` and `DELETE` session operations answer `405`.
100
133
-`serveStdio` decides the era once per connection; its default is `'serve'`.
101
134
-`isLegacyRequest` in front of a strict handler keeps an existing sessionful 2025 deployment serving its clients.
102
-
- The v2 server never serves SSE; the frozen v1 transport is`@modelcontextprotocol/server-legacy/sse`, and the client keeps `SSEClientTransport`.
135
+
- The v2 server never serves SSE; the frozen v1 `SSEServerTransport` in`@modelcontextprotocol/server-legacy/sse` mounts on `GET /sse` + `POST /messages`, and the client keeps `SSEClientTransport`.
0 commit comments