Skip to content

Commit f32b01c

Browse files
committed
apply linting
1 parent ae9451f commit f32b01c

File tree

11 files changed

+510
-527
lines changed

11 files changed

+510
-527
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ npm run start -- --command "tsx examples/clients/typescript/test1.ts" --scenario
1212
## Overview
1313

1414
The conformance test framework validates MCP client implementations by:
15+
1516
1. Starting a test server for the specified scenario
1617
2. Running the client implementation with the test server URL
1718
3. Capturing MCP protocol interactions
@@ -32,6 +33,7 @@ The framework appends the server URL as the final argument to your command.
3233
## Test Results
3334

3435
Results are saved to `results/<scenario>-<timestamp>/`:
36+
3537
- `checks.json` - Array of conformance check results with pass/fail status
3638
- `stdout.txt` - Client stdout output
3739
- `stderr.txt` - Client stderr output
@@ -44,9 +46,9 @@ Results are saved to `results/<scenario>-<timestamp>/`:
4446
## Available Scenarios
4547

4648
- **initialize** - Tests MCP client initialization handshake
47-
- Validates protocol version
48-
- Validates clientInfo (name and version)
49-
- Validates server response handling
49+
- Validates protocol version
50+
- Validates clientInfo (name and version)
51+
- Validates server response handling
5052

5153
## Architecture
5254

examples/clients/typescript/test-broken.ts

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,55 @@
33
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
44

55
async function main(): Promise<void> {
6-
const serverUrl = process.argv[2];
7-
8-
if (!serverUrl) {
9-
console.error('Usage: test-broken-client <server-url>');
10-
process.exit(1);
11-
}
12-
13-
console.log(`Connecting to MCP server at: ${serverUrl}`);
14-
15-
try {
16-
const transport = new StreamableHTTPClientTransport(
17-
new URL(serverUrl)
18-
);
19-
20-
await transport.start();
21-
22-
const initRequest = {
23-
jsonrpc: '2.0',
24-
id: 1,
25-
method: 'initialize',
26-
params: {
27-
protocolVersion: '2025-06-18',
28-
clientInfo: {
29-
version: '1.0.0'
30-
},
31-
capabilities: {}
32-
}
33-
};
34-
35-
const response = await fetch(serverUrl, {
36-
method: 'POST',
37-
headers: {
38-
'Content-Type': 'application/json'
39-
},
40-
body: JSON.stringify(initRequest)
41-
});
42-
43-
const result = await response.json();
44-
console.log('✅ Received response:', JSON.stringify(result, null, 2));
45-
46-
await transport.close();
47-
console.log('✅ Connection closed');
48-
49-
process.exit(0);
50-
} catch (error) {
51-
console.error('❌ Error:', error);
52-
process.exit(1);
53-
}
6+
const serverUrl = process.argv[2];
7+
8+
if (!serverUrl) {
9+
console.error('Usage: test-broken-client <server-url>');
10+
process.exit(1);
11+
}
12+
13+
console.log(`Connecting to MCP server at: ${serverUrl}`);
14+
15+
try {
16+
const transport = new StreamableHTTPClientTransport(new URL(serverUrl));
17+
18+
await transport.start();
19+
20+
const initRequest = {
21+
jsonrpc: '2.0',
22+
id: 1,
23+
method: 'initialize',
24+
params: {
25+
protocolVersion: '2025-06-18',
26+
clientInfo: {
27+
version: '1.0.0'
28+
},
29+
capabilities: {}
30+
}
31+
};
32+
33+
const response = await fetch(serverUrl, {
34+
method: 'POST',
35+
headers: {
36+
'Content-Type': 'application/json'
37+
},
38+
body: JSON.stringify(initRequest)
39+
});
40+
41+
const result = await response.json();
42+
console.log('✅ Received response:', JSON.stringify(result, null, 2));
43+
44+
await transport.close();
45+
console.log('✅ Connection closed');
46+
47+
process.exit(0);
48+
} catch (error) {
49+
console.error('❌ Error:', error);
50+
process.exit(1);
51+
}
5452
}
5553

