Skip to content

Commit 9dd151e

Browse files
authored
Merge branch 'main' into mcpb-blog
2 parents 204431d + 4f4104c commit 9dd151e

File tree

13 files changed

+234
-166
lines changed

13 files changed

+234
-166
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.claude/
22
node_modules/
33
.DS_Store
4+
.idea/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.16.0
1+
v20.17.0

docs/docs/develop/build-client.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@ async function main() {
738738
try {
739739
await mcpClient.connectToServer(process.argv[2]);
740740
await mcpClient.chatLoop();
741+
} catch (e) {
742+
console.error("Error:", e);
743+
await mcpClient.cleanup();
744+
process.exit(1);
741745
} finally {
742746
await mcpClient.cleanup();
743747
process.exit(0);
@@ -842,6 +846,7 @@ If you see:
842846
- `Tool execution failed`: Verify the tool's required environment variables are set
843847
- `ANTHROPIC_API_KEY is not set`: Check your .env file and environment variables
844848
- `TypeError`: Ensure you're using the correct types for tool arguments
849+
- `BadRequestError`: Ensure you have enough credits to access the Anthropic API
845850

846851
</Tab>
847852

docs/specification/draft/basic/index.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ may reserve particular names for purpose-specific metadata, as declared in those
191191

192192
- If specified, MUST be a series of labels separated by dots (`.`), followed by a slash (`/`).
193193
- Labels MUST start with a letter and end with a letter or digit; interior characters can be letters, digits, or hyphens (`-`).
194-
- Any prefix beginning with zero or more valid labels, followed by `modelcontextprotocol` or `mcp`, followed by any valid label,
195-
is **reserved** for MCP use.
196-
- For example: `modelcontextprotocol.io/`, `mcp.dev/`, `api.modelcontextprotocol.org/`, and `tools.mcp.com/` are all reserved.
194+
- Implementations SHOULD use reverse DNS notation (e.g., `com.example/` rather than `example.com/`).
195+
- Any prefix where the second label is `modelcontextprotocol` or `mcp` is **reserved** for MCP use.
196+
- For example: `io.modelcontextprotocol/`, `dev.mcp/`, `org.modelcontextprotocol.api/`, and `com.mcp.tools/` are all reserved.
197+
- However, `com.example.mcp/` is NOT reserved, as the second label is `example`.
197198

198199
**Name:**
199200

docs/specification/draft/basic/transports.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ MCP endpoint.
111111
at any time in order to avoid holding a long-lived connection. The client
112112
**SHOULD** then "poll" the SSE stream by attempting to reconnect.
113113
- If the server does close the _connection_ prior to terminating the _SSE stream_,
114-
it **SHOULD** send an SSE event with a standard `retry` field before
114+
it **SHOULD** send an SSE event with a standard [`retry`](https://html.spec.whatwg.org/multipage/server-sent-events.html#:~:text=field%20name%20is%20%22retry%22) field before
115115
closing the connection. The client **MUST** respect the `retry` field,
116116
waiting the given number of milliseconds before attempting to reconnect.
117117
- The SSE stream **SHOULD** eventually include a JSON-RPC _response_ for the
@@ -148,6 +148,9 @@ MCP endpoint.
148148
[resuming](#resumability-and-redelivery) a stream associated with a previous client
149149
request.
150150
- The server **MAY** close the SSE stream at any time.
151+
- If the server closes the _connection_ without terminating the _stream_, it
152+
**SHOULD** follow the same polling behavior as described for POST requests:
153+
sending a `retry` field and allowing the client to reconnect.
151154
- The client **MAY** close the SSE stream at any time.
152155

153156
### Multiple Connections
@@ -168,15 +171,20 @@ lost:
168171
- If present, the ID **MUST** be globally unique across all streams within that
169172
[session](#session-management)—or all streams with that specific client, if session
170173
management is not in use.
171-
2. If the client wishes to resume after a broken connection, it **SHOULD** issue an HTTP
172-
GET to the MCP endpoint, and include the
174+
- Event IDs **SHOULD** encode sufficient information to identify the originating
175+
stream, enabling the server to correlate a `Last-Event-ID` to the correct stream.
176+
2. If the client wishes to resume after a disconnection (whether due to network failure
177+
or server-initiated closure), it **SHOULD** issue an HTTP GET to the MCP endpoint,
178+
and include the
173179
[`Last-Event-ID`](https://html.spec.whatwg.org/multipage/server-sent-events.html#the-last-event-id-header)
174180
header to indicate the last event ID it received.
175181
- The server **MAY** use this header to replay messages that would have been sent
176182
after the last event ID, _on the stream that was disconnected_, and to resume the
177183
stream from that point.
178184
- The server **MUST NOT** replay messages that would have been delivered on a
179185
different stream.
186+
- This mechanism applies regardless of how the original stream was initiated (via
187+
POST or GET). Resumption is always via HTTP GET with `Last-Event-ID`.
180188

181189
In other words, these event IDs should be assigned by servers on a _per-stream_ basis, to
182190
act as a cursor within that particular stream.

docs/specification/draft/basic/utilities/tasks.mdx

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ The set of capabilities in `capabilities.tasks.requests` is exhaustive. If a req
108108

109109
### Tool-Level Negotiation
110110

111-
Tool calls are given special consideration for the purpose of task augmentation. In the result of `tools/list`, tools declare support for tasks via `annotations.taskHint`, which if present can have a value of `"always"`, `"optional"`, or `"never"`.
111+
Tool calls are given special consideration for the purpose of task augmentation. In the result of `tools/list`, tools declare support for tasks via `execution.taskSupport`, which if present can have a value of `"required"`, `"optional"`, or `"forbidden"`.
112112

113113
This is to be interpreted as a fine-grained layer in addition to capabilities, following these rules:
114114

115-
1. If a server's capabilities include `tasks.requests.tools.call: false`, then clients **MUST NOT** attempt to use task augmentation on that server's tools, regardless of the `taskHint` value.
116-
1. If a server's capabilities include `tasks.requests.tools.call: true`, then clients consider the value of `taskHint`, and handle it accordingly:
117-
1. If `taskHint` is not present or `"never"`, clients **MUST NOT** attempt to invoke the tool as a task. Servers **SHOULD** return a `-32601` (Method not found) error if a client attempts to do so. This is the default behavior.
118-
1. If `taskHint` is `"optional"`, clients **MAY** invoke the tool as a task or as a normal request.
119-
1. If `taskHint` is `"always"`, clients **SHOULD** invoke the tool as a task. Servers **MAY** return a `-32601` (Method not found) error if a client does not attempt to do so.
115+
1. If a server's capabilities do not include `tasks.requests.tools.call`, then clients **MUST NOT** attempt to use task augmentation on that server's tools, regardless of the `execution.taskSupport` value.
116+
1. If a server's capabilities include `tasks.requests.tools.call`, then clients consider the value of `execution.taskSupport`, and handle it accordingly:
117+
1. If `execution.taskSupport` is not present or `"forbidden"`, clients **MUST NOT** attempt to invoke the tool as a task. Servers **SHOULD** return a `-32601` (Method not found) error if a client attempts to do so. This is the default behavior.
118+
1. If `execution.taskSupport` is `"optional"`, clients **MAY** invoke the tool as a task or as a normal request.
119+
1. If `execution.taskSupport` is `"required"`, clients **MUST** invoke the tool as a task. Servers **MUST** return a `-32601` (Method not found) error if a client does not attempt to do so.
120120

121121
## Protocol Messages
122122

@@ -182,10 +182,18 @@ This guidance is non-binding and is provisional logic intended to account for th
182182

183183
### Getting Tasks
184184

185+
<Note>
186+
187+
In the Streamable HTTP (SSE) transport, clients **MAY** disconnect from an SSE stream opened by the server in response to a `tasks/get` request at any time.
188+
189+
While this note is not prescriptive regarding the specific usage of SSE streams, all implementations **MUST** continue to comply with the existing [Streamable HTTP transport specification](../transports#sending-messages-to-the-server).
190+
191+
</Note>
192+
185193
Requestors poll for task completion by sending [`tasks/get`](/specification/draft/schema#tasks%2Fget) requests.
186194
Requestors **SHOULD** respect the `pollInterval` provided in responses when determining polling frequency.
187195

188-
Requestors **SHOULD** continue polling until the task reaches a terminal status (`completed`, `failed`, or `cancelled`), or until encountering the [`input_required`](#input-required-status) status.
196+
Requestors **SHOULD** continue polling until the task reaches a terminal status (`completed`, `failed`, or `cancelled`), or until encountering the [`input_required`](#input-required-status) status. Note that invoking `tasks/result` does not imply that the requestor needs to stop polling - requestors **SHOULD** continue polling the task status via `tasks/get` if they are not actively waiting for `tasks/result` to complete.
189197

190198
**Request:**
191199

@@ -219,10 +227,20 @@ Requestors **SHOULD** continue polling until the task reaches a terminal status
219227

220228
### Retrieving Task Results
221229

230+
<Note>
231+
232+
In the Streamable HTTP (SSE) transport, clients **MAY** disconnect from an SSE stream opened by the server in response to a `tasks/result` request at any time.
233+
234+
While this note is not prescriptive regarding the specific usage of SSE streams, all implementations **MUST** continue to comply with the existing [Streamable HTTP transport specification](../transports#sending-messages-to-the-server).
235+
236+
</Note>
237+
222238
After a task completes the operation result is retrieved via [`tasks/result`](/specification/draft/schema#tasks%2Fresult). This is distinct from the initial `CreateTaskResult` response, which contains only task data. The result structure matches the original request type (e.g., `CallToolResult` for `tools/call`).
223239

224240
To retrieve the result of a completed task, requestors can send a `tasks/result` request:
225241

242+
While `tasks/result` blocks until the task reaches a terminal status, requestors can continue polling via `tasks/get` in parallel if they are not actively blocked waiting for the result, such as if their previous `tasks/result` request failed or was cancelled. This allows requestors to monitor status changes or display progress updates while the task executes, even after invoking `tasks/result`.
243+
226244
**Request:**
227245

228246
```json
@@ -412,7 +430,9 @@ stateDiagram-v2
412430

413431
With the Streamable HTTP (SSE) transport, servers often close SSE streams after delivering a response message, which can lead to ambiguity regarding the stream used for subsequent task messages.
414432

415-
Implementations have flexibility in how they manage SSE streams during task polling and result retrieval.
433+
Servers can handle this by enqueueing messages to the client to side-channel task-related messages alongside other responses.
434+
435+
Servers have flexibility in how they manage SSE streams during task polling and result retrieval, and clients **SHOULD** expect messages to be delivered on any SSE stream, including the HTTP GET stream.
416436
One possible approach is maintaining an SSE stream on `tasks/result` (see notes on the `input_required` status).
417437
Where possible, servers **SHOULD NOT** upgrade to an SSE stream in response to a `tasks/get` request, as the client has indicated it wishes to poll for a result.
418438

@@ -482,19 +502,29 @@ sequenceDiagram
482502
participant S as Server (Receiver)
483503
Note over C,S: 1. Task Creation
484504
C->>S: Request with task field (ttl)
505+
activate S
485506
S->>C: CreateTaskResult (taskId, status: working, ttl, pollInterval)
507+
deactivate S
486508
Note over C,S: 2. Task Polling
487509
C->>S: tasks/get (taskId)
510+
activate S
488511
S->>C: working
512+
deactivate S
489513
Note over S: Task processing continues...
490514
C->>S: tasks/get (taskId)
515+
activate S
491516
S->>C: working
517+
deactivate S
492518
Note over S: Task completes
493519
C->>S: tasks/get (taskId)
520+
activate S
494521
S->>C: completed
522+
deactivate S
495523
Note over C,S: 3. Result Retrieval
496524
C->>S: tasks/result (taskId)
525+
activate S
497526
S->>C: Result content
527+
deactivate S
498528
Note over C,S: 4. Cleanup
499529
Note over S: After ttl period from creation, task is cleaned up
500530
```
@@ -513,44 +543,61 @@ sequenceDiagram
513543
514544
Note over C,S: Client augments with task
515545
C->>S: tools/call (ttl: 3600000)
546+
activate S
516547
S->>C: CreateTaskResult (task-123, status: working)
548+
deactivate S
517549
518550
Note over LLM,C: Client continues processing other requests<br/>while task executes in background
519551
LLM->>C: Request other operation
520552
C->>LLM: Other operation result
521553
522554
Note over C,S: Client polls for status
523555
C->>S: tasks/get (task-123)
556+
activate S
524557
S->>C: working
558+
deactivate S
525559
526560
Note over S: Server needs information from client<br/>Task moves to input_required
527561
528562
Note over C,S: Client polls and discovers input_required
529563
C->>S: tasks/get (task-123)
564+
activate S
530565
S->>C: input_required
566+
deactivate S
531567
532-
Note over C,S: Client receives input requests
568+
Note over C,S: Client opens result stream
533569
C->>S: tasks/result (task-123)
534-
S->>C: elicitation/create (task-123)
570+
activate S
571+
S->>C: elicitation/create (related-task: task-123)
572+
activate C
535573
C->>U: Prompt user for input
536574
U->>C: Provide information
537-
C->>S: elicitation response (task-123)
575+
C->>S: elicitation response (related-task: task-123)
576+
deactivate C
577+
deactivate S
578+
579+
Note over C,S: Client closes result stream and resumes polling
538580
539581
Note over S: Task continues processing...<br/>Task moves back to working
540582
541-
Note over C,S: Client polls again
542583
C->>S: tasks/get (task-123)
584+
activate S
543585
S->>C: working
586+
deactivate S
544587
545588
Note over S: Task completes
546589
547590
Note over C,S: Client polls and discovers completion
548591
C->>S: tasks/get (task-123)
592+
activate S
549593
S->>C: completed
594+
deactivate S
550595
551596
Note over C,S: Client retrieves final results
552597
C->>S: tasks/result (task-123)
598+
activate S
553599
S->>C: Result content
600+
deactivate S
554601
C->>LLM: Process result
555602
556603
Note over S: Results retained for ttl period from creation
@@ -569,13 +616,17 @@ sequenceDiagram
569616
570617
Note over S,C: Server requests client operation (task-augmented)
571618
S->>C: sampling/createMessage (ttl: 3600000)
619+
activate C
572620
C->>S: CreateTaskResult (request-789, status: working)
621+
deactivate C
573622
574623
Note over S: Server continues processing<br/>while waiting for result
575624
576625
Note over S,C: Server polls for result
577626
S->>C: tasks/get (request-789)
627+
activate C
578628
C->>S: working
629+
deactivate C
579630
580631
Note over C,U: Client may present request to user
581632
C->>U: Review request
@@ -591,11 +642,15 @@ sequenceDiagram
591642
592643
Note over S,C: Server polls and discovers completion
593644
S->>C: tasks/get (request-789)
645+
activate C
594646
C->>S: completed
647+
deactivate C
595648
596649
Note over S,C: Server retrieves result
597650
S->>C: tasks/result (request-789)
651+
activate C
598652
C->>S: Result content
653+
deactivate C
599654
600655
Note over S: Server continues processing
601656
@@ -611,20 +666,26 @@ sequenceDiagram
611666
612667
Note over C,S: 1. Task Creation
613668
C->>S: tools/call (request ID: 42, ttl: 60000)
669+
activate S
614670
S->>C: CreateTaskResult (task-123, status: working)
671+
deactivate S
615672
616673
Note over C,S: 2. Task Processing
617674
C->>S: tasks/get (task-123)
675+
activate S
618676
S->>C: working
677+
deactivate S
619678
620679
Note over C,S: 3. Client Cancellation
621680
Note over C: User requests cancellation
622681
C->>S: tasks/cancel (taskId: task-123)
682+
activate S
623683
624684
Note over S: Server stops execution (best effort)
625685
Note over S: Task moves to cancelled status
626686
627687
S->>C: Task (status: cancelled)
688+
deactivate S
628689
629690
Note over C: Client receives confirmation
630691

docs/specification/draft/changelog.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ the previous revision, [2025-06-18](/specification/2025-06-18).
1414
3. Enhance authorization flows with incremental scope consent via `WWW-Authenticate` ([SEP-835](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/835))
1515
4. Provide guidance on tool names ([SEP-986](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1603))
1616
5. Update `ElicitResult` and `EnumSchema` to use a more standards-based approach and support titled, untitled, single-select, and multi-select enums ([SEP-1330](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1330)).
17-
6. Added support for [URL mode elicitation](/specification/draft/client/elicitation#url-elicitation-requests)([SEP-1036](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/887))
17+
6. Added support for [URL mode elicitation](/specification/draft/client/elicitation#url-elicitation-requests) ([SEP-1036](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/887))
1818
7. Add tool calling support to sampling via `tools` and `toolChoice` parameters ([SEP-1577](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1577))
1919
8. Add support for OAuth Client ID Metadata Documents as a recommended client registration mechanism ([SEP-991](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/991), PR [#1296](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1296))
2020
9. Add experimental support for [tasks](/specification/draft/basic/utilities/tasks) to enable tracking durable requests with polling and deferred result retrieval ([SEP-1686](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1686)).
@@ -26,9 +26,10 @@ the previous revision, [2025-06-18](/specification/2025-06-18).
2626
3. Updated the [Security Best Practices guidance](https://modelcontextprotocol.io/specification/draft/basic/security_best_practices).
2727
4. Clarify that input validation errors should be returned as Tool Execution Errors rather than Protocol Errors to enable model self-correction ([SEP-1303](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1303)).
2828
5. Support polling SSE streams by allowing servers to disconnect at will ([SEP-1699](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1699)).
29-
6. Align OAuth 2.0 Protected Resource Metadata discovery with RFC 9728, making `WWW-Authenticate` header optional with fallback to `.well-known` endpoint ([SEP-985](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/985)).
30-
7. Add support for default values in all primitive types (string, number, enum) for elicitation schemas ([SEP-1034](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1034)).
31-
8. Establish JSON Schema 2020-12 as the default dialect for MCP schema definitions ([SEP-1613](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1613)).
29+
6. Clarify SEP-1699: GET streams support polling, resumption always via GET regardless of stream origin, event IDs should encode stream identity, disconnection includes server-initiated closure (Issue [#1847](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1847)).
30+
7. Align OAuth 2.0 Protected Resource Metadata discovery with RFC 9728, making `WWW-Authenticate` header optional with fallback to `.well-known` endpoint ([SEP-985](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/985)).
31+
8. Add support for default values in all primitive types (string, number, enum) for elicitation schemas ([SEP-1034](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1034)).
32+
9. Establish JSON Schema 2020-12 as the default dialect for MCP schema definitions ([SEP-1613](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1613)).
3233

3334
## Other schema changes
3435

0 commit comments

Comments
 (0)