Visitar URL original
chore: sync spec-types/draft.ts to modelcontextprotocol@2fb207d (#348) · modelcontextprotocol/conformance@7c4bea4 · GitHub
Skip to content

Commit 7c4bea4

Browse files
authored
chore: sync spec-types/draft.ts to 2fb207d (#348)
Re-vendors schema/draft/schema.ts from the spec repo at the merge commit of PR #2891 (2fb207da428f43a4981513ec2aef218b7533c5b3), which also includes #2889 and #2890. Type changes picked up: - Add NotificationMetaObject (with io.modelcontextprotocol/subscriptionId) - Add HEADER_MISMATCH (-32001) const and HeaderMismatchError interface - CancelledNotificationParams.requestId is now required - ClientNotification narrowed to CancelledNotification only - ListRootsRequest.params narrowed (drops progressToken) - Remove ElicitationCompleteNotification and elicitationId Also replaces the local -32001 literal in src/scenarios/server/http-standard-headers.ts with the new exported HEADER_MISMATCH constant. Claude-Session: https://claude.ai/code/session_01Gbqx5LodtAghT5fRYFxeja
1 parent 206709f commit 7c4bea4

3 files changed

Lines changed: 80 additions & 48 deletions

File tree

‎src/scenarios/server/http-standard-headers.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
sendStatelessRequest,
2626
type RunContext
2727
} from '../../connection';
28+
import { HEADER_MISMATCH } from '../../spec-types/draft';
2829

2930
const SPEC_REFERENCE = {
3031
id: 'SEP-2243-Server-Validation',
@@ -55,7 +56,7 @@ const SPEC_REFERENCE_CUSTOM = {
5556
url: 'https://modelcontextprotocol.io/specification/draft/basic/transports#server-behavior-for-custom-headers'
5657
};
5758

58-
const HEADER_MISMATCH_ERROR_CODE = -32001;
59+
const HEADER_MISMATCH_ERROR_CODE = HEADER_MISMATCH;
5960

6061
// Coarse, requirement-level check IDs (SEP-2243) for STANDARD-header
6162
// rejections. Every standard-header rejection case emits this same pair of IDs;

‎src/spec-types/SOURCE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
modelcontextprotocol@0168c57fc74aba6e6dcf8f0b7191db3caaa5ad65
1+
modelcontextprotocol@2fb207da428f43a4981513ec2aef218b7533c5b3

‎src/spec-types/draft.ts‎

Lines changed: 77 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,29 @@ export interface RequestMetaObject extends MetaObject {
110110
"io.modelcontextprotocol/logLevel"?: LoggingLevel;
111111
}
112112

113+
/**
114+
* Extends {@link MetaObject} with additional notification-specific fields. All key naming rules from `MetaObject` apply.
115+
*
116+
* @see {@link MetaObject} for key naming rules and reserved prefixes.
117+
* @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details.
118+
* @category Common Types
119+
*/
120+
export interface NotificationMetaObject extends MetaObject {
121+
/**
122+
* Identifies the subscription stream a notification was delivered on. The
123+
* server MUST include this key on every notification delivered via a
124+
* {@link SubscriptionsListenRequest | subscriptions/listen} stream, so the
125+
* client can correlate the notification with the originating subscription.
126+
* The key is absent on notifications not delivered via a subscription
127+
* stream (e.g. progress notifications for an in-flight request), which is
128+
* why it is optional here.
129+
*
130+
* The value is the JSON-RPC ID of the `subscriptions/listen` request that
131+
* opened the stream.
132+
*/
133+
"io.modelcontextprotocol/subscriptionId"?: RequestId;
134+
}
135+
113136
/**
114137
* A progress token, used to associate progress notifications with the original request.
115138
*
@@ -147,7 +170,7 @@ export interface Request {
147170
* @category Common Types
148171
*/
149172
export interface NotificationParams {
150-
_meta?: MetaObject;
173+
_meta?: NotificationMetaObject;
151174
}
152175

153176
/** @internal */
@@ -357,6 +380,15 @@ export interface InternalError extends Error {
357380
code: typeof INTERNAL_ERROR;
358381
}
359382

383+
/**
384+
* Error code returned when the HTTP headers of a request do not match the
385+
* corresponding values in the request body, or required headers are
386+
* missing or malformed.
387+
*
388+
* @category Errors
389+
*/
390+
export const HEADER_MISMATCH = -32001;
391+
360392
/**
361393
* Error code returned when a server requires a client capability that was
362394
* not declared in the request's `clientCapabilities`.
@@ -373,6 +405,26 @@ export const MISSING_REQUIRED_CLIENT_CAPABILITY = -32003;
373405
*/
374406
export const UNSUPPORTED_PROTOCOL_VERSION = -32004;
375407

408+
/**
409+
* Returned when a server rejects a request because the values in the HTTP
410+
* headers do not match the corresponding values in the request body, or
411+
* because required headers are missing or malformed. For HTTP, the response
412+
* status code MUST be `400 Bad Request`.
413+
*
414+
* @example Header mismatch
415+
* {@includeCode ./examples/HeaderMismatchError/header-mismatch.json}
416+
*
417+
* @category Errors
418+
*/
419+
export interface HeaderMismatchError extends Omit<
420+
JSONRPCErrorResponse,
421+
"error"
422+
> {
423+
error: Error & {
424+
code: typeof HEADER_MISMATCH;
425+
};
426+
}
427+
376428
/**
377429
* Returned when the request's protocol version is unknown to the server or
378430
* unsupported (e.g., a known experimental or draft version the server has
@@ -529,9 +581,9 @@ export interface CancelledNotificationParams extends NotificationParams {
529581
/**
530582
* The ID of the request to cancel.
531583
*
532-
* This MUST correspond to the ID of a request previously issued in the same direction.
584+
* This MUST correspond to the ID of a request the client previously issued.
533585
*/
534-
requestId?: RequestId;
586+
requestId: RequestId;
535587

536588
/**
537589
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
@@ -540,7 +592,9 @@ export interface CancelledNotificationParams extends NotificationParams {
540592
}
541593

542594
/**
543-
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
595+
* This notification is sent by the client to indicate that it is cancelling a request it previously issued.
596+
*
597+
* On stdio, the server also sends this notification, solely to terminate a {@link SubscriptionsListenRequest | subscriptions/listen} stream: it references the ID of the `subscriptions/listen` request that opened the stream. Servers MUST NOT use this notification to cancel any other request.
544598
*
545599
* The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
546600
*
@@ -1007,11 +1061,13 @@ export interface CacheableResult extends Result {
10071061
* Indicates the intended scope of the cached response, analogous to HTTP
10081062
* `Cache-Control: public` vs `Cache-Control: private`.
10091063
*
1010-
* - `"public"`: Any client or intermediary (e.g., shared gateway, proxy)
1011-
* MAY cache the response and serve it to any user.
1012-
* - `"private"`: Only the requesting user's client MAY cache the response.
1013-
* Shared caches (e.g., multi-tenant gateways) MUST NOT serve a cached
1014-
* copy to a different user.
1064+
* - `"public"`: The response does not contain user-specific data. Any
1065+
* client or intermediary (e.g., shared gateway, caching proxy) MAY cache
1066+
* the response and serve it across authorization contexts.
1067+
* - `"private"`: The response MAY be cached and reused only within the
1068+
* same authorization context. Caches MUST NOT be shared across
1069+
* authorization contexts (e.g., a different access token requires a
1070+
* different cache).
10151071
*
10161072
*/
10171073
cacheScope: "public" | "private";
@@ -1154,7 +1210,7 @@ export interface ReadResourceResultResponse extends JSONRPCResultResponse {
11541210
}
11551211

11561212
/**
1157-
* An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
1213+
* An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This is only delivered on a {@link SubscriptionsListenRequest | subscriptions/listen} stream when the client requested it via the `resourcesListChanged` filter field.
11581214
*
11591215
* @example Resources list changed
11601216
* {@includeCode ./examples/ResourceListChangedNotification/resources-list-changed.json}
@@ -1598,7 +1654,7 @@ export interface EmbeddedResource {
15981654
_meta?: MetaObject;
15991655
}
16001656
/**
1601-
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
1657+
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This is only delivered on a {@link SubscriptionsListenRequest | subscriptions/listen} stream when the client requested it via the `promptsListChanged` filter field.
16021658
*
16031659
* @example Prompts list changed
16041660
* {@includeCode ./examples/PromptListChangedNotification/prompts-list-changed.json}
@@ -1740,7 +1796,7 @@ export interface CallToolRequest extends JSONRPCRequest {
17401796
}
17411797

17421798
/**
1743-
* An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
1799+
* An optional notification from the server to the client, informing it that the list of tools it offers has changed. This is only delivered on a {@link SubscriptionsListenRequest | subscriptions/listen} stream when the client requested it via the `toolsListChanged` filter field.
17441800
*
17451801
* @example Tools list changed
17461802
* {@includeCode ./examples/ToolListChangedNotification/tools-list-changed.json}
@@ -1842,6 +1898,11 @@ export interface Tool extends BaseMetadata, Icons {
18421898
* (`if`/`then`/`else`), reference keywords (`$ref`, `$defs`, `$anchor`), and any other
18431899
* standard validation or annotation keywords.
18441900
*
1901+
* Property schemas may carry an `x-mcp-header` annotation to mirror the
1902+
* argument value into an HTTP header on the Streamable HTTP transport. See
1903+
* the Streamable HTTP transport specification for the validity and
1904+
* extraction rules.
1905+
*
18451906
* Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
18461907
*/
18471908
inputSchema: { $schema?: string; type: "object"; [key: string]: unknown };
@@ -2571,7 +2632,9 @@ export interface PromptReference extends BaseMetadata {
25712632
*/
25722633
export interface ListRootsRequest {
25732634
method: "roots/list";
2574-
params?: RequestParams;
2635+
params?: {
2636+
_meta?: MetaObject;
2637+
};
25752638
}
25762639

25772640
/**
@@ -2681,12 +2744,6 @@ export interface ElicitRequestURLParams {
26812744
*/
26822745
message: string;
26832746

2684-
/**
2685-
* The ID of the elicitation, which must be unique within the context of the server.
2686-
* The client MUST treat this ID as an opaque value.
2687-
*/
2688-
elicitationId: string;
2689-
26902747
/**
26912748
* The URL that the user should navigate to.
26922749
*
@@ -3014,31 +3071,6 @@ export interface ElicitResult {
30143071
content?: { [key: string]: string | number | boolean | string[] };
30153072
}
30163073

3017-
/**
3018-
* Parameters for a {@link ElicitationCompleteNotification | notifications/elicitation/complete} notification.
3019-
*
3020-
* @category `notifications/elicitation/complete`
3021-
*/
3022-
export interface ElicitationCompleteNotificationParams extends NotificationParams {
3023-
/**
3024-
* The ID of the elicitation that completed.
3025-
*/
3026-
elicitationId: string;
3027-
}
3028-
3029-
/**
3030-
* An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request.
3031-
*
3032-
* @example Elicitation complete
3033-
* {@includeCode ./examples/ElicitationCompleteNotification/elicitation-complete.json}
3034-
*
3035-
* @category `notifications/elicitation/complete`
3036-
*/
3037-
export interface ElicitationCompleteNotification extends JSONRPCNotification {
3038-
method: "notifications/elicitation/complete";
3039-
params: ElicitationCompleteNotificationParams;
3040-
}
3041-
30423074
/* Client messages */
30433075
/** @internal */
30443076
export type ClientRequest =
@@ -3054,7 +3086,7 @@ export type ClientRequest =
30543086
| ListToolsRequest;
30553087

30563088
/** @internal */
3057-
export type ClientNotification = CancelledNotification | ProgressNotification;
3089+
export type ClientNotification = CancelledNotification;
30583090

30593091
/** @internal */
30603092
export type ClientResult = EmptyResult;
@@ -3070,7 +3102,6 @@ export type ServerNotification =
30703102
| ResourceListChangedNotification
30713103
| ToolListChangedNotification
30723104
| PromptListChangedNotification
3073-
| ElicitationCompleteNotification
30743105
| SubscriptionsAcknowledgedNotification;
30753106

30763107
/** @internal */

0 commit comments

Comments
 (0)