56-
main().catch((error) => {
57-
console.error('Unhandled error:', error);
58-
process.exit(1);
54+
main().catch(error => {
55+
console.error('Unhandled error:', error);
56+
process.exit(1);
5957
});

examples/clients/typescript/test1.ts

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,45 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
44
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
55

66
async function main(): Promise<void> {
7-
const serverUrl = process.argv[2];
8-
9-
if (!serverUrl) {
10-
console.error('Usage: test-client <server-url>');
11-
process.exit(1);
12-
}
13-
14-
console.log(`Connecting to MCP server at: ${serverUrl}`);
15-
16-
try {
17-
const client = new Client({
18-
name: 'test-client',
19-
version: '1.0.0'
20-
}, {
21-
capabilities: {}
22-
});
23-
24-
const transport = new StreamableHTTPClientTransport(
25-
new URL(serverUrl)
26-
);
27-
28-
await client.connect(transport);
29-
console.log('✅ Successfully connected to MCP server');
30-
31-
await client.listTools();
32-
console.log('✅ Successfully listed tools');
33-
34-
await transport.close();
35-
console.log('✅ Connection closed successfully');
36-
37-
process.exit(0);
38-
} catch (error) {
39-
console.error('❌ Failed to connect to MCP server:', error);
40-
process.exit(1);
41-
}
7+
const serverUrl = process.argv[2];
8+
9+
if (!serverUrl) {
10+
console.error('Usage: test-client <server-url>');
11+
process.exit(1);
12+
}
13+
14+
console.log(`Connecting to MCP server at: ${serverUrl}`);
15+
16+
try {
17+
const client = new Client(
18+
{
19+
name: 'test-client',
20+
version: '1.0.0'
21+
},
22+
{
23+
capabilities: {}
24+
}
25+
);
26+
27+
const transport = new StreamableHTTPClientTransport(new URL(serverUrl));
28+
29+
await client.connect(transport);
30+
console.log('✅ Successfully connected to MCP server');
31+
32+
await client.listTools();
33+
console.log('✅ Successfully listed tools');
34+
35+
await transport.close();
36+
console.log('✅ Connection closed successfully');
37+
38+
process.exit(0);
39+
} catch (error) {
40+
console.error('❌ Failed to connect to MCP server:', error);
41+
process.exit(1);
42+
}
4243
}
4344

44-
main().catch((error) => {
45-
console.error('Unhandled error:', error);
46-
process.exit(1);
45+
main().catch(error => {
46+
console.error('Unhandled error:', error);
47+
process.exit(1);
4748
});

jest.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export default {
2-
preset: 'ts-jest/presets/default-esm',
3-
extensionsToTreatAsEsm: ['.ts'],
4-
testEnvironment: 'node',
5-
moduleNameMapper: {
6-
'^(\\.{1,2}/.*)\\.js$': '$1',
7-
},
2+
preset: 'ts-jest/presets/default-esm',
3+
extensionsToTreatAsEsm: ['.ts'],
4+
testEnvironment: 'node',
5+
moduleNameMapper: {
6+
'^(\\.{1,2}/.*)\\.js$': '$1'
7+
}
88
};

src/checks.test.ts

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
11
import { createClientInitializationCheck } from './checks';
22

33
describe('createClientInitializationCheck', () => {
4-
it('should return SUCCESS for a valid initialize request', () => {
5-
const validRequest = {
6-
protocolVersion: '2025-06-18',
7-
clientInfo: {
8-
name: 'TestClient',
9-
version: '1.0.0'
10-
}
11-
};
4+
it('should return SUCCESS for a valid initialize request', () => {
5+
const validRequest = {
6+
protocolVersion: '2025-06-18',
7+
clientInfo: {
8+
name: 'TestClient',
9+
version: '1.0.0'
10+
}
11+
};
1212

13-
const check = createClientInitializationCheck(validRequest);
14-
expect(check.status).toBe('SUCCESS');
15-
expect(check.errorMessage).toBeUndefined();
16-
});
13+
const check = createClientInitializationCheck(validRequest);
14+
expect(check.status).toBe('SUCCESS');
15+
expect(check.errorMessage).toBeUndefined();
16+
});
1717

18-
it('should return FAILURE when protocol version is missing', () => {
19-
const invalidRequest = {
20-
clientInfo: {
21-
name: 'TestClient',
22-
version: '1.0.0'
23-
}
24-
};
18+
it('should return FAILURE when protocol version is missing', () => {
19+
const invalidRequest = {
20+
clientInfo: {
21+
name: 'TestClient',
22+
version: '1.0.0'
23+
}
24+
};
2525

26-
const check = createClientInitializationCheck(invalidRequest);
27-
expect(check.status).toBe('FAILURE');
28-
expect(check.errorMessage).toContain('Protocol version not provided');
29-
});
26+
const check = createClientInitializationCheck(invalidRequest);
27+
expect(check.status).toBe('FAILURE');
28+
expect(check.errorMessage).toContain('Protocol version not provided');
29+
});
3030

31-
it('should return FAILURE when protocol version does not match', () => {
32-
const invalidRequest = {
33-
protocolVersion: '2024-11-05',
34-
clientInfo: {
35-
name: 'TestClient',
36-
version: '1.0.0'
37-
}
38-
};
31+
it('should return FAILURE when protocol version does not match', () => {
32+
const invalidRequest = {
33+
protocolVersion: '2024-11-05',
34+
clientInfo: {
35+
name: 'TestClient',
36+
version: '1.0.0'
37+
}
38+
};
3939

40-
const check = createClientInitializationCheck(invalidRequest);
41-
expect(check.status).toBe('FAILURE');
42-
expect(check.errorMessage).toContain('Version mismatch');
43-
});
40+
const check = createClientInitializationCheck(invalidRequest);
41+
expect(check.status).toBe('FAILURE');
42+
expect(check.errorMessage).toContain('Version mismatch');
43+
});
4444

45-
it('should return FAILURE when client name is missing', () => {
46-
const invalidRequest = {
47-
protocolVersion: '2025-06-18',
48-
clientInfo: {
49-
version: '1.0.0'
50-
}
51-
};
45+
it('should return FAILURE when client name is missing', () => {
46+
const invalidRequest = {
47+
protocolVersion: '2025-06-18',
48+
clientInfo: {
49+
version: '1.0.0'
50+
}
51+
};
5252

53-
const check = createClientInitializationCheck(invalidRequest);
54-
expect(check.status).toBe('FAILURE');
55-
expect(check.errorMessage).toContain('Client name missing');
56-
});
53+
const check = createClientInitializationCheck(invalidRequest);
54+
expect(check.status).toBe('FAILURE');
55+
expect(check.errorMessage).toContain('Client name missing');
56+
});
5757

58-
it('should return FAILURE when client version is missing', () => {
59-
const invalidRequest = {
60-
protocolVersion: '2025-06-18',
61-
clientInfo: {
62-
name: 'TestClient'
63-
}
64-
};
58+
it('should return FAILURE when client version is missing', () => {
59+
const invalidRequest = {
60+
protocolVersion: '2025-06-18',
61+
clientInfo: {
62+
name: 'TestClient'
63+
}
64+
};
6565

66-
const check = createClientInitializationCheck(invalidRequest);
67-
expect(check.status).toBe('FAILURE');
68-
expect(check.errorMessage).toContain('Client version missing');
69-
});
66+
const check = createClientInitializationCheck(invalidRequest);
67+
expect(check.status).toBe('FAILURE');
68+
expect(check.errorMessage).toContain('Client version missing');
69+
});
7070

71-
it('should support custom expected spec version', () => {
72-
const request = {
73-
protocolVersion: '2024-11-05',
74-
clientInfo: {
75-
name: 'TestClient',
76-
version: '1.0.0'
77-
}
78-
};
71+
it('should support custom expected spec version', () => {
72+
const request = {
73+
protocolVersion: '2024-11-05',
74+
clientInfo: {
75+
name: 'TestClient',
76+
version: '1.0.0'
77+
}
78+
};
7979

80-
const check = createClientInitializationCheck(request, '2024-11-05');
81-
expect(check.status).toBe('SUCCESS');
82-
expect(check.errorMessage).toBeUndefined();
83-
});
80+
const check = createClientInitializationCheck(request, '2024-11-05');
81+
expect(check.status).toBe('SUCCESS');
82+
expect(check.errorMessage).toBeUndefined();
83+
});
8484
});

0 commit comments

Comments
 (0)