-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SEP-1319: Decouple Request Payloads, Remove passthrough iteration, Typecheck fixes #1086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
78e42d0
4b8cb77
48d2945
9dd7888
a8f6279
7d97155
9c1ce81
adf9655
bd02632
83cdbcc
1b373c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,8 +177,7 @@ mcpServer.registerTool( | |
| startTime: { | ||
| type: 'string', | ||
| title: 'Start Time', | ||
| description: 'Event start time (HH:MM)', | ||
| pattern: '^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pattern could be left here, but needs ts-ignore, as not supported by the spec. We could allow it on an optional basis and still match the spec if we wanted. |
||
| description: 'Event start time (HH:MM)' | ||
| }, | ||
| duration: { | ||
| type: 'integer', | ||
|
|
@@ -268,8 +267,7 @@ mcpServer.registerTool( | |
| zipCode: { | ||
| type: 'string', | ||
| title: 'ZIP/Postal Code', | ||
| description: '5-digit ZIP code', | ||
| pattern: '^[0-9]{5}$' | ||
| description: '5-digit ZIP code' | ||
| }, | ||
| phone: { | ||
| type: 'string', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,7 +151,7 @@ describe('Transport resumability', () => { | |
|
|
||
| // Create first client | ||
| const client1 = new Client({ | ||
| id: clientId, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No such property. |
||
| title: clientId, | ||
| name: 'test-client', | ||
| version: '1.0.0' | ||
| }); | ||
|
|
@@ -223,7 +223,7 @@ describe('Transport resumability', () => { | |
|
|
||
| // Create second client with same client ID | ||
| const client2 = new Client({ | ||
| id: clientId, | ||
| title: clientId, | ||
| name: 'test-client', | ||
| version: '1.0.0' | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,6 +176,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo | |
| age: { type: 'integer', minimum: 0, maximum: 150 }, | ||
| street: { type: 'string' }, | ||
| city: { type: 'string' }, | ||
| // @ts-expect-error - pattern is not a valid property by MCP spec, however it is making use of the Ajv validator | ||
| zipCode: { type: 'string', pattern: '^[0-9]{5}$' }, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Patterns not supported by the spec. Passing them will work, but the TS error needs ignoring. |
||
| newsletter: { type: 'boolean' }, | ||
| notifications: { type: 'boolean' } | ||
|
|
@@ -355,6 +356,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo | |
| requestedSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| // @ts-expect-error - pattern is not a valid property by MCP spec, however it is making use of the Ajv validator | ||
| zipCode: { type: 'string', pattern: '^[0-9]{5}$' } | ||
| }, | ||
| required: ['zipCode'] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,9 +237,9 @@ export class Server< | |
|
|
||
| protected assertRequestHandlerCapability(method: string): void { | ||
| switch (method) { | ||
| case 'sampling/createMessage': | ||
| if (!this._capabilities.sampling) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Servers do not have sampling capabilities, thus removed. Swapped with completions capabilities. |
||
| throw new Error(`Server does not support sampling (required for ${method})`); | ||
| case 'completion/complete': | ||
| if (!this._capabilities.completions) { | ||
| throw new Error(`Server does not support completions (required for ${method})`); | ||
| } | ||
| break; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ import { | |
| CallToolResult, | ||
| McpError, | ||
| ErrorCode, | ||
| CompleteRequest, | ||
| CompleteResult, | ||
| PromptReference, | ||
| ResourceTemplateReference, | ||
|
|
@@ -31,7 +30,11 @@ import { | |
| ServerRequest, | ||
| ServerNotification, | ||
| ToolAnnotations, | ||
| LoggingMessageNotification | ||
| LoggingMessageNotification, | ||
| CompleteRequestPrompt, | ||
| CompleteRequestResourceTemplate, | ||
| assertCompleteRequestPrompt, | ||
| assertCompleteRequestResourceTemplate | ||
| } from '../types.js'; | ||
| import { Completable, CompletableDef } from './completable.js'; | ||
| import { UriTemplate, Variables } from '../shared/uriTemplate.js'; | ||
|
|
@@ -217,9 +220,11 @@ export class McpServer { | |
| this.server.setRequestHandler(CompleteRequestSchema, async (request): Promise<CompleteResult> => { | ||
| switch (request.params.ref.type) { | ||
| case 'ref/prompt': | ||
| assertCompleteRequestPrompt(request); | ||
| return this.handlePromptCompletion(request, request.params.ref); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When passthrough removed, assertions are needed to proceed with a narrowed type to alleviate type errors downstream. |
||
|
|
||
| case 'ref/resource': | ||
| assertCompleteRequestResourceTemplate(request); | ||
| return this.handleResourceCompletion(request, request.params.ref); | ||
|
|
||
| default: | ||
|
|
@@ -230,7 +235,7 @@ export class McpServer { | |
| this._completionHandlerInitialized = true; | ||
| } | ||
|
|
||
| private async handlePromptCompletion(request: CompleteRequest, ref: PromptReference): Promise<CompleteResult> { | ||
| private async handlePromptCompletion(request: CompleteRequestPrompt, ref: PromptReference): Promise<CompleteResult> { | ||
| const prompt = this._registeredPrompts[ref.name]; | ||
| if (!prompt) { | ||
| throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`); | ||
|
|
@@ -254,7 +259,7 @@ export class McpServer { | |
| return createCompletionResult(suggestions); | ||
| } | ||
|
|
||
| private async handleResourceCompletion(request: CompleteRequest, ref: ResourceTemplateReference): Promise<CompleteResult> { | ||
| private async handleResourceCompletion(request: CompleteRequestResourceTemplate, ref: ResourceTemplateReference): Promise<CompleteResult> { | ||
| const template = Object.values(this._registeredResourceTemplates).find(t => t.resourceTemplate.uriTemplate.toString() === ref.uri); | ||
|
|
||
| if (!template) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property doesn't exist.