Skip to content

Commit 96169b3

Browse files
committed
move logger methods under loggingNotification
1 parent 187a3cd commit 96169b3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/server/context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { AnySchema, SchemaOutput } from './zod-compat.js';
2323
/**
2424
* Interface for sending logging messages to the client via {@link LoggingMessageNotification}.
2525
*/
26-
export interface LoggingMessageSenderInterface {
26+
export interface LoggingMessageNotificationSenderInterface {
2727
/**
2828
* Sends a logging message to the client.
2929
*/
@@ -46,7 +46,7 @@ export interface LoggingMessageSenderInterface {
4646
error(message: string, extraLogData?: Record<string, unknown>, sessionId?: string): Promise<void>;
4747
}
4848

49-
export class ServerLogger implements LoggingMessageSenderInterface {
49+
export class ServerLogger implements LoggingMessageNotificationSenderInterface {
5050
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5151
constructor(private readonly server: Server<any, any, any>) {}
5252

@@ -130,7 +130,7 @@ export interface ContextInterface<RequestT extends Request = Request, Notificati
130130
extends RequestHandlerExtra<ServerRequest | RequestT, NotificationT | ServerNotification> {
131131
elicitInput(params: ElicitRequest['params'], options?: RequestOptions): Promise<ElicitResult>;
132132
requestSampling: (params: CreateMessageRequest['params'], options?: RequestOptions) => Promise<CreateMessageResult>;
133-
logger: LoggingMessageSenderInterface;
133+
loggingNotification: LoggingMessageNotificationSenderInterface;
134134
}
135135
/**
136136
* A context object that is passed to request handlers.
@@ -196,7 +196,7 @@ export class Context<RequestT extends Request = Request, NotificationT extends N
196196
}
197197
| undefined;
198198

199-
public readonly logger: LoggingMessageSenderInterface;
199+
public readonly loggingNotification: LoggingMessageNotificationSenderInterface;
200200

201201
constructor(args: {
202202
server: Server<RequestT, NotificationT, ResultT>;
@@ -218,7 +218,7 @@ export class Context<RequestT extends Request = Request, NotificationT extends N
218218
requestedTtl: args.requestCtx.taskRequestedTtl
219219
};
220220

221-
this.logger = new ServerLogger(args.server);
221+
this.loggingNotification = new ServerLogger(args.server);
222222

223223
this.stream = {
224224
closeSSEStream: args.requestCtx.closeSSEStream,

test/server/context.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ describe('Context', () => {
138138
});
139139

140140
mcpServer.registerTool('ctx-log-test', { inputSchema: z.object({ name: z.string() }) }, async (_args: { name: string }, extra) => {
141-
await extra.logger[level]('Test message', { test: 'test' }, 'sample-session-id');
142-
await extra.logger.log(
141+
await extra.loggingNotification[level]('Test message', { test: 'test' }, 'sample-session-id');
142+
await extra.loggingNotification.log(
143143
{
144144
level,
145145
data: 'Test message',

0 commit comments

Comments
 (0)