conformance/src/checks/client.ts
Paul Carleton d303013e5d
[auth] Implement CIMD conformance test (#37)
* add cimd test and negative test

* Improve auth-test-no-cimd.ts documentation for clarity

Address review feedback: expanded comments to better explain what CIMD is,
why this client is non-compliant, and what behavior it's testing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove .js extensions from relative imports

tsx doesn't require .js extensions for TypeScript imports.
Keeps .js for @modelcontextprotocol/sdk imports as those are external packages.

Also improves auth-test-no-cimd.ts documentation for clarity.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Skip auth/basic-cimd test until SDK support lands

Waiting on typescript-sdk PR #1127 for CIMD support.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix trailing whitespace in auth-test-no-cimd.ts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-20 21:00:13 +00:00

67 lines
2 KiB
TypeScript

import { ConformanceCheck, CheckStatus } from '../types';
export function createServerInfoCheck(serverInfo: {
name: string;
version: string;
}): ConformanceCheck {
return {
id: 'server-info',
name: 'ServerInfo',
description: 'Test server info returned to client',
status: 'INFO',
timestamp: new Date().toISOString(),
specReferences: [
{
id: 'MCP-Lifecycle',
url: 'https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle'
}
],
details: {
serverName: serverInfo.name,
serverVersion: serverInfo.version
}
};
}
export function createClientInitializationCheck(
initializeRequest: any,
expectedSpecVersion: string = '2025-06-18'
): ConformanceCheck {
const protocolVersionSent = initializeRequest?.protocolVersion;
const versionMatch = protocolVersionSent === expectedSpecVersion;
const errors: string[] = [];
if (!protocolVersionSent) errors.push('Protocol version not provided');
if (!versionMatch)
errors.push(
`Version mismatch: expected ${expectedSpecVersion}, got ${protocolVersionSent}`
);
if (!initializeRequest?.clientInfo?.name) errors.push('Client name missing');
if (!initializeRequest?.clientInfo?.version)
errors.push('Client version missing');
const status: CheckStatus = errors.length === 0 ? 'SUCCESS' : 'FAILURE';
return {
id: 'mcp-client-initialization',
name: 'MCPClientInitialization',
description: 'Validates that MCP client properly initializes with server',
status,
timestamp: new Date().toISOString(),
specReferences: [
{
id: 'MCP-Lifecycle',
url: 'https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle'
}
],
details: {
protocolVersionSent,
expectedSpecVersion,
versionMatch,
clientName: initializeRequest?.clientInfo?.name,
clientVersion: initializeRequest?.clientInfo?.version
},
errorMessage: errors.length > 0 ? errors.join('; ') : undefined,
logs: errors.length > 0 ? errors : undefined
};
}