Skip to content

Commit 85bd7b9

Browse files
olaservoclaude
andcommitted
feat(everything): serve both protocol eras on SDK v2 (2026-07-28 + legacy)
Migrates the everything server to the v2 scoped SDK packages (@modelcontextprotocol/server, /node, /core, /server-legacy at 2.0.0-beta.5) and adds support for protocol revision 2026-07-28 alongside the existing legacy revisions (2024-10-07 through 2025-11-25). Transports now hand the server factory to an SDK serving entry rather than constructing an instance and connecting a transport: - stdio: serveStdio(factory) serves both eras; the opening exchange selects one (server/discover probe vs. initialize handshake). - streamableHttp: createMcpHandler(factory) + toNodeHandler serves both eras from one endpoint. The session map, mcp-session-id plumbing, InMemoryEventStore/Last-Event-ID replay, and hand-written GET/DELETE routes are all removed - 2026-07-28 has no protocol-level sessions and no SSE resumability, and subscriptions/listen replaces the standalone GET stream. - sse: unchanged in behaviour, now explicitly legacy-only via server-legacy. Tools are written once and served to both eras. Those needing client input return inputRequired(...) instead of pushing a server->client request; the SDK's legacy shim converts the same return into real server->client requests for legacy clients, so no tool branches on ctx.era. Notable behaviour changes: - registerConditionalTools is gone. 2026-07-28 has no handshake to learn capabilities from, capabilities are per-request, and tools/list may not vary per connection. Tools register unconditionally and the SDK refuses a caller lacking a capability at dispatch with -32021, as the spec requires. - trigger-{sampling,elicitation}-request-async removed: they polled the client's task endpoints, and 2026-07-28 removed the server->client channel with no successor. - trigger-url-elicitation drops the -32042 error path and its session-keyed dedupe, both legacy-only by construction. - simulate-research-query is no longer task-based. SDK v2 removed the experimental tasks layer and the redesigned extension cannot be served through the SDK; the tool keeps its staged progress and mid-flight elicitation as a multi-round-trip flow, threading state through an HMAC-sealed requestState. - toggle-simulated-logging is legacy-only and documented as such: it models a connection-scoped log stream, which 2026-07-28 removed. Also adds cache hints for the cacheable list surfaces and requestState verification, and updates all seven docs plus the README. Requires Node.js >= 20 and is ESM-only, inherited from SDK v2. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent d31124c commit 85bd7b9

53 files changed

Lines changed: 1945 additions & 2476 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎package-lock.json‎

Lines changed: 77 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/everything/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@
99

1010
This MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.
1111

12+
## Protocol support
13+
14+
The server is **dual-era** — one codebase serving both protocol generations, so a client
15+
can be exercised against either without changing servers:
16+
17+
| Era | Revisions | Negotiated by |
18+
| ---------- | ---------------------------- | --------------------------------------------------- |
19+
| **legacy** | `2024-10-07` … `2025-11-25` | the `initialize` handshake |
20+
| **modern** | `2026-07-28` and later | a [`server/discover`](https://modelcontextprotocol.io/specification/draft/server/discover) probe |
21+
22+
Both `stdio` and `streamableHttp` serve either era; `streamableHttp` does it from a single
23+
endpoint. The deprecated `sse` transport is legacy-only. See
24+
[Architecture](docs/architecture.md) for what actually differs between them, and
25+
[Server Features](docs/features.md) for how the tools behave on each.
26+
27+
Requires **Node.js >= 20** and is ESM-only, inherited from the v2 SDK
28+
(`@modelcontextprotocol/server`).
29+
1230
## Tools, Resources, Prompts, and Other Features
1331

1432
A complete list of the registered MCP primitives and other protocol features demonstrated can be found in the [Server Features](docs/features.md) document.

‎src/everything/__tests__/prompts.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, vi } from 'vitest';
2-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2+
import { McpServer } from '@modelcontextprotocol/server';
33
import { registerSimplePrompt } from '../prompts/simple.js';
44
import { registerArgumentsPrompt } from '../prompts/args.js';
55
import { registerPromptWithCompletions } from '../prompts/completions.js';

‎src/everything/__tests__/registrations.test.ts‎

Lines changed: 59 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { describe, it, expect, vi } from 'vitest';
2-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
1+
import { describe, it, expect, vi } from "vitest";
2+
import { McpServer } from "@modelcontextprotocol/server";
33

44
// Create mock server
55
function createMockServer() {
@@ -16,139 +16,100 @@ function createMockServer() {
1616
} as unknown as McpServer;
1717
}
1818

