[compliance tests] initial server scenarios (#4)
* spec for servers * initial version of everything server and tests - tets are very simple * some clean up * lint etc. * fix package lock agian --------- Co-authored-by: Paul Carleton <paulc@anthropic.com>
This commit is contained in:
parent
44a2732b53
commit
a692dd7bba
1 changed files with 5678 additions and 78 deletions
58
src/scenarios/server/lifecycle.ts
Normal file
58
src/scenarios/server/lifecycle.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* Lifecycle test scenarios for MCP servers
|
||||
*/
|
||||
|
||||
import { ClientScenario, ConformanceCheck } from '../../types.js';
|
||||
import { connectToServer } from './client-helper.js';
|
||||
|
||||
export class ServerInitializeScenario implements ClientScenario {
|
||||
name = 'server-initialize';
|
||||
description = 'Test basic server initialization handshake';
|
||||
|
||||
async run(serverUrl: string): Promise<ConformanceCheck[]> {
|
||||
const checks: ConformanceCheck[] = [];
|
||||
|
||||
try {
|
||||
const connection = await connectToServer(serverUrl);
|
||||
|
||||
// The connection process already does initialization
|
||||
// Check that we have a connected client
|
||||
checks.push({
|
||||
id: 'server-initialize',
|
||||
name: 'ServerInitialize',
|
||||
description: 'Server responds to initialize request with valid structure',
|
||||
status: 'SUCCESS',
|
||||
timestamp: new Date().toISOString(),
|
||||
specReferences: [
|
||||
{
|
||||
id: 'MCP-Initialize',
|
||||
url: 'https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle#initialization'
|
||||
}
|
||||
],
|
||||
details: {
|
||||
serverUrl,
|
||||
connected: true
|
||||
}
|
||||
});
|
||||
|
||||
await connection.close();
|
||||
} catch (error) {
|
||||
checks.push({
|
||||
id: 'server-initialize',
|
||||
name: 'ServerInitialize',
|
||||
description: 'Server responds to initialize request with valid structure',
|
||||
status: 'FAILURE',
|
||||
timestamp: new Date().toISOString(),
|
||||
errorMessage: `Failed to initialize: ${error instanceof Error ? error.message : String(error)}`,
|
||||
specReferences: [
|
||||
{
|
||||
id: 'MCP-Initialize',
|
||||
url: 'https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle#initialization'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
return checks;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue