Skip to content

Commit f58b491

Browse files
committed
fixes
1 parent 68ff665 commit f58b491

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

src/server/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class Context<RequestT extends Request = Request, NotificationT extends N
146146
* This is used by certain transports to correctly associate related messages.
147147
*/
148148
public sendNotification = (notification: NotificationT | ServerNotification): Promise<void> => {
149-
return this.server.notification(notification);
149+
return this.requestCtx.sendNotification(notification);
150150
};
151151

152152
/**
@@ -159,7 +159,7 @@ export class Context<RequestT extends Request = Request, NotificationT extends N
159159
resultSchema: U,
160160
options?: RequestOptions
161161
): Promise<SchemaOutput<U>> => {
162-
return this.server.request(request, resultSchema, { ...options, relatedRequestId: this.requestId });
162+
return this.requestCtx.sendRequest(request, resultSchema, { ...options, relatedRequestId: this.requestId });
163163
};
164164

165165
/**

src/server/mcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ export class McpServer {
11361136
/**
11371137
* Registers a prompt with a config object and callback.
11381138
*/
1139-
registerPrompt<Args extends PromptArgsRawShape>(
1139+
registerPrompt<Args extends undefined | PromptArgsRawShape = undefined>(
11401140
name: string,
11411141
config: {
11421142
title?: string;

test/server/context.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from '../../src/types.js';
1414
import { InMemoryTransport } from '../../src/inMemory.js';
1515
import { RequestHandlerExtra } from '../../src/shared/protocol.js';
16-
import { ShapeOutput, ZodRawShapeCompat } from '../../src/server/zod-compat.js';
1716

1817
describe('Context', () => {
1918
/***
@@ -243,15 +242,11 @@ describe('Context', () => {
243242
'prompt',
244243
(mcpServer, seen) => {
245244
// The test is to ensure that the extra is compatible with the RequestHandlerExtra type
246-
mcpServer.registerPrompt(
247-
'ctx-prompt',
248-
{},
249-
async (args: ShapeOutput<ZodRawShapeCompat>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => {
250-
seen.isContext = extra instanceof Context;
251-
seen.hasRequestId = !!extra.requestId;
252-
return { messages: [] };
253-
}
254-
);
245+
mcpServer.registerPrompt('ctx-prompt', {}, async (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => {
246+
seen.isContext = extra instanceof Context;
247+
seen.hasRequestId = !!extra.requestId;
248+
return { messages: [] };
249+
});
255250
},
256251
client => client.request({ method: 'prompts/get', params: { name: 'ctx-prompt', arguments: {} } }, GetPromptResultSchema)
257252
]

0 commit comments

Comments
 (0)