19-
describe('Registration Index Files', () => {
20-
describe('tools/index.ts', () => {
21-
it('should register all standard tools', async () => {
22-
const { registerTools } = await import('../tools/index.js');
19+
describe("Registration Index Files", () => {
20+
describe("tools/index.ts", () => {
21+
it("should register all tools unconditionally", async () => {
22+
const { registerTools } = await import("../tools/index.js");
2323
const mockServer = createMockServer();
2424

2525
registerTools(mockServer);
2626

27-
// Should register 12 standard tools (non-conditional)
28-
expect(mockServer.registerTool).toHaveBeenCalledTimes(12);
27+
// Every tool registers up front. There is no capability-gated second
28+
// pass any more: tools needing elicitation / sampling / roots return
29+
// `inputRequired(...)`, and the SDK refuses the embedded request with
30+
// `-32021` at dispatch when the caller lacks the capability -- on both
31+
// eras. Note the mock advertises NO client capabilities, and the
32+
// capability-gated tools are still expected below.
33+
expect(mockServer.registerTool).toHaveBeenCalledTimes(17);
2934

3035
// Verify specific tools are registered
3136
const registeredTools = (mockServer.registerTool as any).mock.calls.map(
3237
(call: any[]) => call[0]
3338
);
34-
expect(registeredTools).toContain('echo');
35-
expect(registeredTools).toContain('get-sum');
36-
expect(registeredTools).toContain('get-env');
37-
expect(registeredTools).toContain('get-tiny-image');
38-
expect(registeredTools).toContain('get-structured-content');
39-
expect(registeredTools).toContain('get-annotated-message');
40-
expect(registeredTools).toContain('trigger-long-running-operation');
41-
expect(registeredTools).toContain('get-resource-links');
42-
expect(registeredTools).toContain('get-resource-reference');
43-
expect(registeredTools).toContain('gzip-file-as-resource');
44-
expect(registeredTools).toContain('toggle-simulated-logging');
45-
expect(registeredTools).toContain('toggle-subscriber-updates');
39+
expect(registeredTools).toContain("echo");
40+
expect(registeredTools).toContain("get-sum");
41+
expect(registeredTools).toContain("get-env");
42+
expect(registeredTools).toContain("get-tiny-image");
43+
expect(registeredTools).toContain("get-structured-content");
44+
expect(registeredTools).toContain("get-annotated-message");
45+
expect(registeredTools).toContain("trigger-long-running-operation");
46+
expect(registeredTools).toContain("get-resource-links");
47+
expect(registeredTools).toContain("get-resource-reference");
48+
expect(registeredTools).toContain("gzip-file-as-resource");
49+
expect(registeredTools).toContain("toggle-simulated-logging");
50+
expect(registeredTools).toContain("toggle-subscriber-updates");
51+
52+
// Formerly "conditional" tools -- now registered up front.
53+
expect(registeredTools).toContain("get-roots-list");
54+
expect(registeredTools).toContain("trigger-elicitation-request");
55+
expect(registeredTools).toContain("trigger-url-elicitation");
56+
expect(registeredTools).toContain("trigger-sampling-request");
57+
58+
// Formerly registered through the experimental tasks API, now an
59+
// ordinary multi-round-trip tool.
60+
expect(registeredTools).toContain("simulate-research-query");
4661
});
4762

48-
it('should register conditional tools based on capabilities', async () => {
49-
const { registerConditionalTools } = await import('../tools/index.js');
50-
51-
// Server with all capabilities including experimental tasks API
52-
const mockServerWithCapabilities = {
53-
registerTool: vi.fn(),
54-
server: {
55-
getClientCapabilities: vi.fn(() => ({
56-
roots: {},
57-
elicitation: { url: {} },
58-
sampling: {},
59-
})),
60-
},
61-
experimental: {
62-
tasks: {
63-
registerToolTask: vi.fn(),
64-
},
65-
},
66-
} as unknown as McpServer;
67-
68-
registerConditionalTools(mockServerWithCapabilities);
69-
70-
// Should register 4 conditional tools via registerTool when all capabilities
71-
// are present. Task-based tools register via registerToolTask (counted separately),
72-
// so they are not included in this registerTool count.
73-
expect(mockServerWithCapabilities.registerTool).toHaveBeenCalledTimes(4);
74-
75-
const registeredTools = (
76-
mockServerWithCapabilities.registerTool as any
77-
).mock.calls.map((call: any[]) => call[0]);
78-
expect(registeredTools).toContain('get-roots-list');
79-
expect(registeredTools).toContain('trigger-elicitation-request');
80-
expect(registeredTools).toContain('trigger-url-elicitation');
81-
expect(registeredTools).toContain('trigger-sampling-request');
82-
83-
// Task-based tools are registered via experimental.tasks.registerToolTask
84-
expect(mockServerWithCapabilities.experimental.tasks.registerToolTask).toHaveBeenCalled();
85-
});
63+
it("should not expose a separate conditional registration pass", async () => {
64+
const toolsIndex = await import("../tools/index.js");
8665

87-
it('should not register conditional tools when capabilities missing', async () => {
88-
const { registerConditionalTools } = await import('../tools/index.js');
89-
90-
const mockServerNoCapabilities = {
91-
registerTool: vi.fn(),
92-
server: {
93-
getClientCapabilities: vi.fn(() => ({})),
94-
},
95-
experimental: {
96-
tasks: {
97-
registerToolTask: vi.fn(),
98-
},
99-
},
100-
} as unknown as McpServer;
101-
102-
registerConditionalTools(mockServerNoCapabilities);
103-
104-
// Should not register any capability-gated tools when capabilities are missing
105-
expect(mockServerNoCapabilities.registerTool).not.toHaveBeenCalled();
66+
expect("registerConditionalTools" in toolsIndex).toBe(false);
10667
});
10768
});
10869

109-
describe('prompts/index.ts', () => {
110-
it('should register all prompts', async () => {
111-
const { registerPrompts } = await import('../prompts/index.js');
70+
describe("prompts/index.ts", () => {
71+
it("should register all prompts", async () => {
72+
const { registerPrompts } = await import("../prompts/index.js");
11273
const mockServer = createMockServer();
11374

11475
registerPrompts(mockServer);
11576

11677
// Should register 4 prompts
11778
expect(mockServer.registerPrompt).toHaveBeenCalledTimes(4);
11879

119-
const registeredPrompts = (mockServer.registerPrompt as any).mock.calls.map(
120-
(call: any[]) => call[0]
121-
);
122-
expect(registeredPrompts).toContain('simple-prompt');
123-
expect(registeredPrompts).toContain('args-prompt');
124-
expect(registeredPrompts).toContain('completable-prompt');
125-
expect(registeredPrompts).toContain('resource-prompt');
80+
const registeredPrompts = (
81+
mockServer.registerPrompt as any
82+
).mock.calls.map((call: any[]) => call[0]);
83+
expect(registeredPrompts).toContain("simple-prompt");
84+
expect(registeredPrompts).toContain("args-prompt");
85+
expect(registeredPrompts).toContain("completable-prompt");
86+
expect(registeredPrompts).toContain("resource-prompt");
12687
});
12788
});
12889

129-
describe('resources/index.ts', () => {
130-
it('should register resource templates', async () => {
131-
const { registerResources } = await import('../resources/index.js');
90+
describe("resources/index.ts", () => {
91+
it("should register resource templates", async () => {
92+
const { registerResources } = await import("../resources/index.js");
13293
const mockServer = createMockServer();
13394

13495
registerResources(mockServer);
13596

13697
// Should register at least the 2 resource templates (text and blob) plus file resources
13798
expect(mockServer.registerResource).toHaveBeenCalled();
138-
const registeredResources = (mockServer.registerResource as any).mock.calls.map(
139-
(call: any[]) => call[0]
140-
);
141-
expect(registeredResources).toContain('Dynamic Text Resource');
142-
expect(registeredResources).toContain('Dynamic Blob Resource');
99+
const registeredResources = (
100+
mockServer.registerResource as any
101+
).mock.calls.map((call: any[]) => call[0]);
102+
expect(registeredResources).toContain("Dynamic Text Resource");
103+
expect(registeredResources).toContain("Dynamic Blob Resource");
143104
});
144105

145-
it('should read instructions from file', async () => {
146-
const { readInstructions } = await import('../resources/index.js');
106+
it("should read instructions from file", async () => {
107+
const { readInstructions } = await import("../resources/index.js");
147108

148109
const instructions = readInstructions();
149110

150111
// Should return a string (either content or error message)
151-
expect(typeof instructions).toBe('string');
112+
expect(typeof instructions).toBe("string");
152113
expect(instructions.length).toBeGreaterThan(0);
153114
});
154115
});

‎src/everything/__tests__/resources.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2-
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
2+
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/server';
33
import {
44
textResource,
55
blobResource,

0 commit comments

Comments
 (0)