Skip to content

Commit 923f368

Browse files
committed
Merge main into pcarleton/more-sse-polling
2 parents e4df79d + e5cdffe commit 923f368

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enforce LF line endings for all text files
2+
* text=auto eol=lf
3+

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"endOfLine": "lf",
23
"singleQuote": true,
34
"trailingComma": "none",
45
"overrides": [

src/scenarios/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SSERetryScenario } from './client/sse-retry';
88
import { ServerInitializeScenario } from './server/lifecycle';
99

1010
import {
11+
PingScenario,
1112
LoggingSetLevelScenario,
1213
CompletionCompleteScenario
1314
} from './server/utils';
@@ -80,6 +81,7 @@ const allClientScenariosList: ClientScenario[] = [
8081

8182
// Utilities scenarios
8283
new LoggingSetLevelScenario(),
84+
new PingScenario(),
8385
new CompletionCompleteScenario(),
8486

8587
// Tools scenarios

src/scenarios/server/utils.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,95 @@ export class LoggingSetLevelScenario implements ClientScenario {
8383
}
8484
}
8585

86+
export class PingScenario implements ClientScenario {
87+
name = 'ping';
88+
description = `Test ping utility for connection health check.
89+
90+
**Server Implementation Requirements:**
91+
92+
**Endpoint**: \`ping\`
93+
94+
**Requirements**:
95+
- Accept ping request with no parameters
96+
- Respond promptly with empty object \`{}\`
97+
98+
**Request Format**:
99+
100+
\`\`\`json
101+
{
102+
"jsonrpc": "2.0",
103+
"id": "123",
104+
"method": "ping"
105+
}
106+
\`\`\`
107+
108+
**Response Format**:
109+
110+
\`\`\`json
111+
{
112+
"jsonrpc": "2.0",
113+
"id": "123",
114+
"result": {}
115+
}
116+
\`\`\`
117+
118+
**Implementation Note**: The ping utility allows either party to verify that their counterpart is still responsive and the connection is alive.`;
119+
120+
async run(serverUrl: string): Promise<ConformanceCheck[]> {
121+
const checks: ConformanceCheck[] = [];
122+
123+
try {
124+
const connection = await connectToServer(serverUrl);
125+
126+
// Send ping request
127+
const result = await connection.client.ping();
128+
129+
// Validate response (should return empty object {})
130+
const errors: string[] = [];
131+
if (result && Object.keys(result).length > 0) {
132+
errors.push('Expected empty object {} response');
133+
}
134+
135+
checks.push({
136+
id: 'ping',
137+
name: 'Ping',
138+
description: 'Server responds to ping requests',
139+
status: errors.length === 0 ? 'SUCCESS' : 'FAILURE',
140+
timestamp: new Date().toISOString(),
141+
errorMessage: errors.length > 0 ? errors.join('; ') : undefined,
142+
specReferences: [
143+
{
144+
id: 'MCP-Ping',
145+
url: 'https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/ping'
146+
}
147+
],
148+
details: {
149+
result
150+
}
151+
});
152+
153+
await connection.close();
154+
} catch (error) {
155+
checks.push({
156+
id: 'ping',
157+
name: 'Ping',
158+
description: 'Server responds to ping requests',
159+
status: 'FAILURE',
160+
timestamp: new Date().toISOString(),
161+
errorMessage: `Failed: ${error instanceof Error ? error.message : String(error)}`,
162+
specReferences: [
163+
{
164+
id: 'MCP-Ping',
165+
url: 'https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/ping'
166+
}
167+
]
168+
});
169+
}
170+
171+
return checks;
172+
}
173+
}
174+
86175
export class CompletionCompleteScenario implements ClientScenario {
87176
name = 'completion-complete';
88177
description = `Test completion endpoint.

0 commit comments

Comments
 (0)