SEP-1319: Decouple Request Payloads, Remove passthrough iteration, Typecheck fixes (#1086)

This commit is contained in:
Konstantin Konstantinov 2025-11-07 18:50:20 +02:00 • committed by GitHub
commit f59996ae66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 2840 additions and 951 deletions

View file

@ -15,6 +15,9 @@ export default tseslint.config(
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
}
},
{
ignores: ['src/spec.types.ts']
},
{
files: ['src/client/**/*.ts', 'src/server/**/*.ts'],
ignores: ['**/*.test.ts'],

1578
spec.types.ts Normal file

File diff suppressed because it is too large Load diff

View file

@ -217,8 +217,7 @@ test('should connect new client to old, supported server version', async () => {
const client = new Client(
{
name: 'new client',
version: '1.0',
protocolVersion: LATEST_PROTOCOL_VERSION
version: '1.0'
},
{
capabilities: {
@ -279,8 +278,7 @@ test('should negotiate version when client is old, and newer server supports its
const client = new Client(
{
name: 'old client',
version: '1.0',
protocolVersion: OLD_VERSION
version: '1.0'
},
{
capabilities: {
@ -342,8 +340,7 @@ test("should throw when client is old, and server doesn't support its version",
const client = new Client(
{
name: 'old client',
version: '1.0',
protocolVersion: OLD_VERSION
version: '1.0'
},
{
capabilities: {

View file

@ -703,7 +703,7 @@ async function getPrompt(name: string, args: Record<string, unknown>): Promise<v
const promptResult = await client.request(promptRequest, GetPromptResultSchema);
console.log('Prompt template:');
promptResult.messages.forEach((msg, index) => {
console.log(` [${index + 1}] ${msg.role}: ${msg.content.text}`);
console.log(` [${index + 1}] ${msg.role}: ${msg.content.type === 'text' ? msg.content.text : JSON.stringify(msg.content)}`);
});
} catch (error) {
console.log(`Error getting prompt ${name}: ${error}`);

View file

@ -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]$'
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',

View file

@ -145,13 +145,13 @@ describe('Transport resumability', () => {
// across client disconnection/reconnection
it('should resume long-running notifications with lastEventId', async () => {
// Create unique client ID for this test
const clientId = 'test-client-long-running';
const clientTitle = 'test-client-long-running';
const notifications = [];
let lastEventId: string | undefined;
// Create first client
const client1 = new Client({
id: clientId,
title: clientTitle,
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: clientTitle,
name: 'test-client',
version: '1.0.0'
});

View file

@ -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}$' },
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']

View file

@ -702,9 +702,7 @@ test('should handle server cancelling a request', async () => {
version: '1.0'
},
{
capabilities: {
sampling: {}
}
capabilities: {}
}
);
@ -763,9 +761,7 @@ test('should handle request timeout', async () => {
version: '1.0'
},
{
capabilities: {
sampling: {}
}
capabilities: {}
}
);

View file

@ -237,9 +237,9 @@ export class Server<
protected assertRequestHandlerCapability(method: string): void {
switch (method) {
case 'sampling/createMessage':
if (!this._capabilities.sampling) {
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;

View file

@ -1407,7 +1407,14 @@ describe('tool()', () => {
expect(receivedRequestId).toBeDefined();
expect(typeof receivedRequestId === 'string' || typeof receivedRequestId === 'number').toBe(true);
expect(result.content?.[0].text).toContain('Received request ID:');
expect(result.content).toEqual(
expect.arrayContaining([
{
type: 'text',
text: expect.stringContaining('Received request ID:')
}
])
);
});
/***
@ -1781,7 +1788,14 @@ describe('resource()', () => {
);
expect(result.contents).toHaveLength(1);
expect(result.contents[0].text).toBe('Updated content');
expect(result.contents).toEqual(
expect.arrayContaining([
{
text: expect.stringContaining('Updated content'),
uri: 'test://resource'
}
])
);
// Update happened before transport was connected, so no notifications should be expected
expect(notifications).toHaveLength(0);
@ -1846,7 +1860,14 @@ describe('resource()', () => {
);
expect(result.contents).toHaveLength(1);
expect(result.contents[0].text).toBe('Updated content');
expect(result.contents).toEqual(
expect.arrayContaining([
{
text: expect.stringContaining('Updated content'),
uri: 'test://resource/123'
}
])
);
// Update happened before transport was connected, so no notifications should be expected
expect(notifications).toHaveLength(0);
@ -2195,7 +2216,14 @@ describe('resource()', () => {
ReadResourceResultSchema
);
expect(result.contents[0].text).toBe('Category: books, ID: 123');
expect(result.contents).toEqual(
expect.arrayContaining([
{
text: expect.stringContaining('Category: books, ID: 123'),
uri: 'test://resource/books/123'
}
])
);
});
/***
@ -2556,7 +2584,14 @@ describe('resource()', () => {
expect(receivedRequestId).toBeDefined();
expect(typeof receivedRequestId === 'string' || typeof receivedRequestId === 'number').toBe(true);
expect(result.contents[0].text).toContain('Received request ID:');
expect(result.contents).toEqual(
expect.arrayContaining([
{
text: expect.stringContaining(`Received request ID:`),
uri: 'test://resource'
}
])
);
});
});
@ -2662,7 +2697,17 @@ describe('prompt()', () => {
);
expect(result.messages).toHaveLength(1);
expect(result.messages[0].content.text).toBe('Updated response');
expect(result.messages).toEqual(
expect.arrayContaining([
{
role: 'assistant',
content: {
type: 'text',
text: 'Updated response'
}
}
])
);
// Update happened before transport was connected, so no notifications should be expected
expect(notifications).toHaveLength(0);
@ -2754,7 +2799,17 @@ describe('prompt()', () => {
);
expect(getResult.messages).toHaveLength(1);
expect(getResult.messages[0].content.text).toBe('Updated: test, value');
expect(getResult.messages).toEqual(
expect.arrayContaining([
{
role: 'assistant',
content: {
type: 'text',
text: 'Updated: test, value'
}
}
])
);
// Update happened before transport was connected, so no notifications should be expected
expect(notifications).toHaveLength(0);
@ -3411,7 +3466,17 @@ describe('prompt()', () => {
expect(receivedRequestId).toBeDefined();
expect(typeof receivedRequestId === 'string' || typeof receivedRequestId === 'number').toBe(true);
expect(result.messages[0].content.text).toContain('Received request ID:');
expect(result.messages).toEqual(
expect.arrayContaining([
{
role: 'assistant',
content: {
type: 'text',
text: expect.stringContaining(`Received request ID:`)
}
}
])
);
});
/***
@ -3513,7 +3578,7 @@ describe('prompt()', () => {
})
}),
{
name: 'Template Name',
title: 'Template Name',
description: 'Template description',
mimeType: 'application/json'
},

View file

@ -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);
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,10 @@ 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) {

View file

@ -189,7 +189,14 @@ describe('Title field backwards compatibility', () => {
// Test reading the resource
const readResult = await client.readResource({ uri: 'users://123/profile' });
expect(readResult.contents).toHaveLength(1);
expect(readResult.contents[0].text).toBe('Profile data for user 123');
expect(readResult.contents).toEqual(
expect.arrayContaining([
{
text: expect.stringContaining('Profile data for user 123'),
uri: 'users://123/profile'
}
])
);
});
it('should support serverInfo with title', async () => {

View file

@ -10,18 +10,15 @@ import { BaseMetadata } from '../types.js';
* For other objects: title → name
* This implements the spec requirement: "if no title is provided, name should be used for display purposes"
*/
export function getDisplayName(metadata: BaseMetadata): string {
export function getDisplayName(metadata: BaseMetadata & { annotations?: { title?: string } }): string {
// First check for title (not undefined and not empty string)
if (metadata.title !== undefined && metadata.title !== '') {
return metadata.title;
}
// Then check for annotations.title (only present in Tool objects)
if ('annotations' in metadata) {
const metadataWithAnnotations = metadata as BaseMetadata & { annotations?: { title?: string } };
if (metadataWithAnnotations.annotations?.title) {
return metadataWithAnnotations.annotations.title;
}
if (metadata.annotations?.title) {
return metadata.annotations.title;
}
// Finally fall back to name

View file

@ -666,11 +666,13 @@ describe('mergeCapabilities', () => {
const additional: ClientCapabilities = {
experimental: {
feature: true
feature: {
featureFlag: true
}
},
elicitation: {},
roots: {
newProp: true
listChanged: true
}
};
@ -679,11 +681,12 @@ describe('mergeCapabilities', () => {
sampling: {},
elicitation: {},
roots: {
listChanged: true,
newProp: true
listChanged: true
},
experimental: {
feature: true
feature: {
featureFlag: true
}
}
});
});
@ -701,7 +704,7 @@ describe('mergeCapabilities', () => {
subscribe: true
},
prompts: {
newProp: true
listChanged: true
}
};
@ -709,8 +712,7 @@ describe('mergeCapabilities', () => {
expect(merged).toEqual({
logging: {},
prompts: {
listChanged: true,
newProp: true
listChanged: true
},
resources: {
subscribe: true

View file

@ -693,16 +693,24 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
}
}
export function mergeCapabilities<T extends ServerCapabilities | ClientCapabilities>(base: T, additional: T): T {
return Object.entries(additional).reduce(
(acc, [key, value]) => {
if (value && typeof value === 'object') {
acc[key] = acc[key] ? { ...acc[key], ...value } : value;
} else {
acc[key] = value;
}
return acc;
},
{ ...base }
);
function isPlainObject(value: unknown): value is Record<string, unknown> {
return value !== null && typeof value === 'object' && !Array.isArray(value);
}
export function mergeCapabilities(base: ServerCapabilities, additional: Partial<ServerCapabilities>): ServerCapabilities;
export function mergeCapabilities(base: ClientCapabilities, additional: Partial<ClientCapabilities>): ClientCapabilities;
export function mergeCapabilities<T extends ServerCapabilities | ClientCapabilities>(base: T, additional: Partial<T>): T {
const result: T = { ...base };
for (const key in additional) {
const k = key as keyof T;
const addValue = additional[k];
if (addValue === undefined) continue;
const baseValue = result[k];
if (isPlainObject(baseValue) && isPlainObject(addValue)) {
result[k] = { ...(baseValue as Record<string, unknown>), ...(addValue as Record<string, unknown>) } as T[typeof k];
} else {
result[k] = addValue as T[typeof k];
}
}
return result;
}

View file

@ -71,7 +71,7 @@ export interface Transport {
*
* The requestInfo can be used to get the original request information (headers, etc.)
*/
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
onmessage?: <T extends JSONRPCMessage>(message: T, extra?: MessageExtraInfo) => void;
/**
* The session ID generated for this connection.

View file

@ -63,15 +63,93 @@ type MakeUnknownsNotOptional<T> =
: T;
const sdkTypeChecks = {
CancelledNotification: (sdk: RemovePassthrough<WithJSONRPC<SDKTypes.CancelledNotification>>, spec: SpecTypes.CancelledNotification) => {
RequestParams: (sdk: SDKTypes.RequestParams, spec: SpecTypes.RequestParams) => {
sdk = spec;
spec = sdk;
},
BaseMetadata: (sdk: RemovePassthrough<SDKTypes.BaseMetadata>, spec: SpecTypes.BaseMetadata) => {
NotificationParams: (sdk: SDKTypes.NotificationParams, spec: SpecTypes.NotificationParams) => {
sdk = spec;
spec = sdk;
},
Implementation: (sdk: RemovePassthrough<SDKTypes.Implementation>, spec: SpecTypes.Implementation) => {
CancelledNotificationParams: (sdk: SDKTypes.CancelledNotificationParams, spec: SpecTypes.CancelledNotificationParams) => {
sdk = spec;
spec = sdk;
},
InitializeRequestParams: (sdk: SDKTypes.InitializeRequestParams, spec: SpecTypes.InitializeRequestParams) => {
sdk = spec;
spec = sdk;
},
ProgressNotificationParams: (sdk: SDKTypes.ProgressNotificationParams, spec: SpecTypes.ProgressNotificationParams) => {
sdk = spec;
spec = sdk;
},
ResourceRequestParams: (sdk: SDKTypes.ResourceRequestParams, spec: SpecTypes.ResourceRequestParams) => {
sdk = spec;
spec = sdk;
},
ReadResourceRequestParams: (sdk: SDKTypes.ReadResourceRequestParams, spec: SpecTypes.ReadResourceRequestParams) => {
sdk = spec;
spec = sdk;
},
SubscribeRequestParams: (sdk: SDKTypes.SubscribeRequestParams, spec: SpecTypes.SubscribeRequestParams) => {
sdk = spec;
spec = sdk;
},
UnsubscribeRequestParams: (sdk: SDKTypes.UnsubscribeRequestParams, spec: SpecTypes.UnsubscribeRequestParams) => {
sdk = spec;
spec = sdk;
},
ResourceUpdatedNotificationParams: (
sdk: SDKTypes.ResourceUpdatedNotificationParams,
spec: SpecTypes.ResourceUpdatedNotificationParams
) => {
sdk = spec;
spec = sdk;
},
GetPromptRequestParams: (sdk: SDKTypes.GetPromptRequestParams, spec: SpecTypes.GetPromptRequestParams) => {
sdk = spec;
spec = sdk;
},
CallToolRequestParams: (sdk: SDKTypes.CallToolRequestParams, spec: SpecTypes.CallToolRequestParams) => {
sdk = spec;
spec = sdk;
},
SetLevelRequestParams: (sdk: SDKTypes.SetLevelRequestParams, spec: SpecTypes.SetLevelRequestParams) => {
sdk = spec;
spec = sdk;
},
LoggingMessageNotificationParams: (
sdk: MakeUnknownsNotOptional<SDKTypes.LoggingMessageNotificationParams>,
spec: SpecTypes.LoggingMessageNotificationParams
) => {
sdk = spec;
spec = sdk;
},
CreateMessageRequestParams: (sdk: SDKTypes.CreateMessageRequestParams, spec: SpecTypes.CreateMessageRequestParams) => {
sdk = spec;
spec = sdk;
},
CompleteRequestParams: (sdk: SDKTypes.CompleteRequestParams, spec: SpecTypes.CompleteRequestParams) => {
sdk = spec;
spec = sdk;
},
ElicitRequestParams: (sdk: SDKTypes.ElicitRequestParams, spec: SpecTypes.ElicitRequestParams) => {
sdk = spec;
spec = sdk;
},
PaginatedRequestParams: (sdk: SDKTypes.PaginatedRequestParams, spec: SpecTypes.PaginatedRequestParams) => {
sdk = spec;
spec = sdk;
},
CancelledNotification: (sdk: WithJSONRPC<SDKTypes.CancelledNotification>, spec: SpecTypes.CancelledNotification) => {
sdk = spec;
spec = sdk;
},
BaseMetadata: (sdk: SDKTypes.BaseMetadata, spec: SpecTypes.BaseMetadata) => {
sdk = spec;
spec = sdk;
},
Implementation: (sdk: SDKTypes.Implementation, spec: SpecTypes.Implementation) => {
sdk = spec;
spec = sdk;
},
@ -99,23 +177,23 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
ListRootsResult: (sdk: RemovePassthrough<SDKTypes.ListRootsResult>, spec: SpecTypes.ListRootsResult) => {
ListRootsResult: (sdk: SDKTypes.ListRootsResult, spec: SpecTypes.ListRootsResult) => {
sdk = spec;
spec = sdk;
},
Root: (sdk: RemovePassthrough<SDKTypes.Root>, spec: SpecTypes.Root) => {
Root: (sdk: SDKTypes.Root, spec: SpecTypes.Root) => {
sdk = spec;
spec = sdk;
},
ElicitRequest: (sdk: WithJSONRPCRequest<RemovePassthrough<SDKTypes.ElicitRequest>>, spec: SpecTypes.ElicitRequest) => {
ElicitRequest: (sdk: WithJSONRPCRequest<SDKTypes.ElicitRequest>, spec: SpecTypes.ElicitRequest) => {
sdk = spec;
spec = sdk;
},
ElicitResult: (sdk: RemovePassthrough<SDKTypes.ElicitResult>, spec: SpecTypes.ElicitResult) => {
ElicitResult: (sdk: SDKTypes.ElicitResult, spec: SpecTypes.ElicitResult) => {
sdk = spec;
spec = sdk;
},
CompleteRequest: (sdk: WithJSONRPCRequest<RemovePassthrough<SDKTypes.CompleteRequest>>, spec: SpecTypes.CompleteRequest) => {
CompleteRequest: (sdk: WithJSONRPCRequest<SDKTypes.CompleteRequest>, spec: SpecTypes.CompleteRequest) => {
sdk = spec;
spec = sdk;
},
@ -175,19 +253,19 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
ResourceTemplateReference: (sdk: RemovePassthrough<SDKTypes.ResourceTemplateReference>, spec: SpecTypes.ResourceTemplateReference) => {
ResourceTemplateReference: (sdk: SDKTypes.ResourceTemplateReference, spec: SpecTypes.ResourceTemplateReference) => {
sdk = spec;
spec = sdk;
},
PromptReference: (sdk: RemovePassthrough<SDKTypes.PromptReference>, spec: SpecTypes.PromptReference) => {
PromptReference: (sdk: SDKTypes.PromptReference, spec: SpecTypes.PromptReference) => {
sdk = spec;
spec = sdk;
},
ToolAnnotations: (sdk: RemovePassthrough<SDKTypes.ToolAnnotations>, spec: SpecTypes.ToolAnnotations) => {
ToolAnnotations: (sdk: SDKTypes.ToolAnnotations, spec: SpecTypes.ToolAnnotations) => {
sdk = spec;
spec = sdk;
},
Tool: (sdk: RemovePassthrough<SDKTypes.Tool>, spec: SpecTypes.Tool) => {
Tool: (sdk: SDKTypes.Tool, spec: SpecTypes.Tool) => {
sdk = spec;
spec = sdk;
},
@ -195,11 +273,11 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
ListToolsResult: (sdk: RemovePassthrough<SDKTypes.ListToolsResult>, spec: SpecTypes.ListToolsResult) => {
ListToolsResult: (sdk: SDKTypes.ListToolsResult, spec: SpecTypes.ListToolsResult) => {
sdk = spec;
spec = sdk;
},
CallToolResult: (sdk: RemovePassthrough<SDKTypes.CallToolResult>, spec: SpecTypes.CallToolResult) => {
CallToolResult: (sdk: SDKTypes.CallToolResult, spec: SpecTypes.CallToolResult) => {
sdk = spec;
spec = sdk;
},
@ -242,11 +320,11 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
SamplingMessage: (sdk: RemovePassthrough<SDKTypes.SamplingMessage>, spec: SpecTypes.SamplingMessage) => {
SamplingMessage: (sdk: SDKTypes.SamplingMessage, spec: SpecTypes.SamplingMessage) => {
sdk = spec;
spec = sdk;
},
CreateMessageResult: (sdk: RemovePassthrough<SDKTypes.CreateMessageResult>, spec: SpecTypes.CreateMessageResult) => {
CreateMessageResult: (sdk: SDKTypes.CreateMessageResult, spec: SpecTypes.CreateMessageResult) => {
sdk = spec;
spec = sdk;
},
@ -272,7 +350,7 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
ListResourcesResult: (sdk: RemovePassthrough<SDKTypes.ListResourcesResult>, spec: SpecTypes.ListResourcesResult) => {
ListResourcesResult: (sdk: SDKTypes.ListResourcesResult, spec: SpecTypes.ListResourcesResult) => {
sdk = spec;
spec = sdk;
},
@ -283,10 +361,7 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
ListResourceTemplatesResult: (
sdk: RemovePassthrough<SDKTypes.ListResourceTemplatesResult>,
spec: SpecTypes.ListResourceTemplatesResult
) => {
ListResourceTemplatesResult: (sdk: SDKTypes.ListResourceTemplatesResult, spec: SpecTypes.ListResourceTemplatesResult) => {
sdk = spec;
spec = sdk;
},
@ -297,35 +372,35 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
ReadResourceResult: (sdk: RemovePassthrough<SDKTypes.ReadResourceResult>, spec: SpecTypes.ReadResourceResult) => {
ReadResourceResult: (sdk: SDKTypes.ReadResourceResult, spec: SpecTypes.ReadResourceResult) => {
sdk = spec;
spec = sdk;
},
ResourceContents: (sdk: RemovePassthrough<SDKTypes.ResourceContents>, spec: SpecTypes.ResourceContents) => {
ResourceContents: (sdk: SDKTypes.ResourceContents, spec: SpecTypes.ResourceContents) => {
sdk = spec;
spec = sdk;
},
TextResourceContents: (sdk: RemovePassthrough<SDKTypes.TextResourceContents>, spec: SpecTypes.TextResourceContents) => {
TextResourceContents: (sdk: SDKTypes.TextResourceContents, spec: SpecTypes.TextResourceContents) => {
sdk = spec;
spec = sdk;
},
BlobResourceContents: (sdk: RemovePassthrough<SDKTypes.BlobResourceContents>, spec: SpecTypes.BlobResourceContents) => {
BlobResourceContents: (sdk: SDKTypes.BlobResourceContents, spec: SpecTypes.BlobResourceContents) => {
sdk = spec;
spec = sdk;
},
Resource: (sdk: RemovePassthrough<SDKTypes.Resource>, spec: SpecTypes.Resource) => {
Resource: (sdk: SDKTypes.Resource, spec: SpecTypes.Resource) => {
sdk = spec;
spec = sdk;
},
ResourceTemplate: (sdk: RemovePassthrough<SDKTypes.ResourceTemplate>, spec: SpecTypes.ResourceTemplate) => {
ResourceTemplate: (sdk: SDKTypes.ResourceTemplate, spec: SpecTypes.ResourceTemplate) => {
sdk = spec;
spec = sdk;
},
PromptArgument: (sdk: RemovePassthrough<SDKTypes.PromptArgument>, spec: SpecTypes.PromptArgument) => {
PromptArgument: (sdk: SDKTypes.PromptArgument, spec: SpecTypes.PromptArgument) => {
sdk = spec;
spec = sdk;
},
Prompt: (sdk: RemovePassthrough<SDKTypes.Prompt>, spec: SpecTypes.Prompt) => {
Prompt: (sdk: SDKTypes.Prompt, spec: SpecTypes.Prompt) => {
sdk = spec;
spec = sdk;
},
@ -333,7 +408,7 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
ListPromptsResult: (sdk: RemovePassthrough<SDKTypes.ListPromptsResult>, spec: SpecTypes.ListPromptsResult) => {
ListPromptsResult: (sdk: SDKTypes.ListPromptsResult, spec: SpecTypes.ListPromptsResult) => {
sdk = spec;
spec = sdk;
},
@ -341,55 +416,55 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
TextContent: (sdk: RemovePassthrough<SDKTypes.TextContent>, spec: SpecTypes.TextContent) => {
TextContent: (sdk: SDKTypes.TextContent, spec: SpecTypes.TextContent) => {
sdk = spec;
spec = sdk;
},
ImageContent: (sdk: RemovePassthrough<SDKTypes.ImageContent>, spec: SpecTypes.ImageContent) => {
ImageContent: (sdk: SDKTypes.ImageContent, spec: SpecTypes.ImageContent) => {
sdk = spec;
spec = sdk;
},
AudioContent: (sdk: RemovePassthrough<SDKTypes.AudioContent>, spec: SpecTypes.AudioContent) => {
AudioContent: (sdk: SDKTypes.AudioContent, spec: SpecTypes.AudioContent) => {
sdk = spec;
spec = sdk;
},
EmbeddedResource: (sdk: RemovePassthrough<SDKTypes.EmbeddedResource>, spec: SpecTypes.EmbeddedResource) => {
EmbeddedResource: (sdk: SDKTypes.EmbeddedResource, spec: SpecTypes.EmbeddedResource) => {
sdk = spec;
spec = sdk;
},
ResourceLink: (sdk: RemovePassthrough<SDKTypes.ResourceLink>, spec: SpecTypes.ResourceLink) => {
ResourceLink: (sdk: SDKTypes.ResourceLink, spec: SpecTypes.ResourceLink) => {
sdk = spec;
spec = sdk;
},
ContentBlock: (sdk: RemovePassthrough<SDKTypes.ContentBlock>, spec: SpecTypes.ContentBlock) => {
ContentBlock: (sdk: SDKTypes.ContentBlock, spec: SpecTypes.ContentBlock) => {
sdk = spec;
spec = sdk;
},
PromptMessage: (sdk: RemovePassthrough<SDKTypes.PromptMessage>, spec: SpecTypes.PromptMessage) => {
PromptMessage: (sdk: SDKTypes.PromptMessage, spec: SpecTypes.PromptMessage) => {
sdk = spec;
spec = sdk;
},
GetPromptResult: (sdk: RemovePassthrough<SDKTypes.GetPromptResult>, spec: SpecTypes.GetPromptResult) => {
GetPromptResult: (sdk: SDKTypes.GetPromptResult, spec: SpecTypes.GetPromptResult) => {
sdk = spec;
spec = sdk;
},
BooleanSchema: (sdk: RemovePassthrough<SDKTypes.BooleanSchema>, spec: SpecTypes.BooleanSchema) => {
BooleanSchema: (sdk: SDKTypes.BooleanSchema, spec: SpecTypes.BooleanSchema) => {
sdk = spec;
spec = sdk;
},
StringSchema: (sdk: RemovePassthrough<SDKTypes.StringSchema>, spec: SpecTypes.StringSchema) => {
StringSchema: (sdk: SDKTypes.StringSchema, spec: SpecTypes.StringSchema) => {
sdk = spec;
spec = sdk;
},
NumberSchema: (sdk: RemovePassthrough<SDKTypes.NumberSchema>, spec: SpecTypes.NumberSchema) => {
NumberSchema: (sdk: SDKTypes.NumberSchema, spec: SpecTypes.NumberSchema) => {
sdk = spec;
spec = sdk;
},
EnumSchema: (sdk: RemovePassthrough<SDKTypes.EnumSchema>, spec: SpecTypes.EnumSchema) => {
EnumSchema: (sdk: SDKTypes.EnumSchema, spec: SpecTypes.EnumSchema) => {
sdk = spec;
spec = sdk;
},
PrimitiveSchemaDefinition: (sdk: RemovePassthrough<SDKTypes.PrimitiveSchemaDefinition>, spec: SpecTypes.PrimitiveSchemaDefinition) => {
PrimitiveSchemaDefinition: (sdk: SDKTypes.PrimitiveSchemaDefinition, spec: SpecTypes.PrimitiveSchemaDefinition) => {
sdk = spec;
spec = sdk;
},
@ -401,34 +476,31 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
CreateMessageRequest: (
sdk: WithJSONRPCRequest<RemovePassthrough<SDKTypes.CreateMessageRequest>>,
spec: SpecTypes.CreateMessageRequest
) => {
CreateMessageRequest: (sdk: WithJSONRPCRequest<SDKTypes.CreateMessageRequest>, spec: SpecTypes.CreateMessageRequest) => {
sdk = spec;
spec = sdk;
},
InitializeRequest: (sdk: WithJSONRPCRequest<RemovePassthrough<SDKTypes.InitializeRequest>>, spec: SpecTypes.InitializeRequest) => {
InitializeRequest: (sdk: WithJSONRPCRequest<SDKTypes.InitializeRequest>, spec: SpecTypes.InitializeRequest) => {
sdk = spec;
spec = sdk;
},
InitializeResult: (sdk: RemovePassthrough<SDKTypes.InitializeResult>, spec: SpecTypes.InitializeResult) => {
InitializeResult: (sdk: SDKTypes.InitializeResult, spec: SpecTypes.InitializeResult) => {
sdk = spec;
spec = sdk;
},
ClientCapabilities: (sdk: RemovePassthrough<SDKTypes.ClientCapabilities>, spec: SpecTypes.ClientCapabilities) => {
ClientCapabilities: (sdk: SDKTypes.ClientCapabilities, spec: SpecTypes.ClientCapabilities) => {
sdk = spec;
spec = sdk;
},
ServerCapabilities: (sdk: RemovePassthrough<SDKTypes.ServerCapabilities>, spec: SpecTypes.ServerCapabilities) => {
ServerCapabilities: (sdk: SDKTypes.ServerCapabilities, spec: SpecTypes.ServerCapabilities) => {
sdk = spec;
spec = sdk;
},
ClientRequest: (sdk: WithJSONRPCRequest<RemovePassthrough<SDKTypes.ClientRequest>>, spec: SpecTypes.ClientRequest) => {
ClientRequest: (sdk: RemovePassthrough<WithJSONRPCRequest<SDKTypes.ClientRequest>>, spec: SpecTypes.ClientRequest) => {
sdk = spec;
spec = sdk;
},
ServerRequest: (sdk: WithJSONRPCRequest<RemovePassthrough<SDKTypes.ServerRequest>>, spec: SpecTypes.ServerRequest) => {
ServerRequest: (sdk: RemovePassthrough<WithJSONRPCRequest<SDKTypes.ServerRequest>>, spec: SpecTypes.ServerRequest) => {
sdk = spec;
spec = sdk;
},
@ -440,7 +512,7 @@ const sdkTypeChecks = {
spec = sdk;
},
ServerNotification: (
sdk: RemovePassthrough<MakeUnknownsNotOptional<WithJSONRPC<SDKTypes.ServerNotification>>>,
sdk: MakeUnknownsNotOptional<RemovePassthrough<WithJSONRPC<SDKTypes.ServerNotification>>>,
spec: SpecTypes.ServerNotification
) => {
sdk = spec;
@ -450,11 +522,19 @@ const sdkTypeChecks = {
sdk = spec;
spec = sdk;
},
Icon: (sdk: RemovePassthrough<SDKTypes.Icon>, spec: SpecTypes.Icon) => {
Icon: (sdk: SDKTypes.Icon, spec: SpecTypes.Icon) => {
sdk = spec;
spec = sdk;
},
Icons: (sdk: RemovePassthrough<SDKTypes.Icons>, spec: SpecTypes.Icons) => {
Icons: (sdk: SDKTypes.Icons, spec: SpecTypes.Icons) => {
sdk = spec;
spec = sdk;
},
ModelHint: (sdk: SDKTypes.ModelHint, spec: SpecTypes.ModelHint) => {
sdk = spec;
spec = sdk;
},
ModelPreferences: (sdk: SDKTypes.ModelPreferences, spec: SpecTypes.ModelPreferences) => {
sdk = spec;
spec = sdk;
}
@ -468,32 +548,9 @@ const MISSING_SDK_TYPES = [
// These are inlined in the SDK:
'Role',
'Error', // The inner error object of a JSONRPCError
// Params types are not exported as standalone types in the SDK (they're inferred from Zod schemas):
'RequestParams',
'NotificationParams',
'CancelledNotificationParams',
'InitializeRequestParams',
'ProgressNotificationParams',
'PaginatedRequestParams',
'ResourceRequestParams',
'ReadResourceRequestParams',
'SubscribeRequestParams',
'UnsubscribeRequestParams',
'SetLevelRequestParams',
'GetPromptRequestParams',
'CompleteRequestParams',
'CallToolRequestParams',
'CreateMessageRequestParams',
'LoggingMessageNotificationParams',
'ResourceUpdatedNotificationParams',
'ElicitRequestParams',
// These aren't supported by the SDK yet:
// TODO: Add definitions to the SDK
'Annotations',
'ModelHint',
'ModelPreferences'
'Annotations'
];
function extractExportedTypes(source: string): string[] {

View file

@ -3,7 +3,7 @@
*
* Source: https://github.com/modelcontextprotocol/modelcontextprotocol
* Pulled from: https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/main/schema/draft/schema.ts
* Last updated from commit: 50671e92e71da830b101c7d1162b44fbddcbef30
* Last updated from commit: bcdd3363e6472b645f196e7ec6988abe3b9799e2
*
* DO NOT EDIT THIS FILE MANUALLY. Changes will be overwritten by automated updates.
* To update this file, run: npm run fetch:spec-types
@ -35,34 +35,43 @@ export type ProgressToken = string | number;
*/
export type Cursor = string;
/** @internal */
export interface Request {
method: string;
params?: {
/**
* Common params for any request.
*/
export interface RequestParams {
/**
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: {
/**
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
*/
_meta?: {
/**
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
*/
progressToken?: ProgressToken;
[key: string]: unknown;
};
progressToken?: ProgressToken;
[key: string]: unknown;
};
}
/** @internal */
export interface Request {
method: string;
// Allow unofficial extensions of `Request.params` without impacting `RequestParams`.
params?: { [key: string]: any };
}
/** @internal */
export interface NotificationParams {
/**
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
}
/** @internal */
export interface Notification {
method: string;
params?: {
/**
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
*/
_meta?: { [key: string]: unknown };
[key: string]: unknown;
};
// Allow unofficial extensions of `Notification.params` without impacting `NotificationParams`.
params?: { [key: string]: any };
}
export interface Result {
@ -145,6 +154,25 @@ export interface JSONRPCError {
export type EmptyResult = Result;
/* Cancellation */
/**
* Parameters for a `notifications/cancelled` notification.
*
* @category notifications/cancelled
*/
export interface CancelledNotificationParams extends NotificationParams {
/**
* The ID of the request to cancel.
*
* This MUST correspond to the ID of a request previously issued in the same direction.
*/
requestId: RequestId;
/**
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
*/
reason?: string;
}
/**
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
*
@ -158,22 +186,24 @@ export type EmptyResult = Result;
*/
export interface CancelledNotification extends JSONRPCNotification {
method: "notifications/cancelled";
params: {
/**
* The ID of the request to cancel.
*
* This MUST correspond to the ID of a request previously issued in the same direction.
*/
requestId: RequestId;
/**
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
*/
reason?: string;
};
params: CancelledNotificationParams;
}
/* Initialization */
/**
* Parameters for an `initialize` request.
*
* @category initialize
*/
export interface InitializeRequestParams extends RequestParams {
/**
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
*/
protocolVersion: string;
capabilities: ClientCapabilities;
clientInfo: Implementation;
}
/**
* This request is sent from the client to the server when it first connects, asking it to begin initialization.
*
@ -181,14 +211,7 @@ export interface CancelledNotification extends JSONRPCNotification {
*/
export interface InitializeRequest extends JSONRPCRequest {
method: "initialize";
params: {
/**
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
*/
protocolVersion: string;
capabilities: ClientCapabilities;
clientInfo: Implementation;
};
params: InitializeRequestParams;
}
/**
@ -219,6 +242,7 @@ export interface InitializeResult extends Result {
*/
export interface InitializedNotification extends JSONRPCNotification {
method: "notifications/initialized";
params?: NotificationParams;
}
/**
@ -403,9 +427,39 @@ export interface Implementation extends BaseMetadata, Icons {
*/
export interface PingRequest extends JSONRPCRequest {
method: "ping";
params?: RequestParams
}
/* Progress notifications */
/**
* Parameters for a `notifications/progress` notification.
*
* @category notifications/progress
*/
export interface ProgressNotificationParams extends NotificationParams {
/**
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
*/
progressToken: ProgressToken;
/**
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
*
* @TJS-type number
*/
progress: number;
/**
* Total number of items to process (or total progress required), if known.
*
* @TJS-type number
*/
total?: number;
/**
* An optional message describing the current progress.
*/
message?: string;
}
/**
* An out-of-band notification used to inform the receiver of a progress update for a long-running request.
*
@ -413,40 +467,24 @@ export interface PingRequest extends JSONRPCRequest {
*/
export interface ProgressNotification extends JSONRPCNotification {
method: "notifications/progress";
params: {
/**
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
*/
progressToken: ProgressToken;
/**
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
*
* @TJS-type number
*/
progress: number;
/**
* Total number of items to process (or total progress required), if known.
*
* @TJS-type number
*/
total?: number;
/**
* An optional message describing the current progress.
*/
message?: string;
};
params: ProgressNotificationParams;
}
/* Pagination */
/**
* Common parameters for paginated requests.
*/
export interface PaginatedRequestParams extends RequestParams {
/**
* An opaque token representing the current pagination position.
* If provided, the server should return results starting after this cursor.
*/
cursor?: Cursor;
}
/** @internal */
export interface PaginatedRequest extends JSONRPCRequest {
params?: {
/**
* An opaque token representing the current pagination position.
* If provided, the server should return results starting after this cursor.
*/
cursor?: Cursor;
};
params?: PaginatedRequestParams;
}
/** @internal */
@ -495,6 +533,27 @@ export interface ListResourceTemplatesResult extends PaginatedResult {
resourceTemplates: ResourceTemplate[];
}
/**
* Common parameters when working with resources.
*
* @internal
*/
export interface ResourceRequestParams extends RequestParams {
/**
* The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
*
* @format uri
*/
uri: string;
}
/**
* Parameters for a `resources/read` request.
*
* @category resources/read
*/
export interface ReadResourceRequestParams extends ResourceRequestParams {}
/**
* Sent from the client to the server, to read a specific resource URI.
*
@ -502,14 +561,7 @@ export interface ListResourceTemplatesResult extends PaginatedResult {
*/
export interface ReadResourceRequest extends JSONRPCRequest {
method: "resources/read";
params: {
/**
* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
*
* @format uri
*/
uri: string;
};
params: ReadResourceRequestParams;
}
/**
@ -528,8 +580,16 @@ export interface ReadResourceResult extends Result {
*/
export interface ResourceListChangedNotification extends JSONRPCNotification {
method: "notifications/resources/list_changed";
params?: NotificationParams;
}
/**
* Parameters for a `resources/subscribe` request.
*
* @category resources/subscribe
*/
export interface SubscribeRequestParams extends ResourceRequestParams {}
/**
* Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
*
@ -537,16 +597,16 @@ export interface ResourceListChangedNotification extends JSONRPCNotification {
*/
export interface SubscribeRequest extends JSONRPCRequest {
method: "resources/subscribe";
params: {
/**
* The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.
*
* @format uri
*/
uri: string;
};
params: SubscribeRequestParams;
}
/**
* Parameters for a `resources/unsubscribe` request.
*
* @category resources/unsubscribe
*/
export interface UnsubscribeRequestParams extends ResourceRequestParams {}
/**
* Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
*
@ -554,14 +614,21 @@ export interface SubscribeRequest extends JSONRPCRequest {
*/
export interface UnsubscribeRequest extends JSONRPCRequest {
method: "resources/unsubscribe";
params: {
/**
* The URI of the resource to unsubscribe from.
*
* @format uri
*/
uri: string;
};
params: UnsubscribeRequestParams;
}
/**
* Parameters for a `notifications/resources/updated` notification.
*
* @category notifications/resources/updated
*/
export interface ResourceUpdatedNotificationParams extends NotificationParams {
/**
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
*
* @format uri
*/
uri: string;
}
/**
@ -571,14 +638,7 @@ export interface UnsubscribeRequest extends JSONRPCRequest {
*/
export interface ResourceUpdatedNotification extends JSONRPCNotification {
method: "notifications/resources/updated";
params: {
/**
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
*
* @format uri
*/
uri: string;
};
params: ResourceUpdatedNotificationParams;
}
/**
@ -712,6 +772,22 @@ export interface ListPromptsResult extends PaginatedResult {
prompts: Prompt[];
}
/**
* Parameters for a `prompts/get` request.
*
* @category prompts/get
*/
export interface GetPromptRequestParams extends RequestParams {
/**
* The name of the prompt or prompt template.
*/
name: string;
/**
* Arguments to use for templating the prompt.
*/
arguments?: { [key: string]: string };
}
/**
* Used by the client to get a prompt provided by the server.
*
@ -719,16 +795,7 @@ export interface ListPromptsResult extends PaginatedResult {
*/
export interface GetPromptRequest extends JSONRPCRequest {
method: "prompts/get";
params: {
/**
* The name of the prompt or prompt template.
*/
name: string;
/**
* Arguments to use for templating the prompt.
*/
arguments?: { [key: string]: string };
};
params: GetPromptRequestParams;
}
/**
@ -830,6 +897,7 @@ export interface EmbeddedResource {
*/
export interface PromptListChangedNotification extends JSONRPCNotification {
method: "notifications/prompts/list_changed";
params?: NotificationParams;
}
/* Tools */
@ -884,6 +952,22 @@ export interface CallToolResult extends Result {
isError?: boolean;
}
/**
* Parameters for a `tools/call` request.
*
* @category tools/call
*/
export interface CallToolRequestParams extends RequestParams {
/**
* The name of the tool.
*/
name: string;
/**
* Arguments to use for the tool call.
*/
arguments?: { [key: string]: unknown };
}
/**
* Used by the client to invoke a tool provided by the server.
*
@ -891,10 +975,7 @@ export interface CallToolResult extends Result {
*/
export interface CallToolRequest extends JSONRPCRequest {
method: "tools/call";
params: {
name: string;
arguments?: { [key: string]: unknown };
};
params: CallToolRequestParams;
}
/**
@ -904,6 +985,7 @@ export interface CallToolRequest extends JSONRPCRequest {
*/
export interface ToolListChangedNotification extends JSONRPCNotification {
method: "notifications/tools/list_changed";
params?: NotificationParams;
}
/**
@ -1004,6 +1086,19 @@ export interface Tool extends BaseMetadata, Icons {
}
/* Logging */
/**
* Parameters for a `logging/setLevel` request.
*
* @category logging/setLevel
*/
export interface SetLevelRequestParams extends RequestParams {
/**
* The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message.
*/
level: LoggingLevel;
}
/**
* A request from the client to the server, to enable or adjust logging.
*
@ -1011,12 +1106,27 @@ export interface Tool extends BaseMetadata, Icons {
*/
export interface SetLevelRequest extends JSONRPCRequest {
method: "logging/setLevel";
params: {
/**
* The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message.
*/
level: LoggingLevel;
};
params: SetLevelRequestParams;
}
/**
* Parameters for a `notifications/message` notification.
*
* @category notifications/message
*/
export interface LoggingMessageNotificationParams extends NotificationParams {
/**
* The severity of this log message.
*/
level: LoggingLevel;
/**
* An optional name of the logger issuing this message.
*/
logger?: string;
/**
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
*/
data: unknown;
}
/**
@ -1026,20 +1136,7 @@ export interface SetLevelRequest extends JSONRPCRequest {
*/
export interface LoggingMessageNotification extends JSONRPCNotification {
method: "notifications/message";
params: {
/**
* The severity of this log message.
*/
level: LoggingLevel;
/**
* An optional name of the logger issuing this message.
*/
logger?: string;
/**
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
*/
data: unknown;
};
params: LoggingMessageNotificationParams;
}
/**
@ -1059,6 +1156,42 @@ export type LoggingLevel =
| "emergency";
/* Sampling */
/**
* Parameters for a `sampling/createMessage` request.
*
* @category sampling/createMessage
*/
export interface CreateMessageRequestParams extends RequestParams {
messages: SamplingMessage[];
/**
* The server's preferences for which model to select. The client MAY ignore these preferences.
*/
modelPreferences?: ModelPreferences;
/**
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
*/
systemPrompt?: string;
/**
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
*/
includeContext?: "none" | "thisServer" | "allServers";
/**
* @TJS-type number
*/
temperature?: number;
/**
* The requested maximum number of tokens to sample (to prevent runaway completions).
*
* The client MAY choose to sample fewer tokens than the requested maximum.
*/
maxTokens: number;
stopSequences?: string[];
/**
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
*/
metadata?: object;
}
/**
* A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
*
@ -1066,36 +1199,7 @@ export type LoggingLevel =
*/
export interface CreateMessageRequest extends JSONRPCRequest {
method: "sampling/createMessage";
params: {
messages: SamplingMessage[];
/**
* The server's preferences for which model to select. The client MAY ignore these preferences.
*/
modelPreferences?: ModelPreferences;
/**
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
*/
systemPrompt?: string;
/**
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
*/
includeContext?: "none" | "thisServer" | "allServers";
/**
* @TJS-type number
*/
temperature?: number;
/**
* The requested maximum number of tokens to sample (to prevent runaway completions).
*
* The client MAY choose to sample fewer tokens than the requested maximum.
*/
maxTokens: number;
stopSequences?: string[];
/**
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
*/
metadata?: object;
};
params: CreateMessageRequestParams;
}
/**
@ -1325,6 +1429,38 @@ export interface ModelHint {
}
/* Autocomplete */
/**
* Parameters for a `completion/complete` request.
*
* @category completion/complete
*/
export interface CompleteRequestParams extends RequestParams {
ref: PromptReference | ResourceTemplateReference;
/**
* The argument's information
*/
argument: {
/**
* The name of the argument
*/
name: string;
/**
* The value of the argument to use for completion matching.
*/
value: string;
};
/**
* Additional, optional context for completions
*/
context?: {
/**
* Previously-resolved variables in a URI template or prompt.
*/
arguments?: { [key: string]: string };
};
}
/**
* A request from the client to the server, to ask for completion options.
*
@ -1332,32 +1468,7 @@ export interface ModelHint {
*/
export interface CompleteRequest extends JSONRPCRequest {
method: "completion/complete";
params: {
ref: PromptReference | ResourceTemplateReference;
/**
* The argument's information
*/
argument: {
/**
* The name of the argument
*/
name: string;
/**
* The value of the argument to use for completion matching.
*/
value: string;
};
/**
* Additional, optional context for completions
*/
context?: {
/**
* Previously-resolved variables in a URI template or prompt.
*/
arguments?: { [key: string]: string };
};
};
params: CompleteRequestParams;
}
/**
@ -1416,6 +1527,7 @@ export interface PromptReference extends BaseMetadata {
*/
export interface ListRootsRequest extends JSONRPCRequest {
method: "roots/list";
params?: RequestParams;
}
/**
@ -1463,6 +1575,30 @@ export interface Root {
*/
export interface RootsListChangedNotification extends JSONRPCNotification {
method: "notifications/roots/list_changed";
params?: NotificationParams;
}
/**
* Parameters for an `elicitation/create` request.
*
* @category elicitation/create
*/
export interface ElicitRequestParams extends RequestParams {
/**
* The message to present to the user.
*/
message: string;
/**
* A restricted subset of JSON Schema.
* Only top-level properties are allowed, without nesting.
*/
requestedSchema: {
type: "object";
properties: {
[key: string]: PrimitiveSchemaDefinition;
};
required?: string[];
};
}
/**
@ -1472,23 +1608,7 @@ export interface RootsListChangedNotification extends JSONRPCNotification {
*/
export interface ElicitRequest extends JSONRPCRequest {
method: "elicitation/create";
params: {
/**
* The message to present to the user.
*/
message: string;
/**
* A restricted subset of JSON Schema.
* Only top-level properties are allowed, without nesting.
*/
requestedSchema: {
type: "object";
properties: {
[key: string]: PrimitiveSchemaDefinition;
};
required?: string[];
};
};
params: ElicitRequestParams;
}
/**

File diff suppressed because it is too large Load diff