Skip to content

Commit 08bef0f

Browse files
docs(examples): annotate runServerFromArgs / connectFromArgs at every call site
One comment line above each harness helper call so a reader landing on any story file immediately sees what the helper abstracts and what they'd write in their own server/client (serveStdio/createMcpHandler; new Client + transport.connect). 14 server.ts call sites + 15 client.ts files. (#2325)
1 parent 5794111 commit 08bef0f

29 files changed

Lines changed: 29 additions & 0 deletions

File tree

examples/caching/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface Cacheable {
1212
}
1313

1414
runClient('caching', async () => {
15+
// connectFromArgs picks transport (default: spawn ./server.ts over stdio; --http <url>) and era (--legacy) from argv. Your code would construct a Client and connect over your chosen transport directly.
1516
const client = await connectFromArgs(import.meta.dirname);
1617
check.equal(client.getNegotiatedProtocolVersion(), '2026-07-28');
1718

examples/caching/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ function buildServer(): McpServer {
4949
return server;
5050
}
5151

52+
// runServerFromArgs is the example harness's transport selector (default stdio, --http for HTTP). In your own server you'd call serveStdio(buildServer) or createMcpHandler(buildServer) directly.
5253
runServerFromArgs(buildServer);

examples/custom-methods/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ runClient('custom-methods', async () => {
1616
// Custom methods carry no envelope semantics — connect as a plain 2025
1717
// client so the request reaches the server's setRequestHandler exactly as
1818
// a hand-wired stdio client would.
19+
// connectFromArgs picks transport (default: spawn ./server.ts over stdio; --http <url>) and era (--legacy) from argv. Your code would construct a Client and connect over your chosen transport directly.
1920
const client = await connectFromArgs(import.meta.dirname, { versionNegotiation: undefined });
2021

2122
const stages: string[] = [];

examples/custom-methods/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ function buildServer(): McpServer {
2525
return mcp;
2626
}
2727

28+
// runServerFromArgs is the example harness's transport selector (default stdio, --http for HTTP). In your own server you'd call serveStdio(buildServer) or createMcpHandler(buildServer) directly.
2829
runServerFromArgs(buildServer);

examples/custom-version/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { check, connectFromArgs, runClient } from '../harness.js';
77
runClient('custom-version', async () => {
88
// A plain (2025-handshake) client; the server supports the SDK's stock
99
// 2025 version so this negotiates that.
10+
// connectFromArgs picks transport (default: spawn ./server.ts over stdio; --http <url>) and era (--legacy) from argv. Your code would construct a Client and connect over your chosen transport directly.
1011
const client = await connectFromArgs(import.meta.dirname, { versionNegotiation: undefined });
1112

1213
// The server should advertise its supportedProtocolVersions in its

examples/custom-version/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ function buildServer(): McpServer {
2323
return server;
2424
}
2525

26+
// runServerFromArgs is the example harness's transport selector (default stdio, --http for HTTP). In your own server you'd call serveStdio(buildServer) or createMcpHandler(buildServer) directly.
2627
runServerFromArgs(buildServer);

examples/dual-era/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { check, connectFromArgs, runClient } from '../harness.js';
1616

1717
runClient('dual-era', async () => {
1818
// --- leg 1: plain 2025 client (initialize handshake) ---
19+
// connectFromArgs picks transport (default: spawn ./server.ts over stdio; --http <url>) and era (--legacy) from argv. Your code would construct a Client and connect over your chosen transport directly.
1920
const legacy = await connectFromArgs(import.meta.dirname, { versionNegotiation: undefined });
2021
const legacyTools = await legacy.listTools();
2122
check.ok(legacyTools.tools.some(t => t.name === 'greet'));

examples/dual-era/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ const buildServer = (ctx: McpRequestContext) => {
4040
return server;
4141
};
4242

43+
// runServerFromArgs is the example harness's transport selector (default stdio, --http for HTTP). In your own server you'd call serveStdio(buildServer) or createMcpHandler(buildServer) directly.
4344
runServerFromArgs(buildServer);

examples/elicitation-form/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ runClient('elicitation-form', async () => {
99
// multi-round-trip `inputRequired` instead — see ../mrtr/). The harness
1010
// pins this story to the legacy era so `ctx.mcpReq.elicitInput` reaches
1111
// this handler.
12+
// connectFromArgs picks transport (default: spawn ./server.ts over stdio; --http <url>) and era (--legacy) from argv. Your code would construct a Client and connect over your chosen transport directly.
1213
const client = await connectFromArgs(import.meta.dirname, { capabilities: { elicitation: { form: {} } } });
1314

1415
let action: 'accept' | 'decline' = 'accept';

examples/elicitation-form/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ function buildServer(): McpServer {
3737
return server;
3838
}
3939

40+
// runServerFromArgs is the example harness's transport selector (default stdio, --http for HTTP). In your own server you'd call serveStdio(buildServer) or createMcpHandler(buildServer) directly.
4041
runServerFromArgs(buildServer);

0 commit comments

Comments
 (0)