Skip to content

Commit d632389

Browse files
fix(SEP-2322): Explicitly support extending ResultType (modelcontextprotocol#2773)
* SEP-2322: Explicitly support extending ResultType * fix(SEP-2322): Break resultType extension requirement into two clauses Co-authored-by: Caitie McCaffrey <caitiem20@github.com> * fix(SEP-2322): Fix typos and format * fix(SEP-2322): Regenerate files --------- Co-authored-by: Caitie McCaffrey <caitiem20@github.com>
1 parent 7d372f2 commit d632389

8 files changed

Lines changed: 62 additions & 50 deletions

File tree

docs/seps/2322-MRTR.mdx

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/seps/2663-tasks-extension.mdx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/specification/draft/basic/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ can use to determine how to parse and handle the `result` object.
7979

8080
- A `resultType` of `"complete"` indicates the request completed successfully and the result contains the final content.
8181
- A `resultType` of `"input_required"` indicates the request is incomplete and more information is needed to process the request. The result contains an `InputRequiredResult` object with additional information needed.
82+
- Extensions **MAY** add additional `ResultType` values. The set of supported `ResultType` values **MUST** be created from the set defined in the core protocol and include any additional values of supported extensions that are advertised via capabilities.
83+
- A `resultType` of any value unrecognized by the client **MUST** be considered invalid.
8284
- For backward compatibility with servers implementing earlier protocol versions, which do not include `resultType`, clients **MUST** treat an absent `resultType` as `"complete"`.
8385

8486
#### Error Responses

docs/specification/draft/schema.mdx

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/draft/schema.json

Lines changed: 26 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/draft/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export interface Notification {
166166
* input_required - the request requires additional input and the result contains an {@link InputRequiredResult} object with instructions for the client to provide additional input before retrying the original request.
167167
* @category Common Types
168168
*/
169-
export type ResultType = "complete" | "input_required";
169+
export type ResultType = "complete" | "input_required" | string;
170170

171171
/**
172172
* Common result fields.

seps/2322-MRTR.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,13 @@ export interface InputResponseRequestParams extends RequestParams {
320320
}
321321
```
322322

323-
Since this change creates a polymorphic response for method calls like 'tools/call', we are introducing a new field to `Result` which indicate the `ResultType`. The client should parse this field to determine the type of the Result contained in the message. If this field is not provided the Client should assume a `ResultType` of "complete" for backwards compatibility. The schema change will look like this:
323+
Since this change creates a polymorphic response for method calls like `tools/call`, we are introducing a new field to `Result` which indicate the `ResultType`. The client should parse this field to determine the type of the `Result` contained in the message. If this field is not provided, the Client should assume a `ResultType` of `"complete"` for backwards compatibility.
324+
325+
Extensions **MAY** add additional `ResultType` values. The set of supported `ResultType` values **MUST** be created from the set defined in the core protocol and include any additional values of supported extensions that are advertised via capabilities.
326+
327+
The Client **SHOULD** treat unrecognized values as invalid protocol responses.
328+
329+
The schema change will look like this:
324330

325331
```typescript
326332
/**
@@ -337,7 +343,8 @@ export interface Result {
337343

338344
export type ResultType =
339345
| "complete" // the request completed successfully and the result contains the final content.
340-
| "input_required"; // the request is incomplete and the result contains an {@link InputRequiredResult} object
346+
| "input_required" // the request is incomplete and the result contains an {@link InputRequiredResult} object
347+
| string; // open to extensions
341348
```
342349

343350
We anticipate this field will be useful for future extensibility, as it allows us to introduce new types of results and can also apply to `tasks` as well.

seps/2663-tasks-extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ A request that is eligible for task-augmentation may return one of two distinct
122122

123123
```typescript
124124
// "task" is introduced by this extension.
125-
type ResultType = "complete" | "input_required" | "task";
125+
type ResultType = "complete" | "input_required" | "task" | string;
126126
```
127127

128128
Servers **MUST** set `resultType` to `"task"` when returning a `CreateTaskResult` so that clients can distinguish it from a standard result. Servers **MUST NOT** set `resultType` to `"task"` on result types other than `CreateTaskResult`.

0 commit comments

Comments
 (0)