Skip to content

Commit 4d7595c

Browse files
committed
fix: eslint
1 parent 670635e commit 4d7595c

File tree

6 files changed

+33
-39
lines changed

6 files changed

+33
-39
lines changed

src/cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ async function runServer(port: number | null) {
9191
console.log('Received message');
9292

9393
const sessionId = req.query.sessionId as string;
94-
95-
const transport = servers.reduce((pre, val) => pre.concat(Array.from(val.transportMap.values()) as SSEServerTransport[]), [] as SSEServerTransport[]).find(t => t.sessionId === sessionId);
94+
95+
const transport = servers
96+
.reduce((pre, val) => pre.concat(Array.from(val.transportMap.values()) as SSEServerTransport[]), [] as SSEServerTransport[])
97+
.find(t => t.sessionId === sessionId);
9698
if (!transport) {
9799
res.status(404).send('Session not found');
98100
return;

src/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export class Server<
327327
async sendLoggingMessage(params: LoggingMessageNotification['params'], sessionId?: string) {
328328
if (this._capabilities.logging) {
329329
if (!this.isMessageIgnored(params.level, sessionId)) {
330-
return this.notification({ method: 'notifications/message', params }, { sessionId});
330+
return this.notification({ method: 'notifications/message', params }, { sessionId });
331331
}
332332
}
333333
}

src/server/multipleLinks.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Client } from '../client/index.js'
2-
import { SSEClientTransport } from '../client/sse.js'
1+
import { Client } from '../client/index.js';
2+
import { SSEClientTransport } from '../client/sse.js';
33
import { StreamableHTTPClientTransport } from '../client/streamableHttp.js';
44
import express, { Request, Response } from 'express';
55
import { McpServer } from '../server/mcp.js';
@@ -8,7 +8,7 @@ import { InMemoryEventStore } from '../examples/shared/inMemoryEventStore.js';
88
import { StreamableHTTPServerTransport } from '../server/streamableHttp.js';
99
import { z } from 'zod';
1010
import { randomUUID } from 'node:crypto';
11-
import * as http from "http";
11+
import * as http from 'http';
1212
import cors from 'cors';
1313
import { isInitializeRequest } from '../types.js';
1414

@@ -20,26 +20,27 @@ const server = new McpServer(
2020
{ capabilities: { logging: {} } }
2121
);
2222

23-
server.registerTool('sayHello', {
24-
description: 'Says hello to the user',
25-
inputSchema: {
26-
name: z.string().describe('Name to include in greeting')
23+
server.registerTool(
24+
'sayHello',
25+
{
26+
description: 'Says hello to the user',
27+
inputSchema: {
28+
name: z.string().describe('Name to include in greeting')
29+
}
2730
},
28-
}, async ({ name }) => {
29-
return {
30-
content: [{ type: 'text', text: 'Hello, ' + name + '!' }]
31+
async ({ name }) => {
32+
return {
33+
content: [{ type: 'text', text: 'Hello, ' + name + '!' }]
34+
};
3135
}
32-
});
36+
);
3337

3438
const transports: Record<string, StreamableHTTPServerTransport | SSEServerTransport> = {};
3539

3640
let expressServer: http.Server;
3741

38-
39-
4042
describe.only('multipleLinks.test.js', () => {
4143
beforeAll(async () => {
42-
4344
const app = express();
4445
app.use(express.json());
4546

@@ -112,7 +113,6 @@ describe.only('multipleLinks.test.js', () => {
112113
}
113114
});
114115

115-
116116
app.all('/mcp', async (req: Request, res: Response) => {
117117
console.log(`Received ${req.method} request to /mcp`);
118118

@@ -192,7 +192,6 @@ describe.only('multipleLinks.test.js', () => {
192192
}
193193
});
194194

195-
196195
app.post('/stateless/mcp', async (req: Request, res: Response) => {
197196
try {
198197
const transport: StreamableHTTPServerTransport = new StreamableHTTPServerTransport({
@@ -267,7 +266,6 @@ describe.only('multipleLinks.test.js', () => {
267266
await serverReady;
268267
});
269268

270-
271269
afterAll(async () => {
272270
console.log('Shutting down server...');
273271

src/server/sse.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ export interface SSEServerTransportOptions {
3131
*/
3232
enableDnsRebindingProtection?: boolean;
3333

34-
3534
/**
3635
* Callback for when a session is initialized.
3736
*/
38-
onsessioninitialized?: (sessionId: string) => void
37+
onsessioninitialized?: (sessionId: string) => void;
3938

4039
/**
4140
* Callback for when a session is closed.
4241
*/
43-
onsessionclosed?: (sessionId: string) => void
42+
onsessionclosed?: (sessionId: string) => void;
4443
}
4544

4645
/**
@@ -58,7 +57,6 @@ export class SSEServerTransport implements Transport {
5857
onsessioninitialized?: (sessionId: string) => void | Promise<void>;
5958
onsessionclosed?: (sessionId: string) => void | Promise<void>;
6059

61-
6260
/**
6361
* Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.
6462
*/

src/shared/protocol.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,15 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
295295
if (sessionId) {
296296
this._transportMap.set(sessionId, transport);
297297
}
298-
}
298+
};
299299

300300
const originalOnSessionClosed = transport.onsessionclosed;
301301
transport.onsessionclosed = async (sessionId: string) => {
302302
await originalOnSessionClosed?.(sessionId);
303303
if (sessionId) {
304304
this._transportMap.delete(sessionId);
305305
}
306-
}
306+
};
307307

308308
// client init has only one transport, not invoke onsessioninitialized
309309
this._transportMap.set(DEFAULT_TRANSPROT_KEY, transport);
@@ -318,7 +318,7 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
318318
_onerror?.(error);
319319
this._onerror(error);
320320
};
321-
321+
322322
const _onmessage = transport?.onmessage;
323323
transport.onmessage = (message, extra) => {
324324
_onmessage?.(message, extra);
@@ -340,7 +340,7 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
340340
if (sessionId) {
341341
this._transportMap.delete(sessionId);
342342
} else {
343-
this._transportMap.delete(DEFAULT_TRANSPROT_KEY)
343+
this._transportMap.delete(DEFAULT_TRANSPROT_KEY);
344344
}
345345
const responseHandlers = this._responseHandlers;
346346
this._responseHandlers = new Map();
@@ -409,7 +409,8 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
409409
sessionId: capturedTransport?.sessionId,
410410
_meta: request.params?._meta,
411411
sendNotification: notification => this.notification(notification, { relatedRequestId: request.id, sessionId }),
412-
sendRequest: (r, resultSchema, options?) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id, sessionId }),
412+
sendRequest: (r, resultSchema, options?) =>
413+
this.request(r, resultSchema, { ...options, relatedRequestId: request.id, sessionId }),
413414
authInfo: extra?.authInfo,
414415
requestId: request.id,
415416
requestInfo: extra?.requestInfo
@@ -539,7 +540,7 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
539540
if (sessionId) {
540541
transport = this._transportMap.get(sessionId);
541542
}
542-
543+
543544
return new Promise((resolve, reject) => {
544545
if (!transport) {
545546
reject(new Error('Not connected'));
@@ -629,13 +630,10 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
629630
* Emits a notification, which is a one-way message that does not expect a response.
630631
*/
631632
async notification(notification: SendNotificationT, options?: NotificationOptions): Promise<void> {
632-
633633
let transports: Transport[] = Array.from(this._transportMap.values());
634634

635635
if (options?.sessionId && this._transportMap.has(options.sessionId)) {
636-
transports = [
637-
this._transportMap.get(options.sessionId)!
638-
];
636+
transports = [this._transportMap.get(options.sessionId)!];
639637
}
640638

641639
if (transports.length === 0) {
@@ -666,9 +664,7 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
666664
let transports: Transport[] = Array.from(this._transportMap.values());
667665

668666
if (options?.sessionId && this._transportMap.has(options.sessionId)) {
669-
transports = [
670-
this._transportMap.get(options.sessionId)!
671-
];
667+
transports = [this._transportMap.get(options.sessionId)!];
672668
}
673669

674670
// SAFETY CHECK: If the connection was closed while this was pending, abort.

src/shared/transport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface Transport {
8282
* Sets the protocol version used for the connection (called when the initialize response is received).
8383
*/
8484
setProtocolVersion?: (version: string) => void;
85-
85+
8686
/**
8787
* Callback for when a session is initialized.
8888
*/
@@ -92,4 +92,4 @@ export interface Transport {
9292
* Callback for when a session is closed.
9393
*/
9494
onsessionclosed?: (sessionId: string) => void | Promise<void>;
95-
}
95+
}

0 commit comments

Comments
 (0)