Skip to content

Commit fb42e4e

Browse files
committed
refactor: update server implementation to use McpServer and enhance logging
- Changed imports from Server to McpServer in multiple files. - Updated createHttpServer function to accept McpServer. - Refactored logging function to use McpServer for sending log messages. - Updated dependencies in package.json, including @modelcontextprotocol/sdk to version 1.29.0. - Enhanced error handling and logging throughout the application. - Updated express and other dependencies to their latest versions.
1 parent a844ca7 commit fb42e4e

11 files changed

Lines changed: 1189 additions & 1163 deletions

File tree

__tests__/helpers/mock-server.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/**
22
* Mock Server Helper
3-
*
3+
*
44
* Creates mock MCP server objects for testing
55
*/
66

7-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
8-
97
export interface MockServer {
10-
notification: (method: string, params: any) => Promise<void>;
8+
sendLoggingMessage: (params: any) => Promise<void>;
119
_serverInfo: { name: string; version: string };
1210
_capabilities: Record<string, any>;
1311
connect?: (transport: any) => Promise<void>;
@@ -17,11 +15,11 @@ export interface MockServer {
1715
* Create a minimal mock server for testing
1816
*/
1917
export function createMockServer(overrides?: Partial<MockServer>): MockServer {
20-
const mockNotificationCalls: any[] = [];
21-
18+
const mockLoggingCalls: any[] = [];
19+
2220
return {
23-
notification: async (method: string, params: any) => {
24-
mockNotificationCalls.push({ method, params });
21+
sendLoggingMessage: async (params: any) => {
22+
mockLoggingCalls.push(params);
2523
},
2624
_serverInfo: { name: 'test', version: '1.0' },
2725
_capabilities: {},
@@ -31,17 +29,17 @@ export function createMockServer(overrides?: Partial<MockServer>): MockServer {
3129
}
3230

3331
/**
34-
* Create a mock server that tracks notification calls
32+
* Create a mock server that tracks logging calls
3533
*/
3634
export function createMockServerWithTracking(): {
3735
server: MockServer;
38-
getNotificationCalls: () => any[];
36+
getLoggingCalls: () => any[];
3937
} {
40-
const mockNotificationCalls: any[] = [];
41-
38+
const mockLoggingCalls: any[] = [];
39+
4240
const server: MockServer = {
43-
notification: async (method: string, params: any) => {
44-
mockNotificationCalls.push({ method, params });
41+
sendLoggingMessage: async (params: any) => {
42+
mockLoggingCalls.push(params);
4543
},
4644
_serverInfo: { name: 'test', version: '1.0' },
4745
_capabilities: {},
@@ -50,6 +48,6 @@ export function createMockServerWithTracking(): {
5048

5149
return {
5250
server,
53-
getNotificationCalls: () => mockNotificationCalls
51+
getLoggingCalls: () => mockLoggingCalls
5452
};
5553
}

__tests__/unit/logging.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function runTests() {
5252
}, results);
5353

5454
await testFunction('logMessage with different levels and mock server', () => {
55-
const { server, getNotificationCalls } = createMockServerWithTracking();
55+
const { server, getLoggingCalls } = createMockServerWithTracking();
5656

5757
// Test different log levels
5858
setLogLevel('debug'); // Allow all messages
@@ -62,7 +62,7 @@ async function runTests() {
6262
logMessage(server as any, 'error', 'Test error message');
6363

6464
// Should have called notification for each message
65-
const calls = getNotificationCalls();
65+
const calls = getLoggingCalls();
6666
assert.ok(calls.length >= 0); // Notification calls depend on implementation
6767
}, results);
6868

eslint.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import tseslint from '@typescript-eslint/eslint-plugin';
2+
import tsParser from '@typescript-eslint/parser';
3+
4+
export default [
5+
// Type-aware rules for src (tsconfig covers these files)
6+
{
7+
files: ['src/**/*.ts'],
8+
languageOptions: {
9+
parser: tsParser,
10+
parserOptions: { project: './tsconfig.json' },
11+
},
12+
plugins: { '@typescript-eslint': tseslint },
13+
rules: {
14+
'@typescript-eslint/no-deprecated': 'warn',
15+
},
16+
},
17+
// Test files: parse without project (no type-aware rules)
18+
{
19+
files: ['__tests__/**/*.ts'],
20+
languageOptions: {
21+
parser: tsParser,
22+
},
23+
plugins: { '@typescript-eslint': tseslint },
24+
rules: {},
25+
},
26+
];

evals.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)