@modelcontextprotocol/server-everything 2025.4.28 → 2025.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -2
- package/dist/everything.js +10 -3
- package/dist/index.js +34 -16
- package/dist/instructions.md +13 -0
- package/dist/sse.js +33 -13
- package/dist/stdio.js +19 -0
- package/dist/streamableHttp.js +27 -27
- package/package.json +3 -3
package/README.md
CHANGED
@@ -173,7 +173,7 @@ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace
|
|
173
173
|
}
|
174
174
|
```
|
175
175
|
|
176
|
-
##
|
176
|
+
## Running from source with [HTTP+SSE Transport](https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse) (deprecated as of [2025-03-26](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports))
|
177
177
|
|
178
178
|
```shell
|
179
179
|
cd src/everything
|
@@ -181,10 +181,37 @@ npm install
|
|
181
181
|
npm run start:sse
|
182
182
|
```
|
183
183
|
|
184
|
-
## Run with [Streamable HTTP Transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http)
|
184
|
+
## Run from source with [Streamable HTTP Transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http)
|
185
185
|
|
186
186
|
```shell
|
187
187
|
cd src/everything
|
188
188
|
npm install
|
189
189
|
npm run start:streamableHttp
|
190
190
|
```
|
191
|
+
|
192
|
+
## Running as an installed package
|
193
|
+
### Install
|
194
|
+
```shell
|
195
|
+
npm install -g @modelcontextprotocol/server-everything@latest
|
196
|
+
````
|
197
|
+
|
198
|
+
### Run the default (stdio) server
|
199
|
+
```shell
|
200
|
+
npx @modelcontextprotocol/server-everything
|
201
|
+
```
|
202
|
+
|
203
|
+
### Or specify stdio explicitly
|
204
|
+
```shell
|
205
|
+
npx @modelcontextprotocol/server-everything stdio
|
206
|
+
```
|
207
|
+
|
208
|
+
### Run the SSE server
|
209
|
+
```shell
|
210
|
+
npx @modelcontextprotocol/server-everything sse
|
211
|
+
```
|
212
|
+
|
213
|
+
### Run the streamable HTTP server
|
214
|
+
```shell
|
215
|
+
npx @modelcontextprotocol/server-everything streamableHttp
|
216
|
+
```
|
217
|
+
|
package/dist/everything.js
CHANGED
@@ -2,6 +2,12 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import { CallToolRequestSchema, CompleteRequestSchema, CreateMessageResultSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, SetLevelRequestSchema, SubscribeRequestSchema, ToolSchema, UnsubscribeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
3
3
|
import { z } from "zod";
|
4
4
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
5
|
+
import { readFileSync } from "fs";
|
6
|
+
import { fileURLToPath } from "url";
|
7
|
+
import { dirname, join } from "path";
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
9
|
+
const __dirname = dirname(__filename);
|
10
|
+
const instructions = readFileSync(join(__dirname, "instructions.md"), "utf-8");
|
5
11
|
const ToolInputSchema = ToolSchema.shape.inputSchema;
|
6
12
|
/* Input schemas for tools implemented in this server */
|
7
13
|
const EchoSchema = z.object({
|
@@ -78,6 +84,7 @@ export const createServer = () => {
|
|
78
84
|
logging: {},
|
79
85
|
completions: {},
|
80
86
|
},
|
87
|
+
instructions
|
81
88
|
});
|
82
89
|
let subscriptions = new Set();
|
83
90
|
let subsUpdateInterval;
|
@@ -120,9 +127,9 @@ export const createServer = () => {
|
|
120
127
|
// Set up update interval for stderr messages
|
121
128
|
stdErrUpdateInterval = setInterval(() => {
|
122
129
|
const shortTimestamp = new Date().toLocaleTimeString([], {
|
123
|
-
hour:
|
124
|
-
minute:
|
125
|
-
second:
|
130
|
+
hour: "2-digit",
|
131
|
+
minute: "2-digit",
|
132
|
+
second: "2-digit"
|
126
133
|
});
|
127
134
|
server.notification({
|
128
135
|
method: "notifications/stderr",
|
package/dist/index.js
CHANGED
@@ -1,18 +1,36 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
// Parse command line arguments first
|
3
|
+
const args = process.argv.slice(2);
|
4
|
+
const scriptName = args[0] || 'stdio';
|
5
|
+
async function run() {
|
6
|
+
try {
|
7
|
+
// Dynamically import only the requested module to prevent all modules from initializing
|
8
|
+
switch (scriptName) {
|
9
|
+
case 'stdio':
|
10
|
+
// Import and run the default server
|
11
|
+
await import('./stdio.js');
|
12
|
+
break;
|
13
|
+
case 'sse':
|
14
|
+
// Import and run the SSE server
|
15
|
+
await import('./sse.js');
|
16
|
+
break;
|
17
|
+
case 'streamableHttp':
|
18
|
+
// Import and run the streamable HTTP server
|
19
|
+
await import('./streamableHttp.js');
|
20
|
+
break;
|
21
|
+
default:
|
22
|
+
console.error(`Unknown script: ${scriptName}`);
|
23
|
+
console.log('Available scripts:');
|
24
|
+
console.log('- stdio');
|
25
|
+
console.log('- sse');
|
26
|
+
console.log('- streamableHttp');
|
27
|
+
process.exit(1);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
catch (error) {
|
31
|
+
console.error('Error running script:', error);
|
32
|
+
process.exit(1);
|
33
|
+
}
|
14
34
|
}
|
15
|
-
|
16
|
-
|
17
|
-
process.exit(1);
|
18
|
-
});
|
35
|
+
run();
|
36
|
+
export {};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Testing and demonstration server for MCP protocol features.
|
2
|
+
|
3
|
+
Resources: Resources 1-100 follow pattern: even IDs contain text, odd IDs contain binary data. Resources paginated at 10 items per page with cursor-based navigation.
|
4
|
+
|
5
|
+
Key dependencies: Progress notifications require `_meta.progressToken` in tool calls. Resource subscriptions generate updates every 10 seconds.
|
6
|
+
|
7
|
+
Performance characteristics: Server generates automatic log messages every 20 seconds (filtered by current log level), stderr notifications every 30 seconds, and resource update notifications every 10 seconds for active subscriptions. Log level changes affect message filtering in real-time.
|
8
|
+
|
9
|
+
Multi-modal testing: `complex_prompt` includes both text arguments and image content for testing client multi-modal handling. `resource_prompt` embeds actual resource content for testing resource reference resolution.
|
10
|
+
|
11
|
+
Argument completion available for prompt parameters and resource IDs. Resource templates enable dynamic URI construction via `test://static/resource/{id}` pattern.
|
12
|
+
|
13
|
+
Easter egg: If asked about server instructions, respond with "🎉 Server instructions are working! This response proves the client properly passed server instructions to the LLM. This demonstrates MCP's instructions feature in action."
|
package/dist/sse.js
CHANGED
@@ -1,24 +1,44 @@
|
|
1
1
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
2
2
|
import express from "express";
|
3
3
|
import { createServer } from "./everything.js";
|
4
|
+
console.error('Starting SSE server...');
|
4
5
|
const app = express();
|
5
|
-
const
|
6
|
-
let transport;
|
6
|
+
const transports = new Map();
|
7
7
|
app.get("/sse", async (req, res) => {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
let transport;
|
9
|
+
const { server, cleanup } = createServer();
|
10
|
+
if (req?.query?.sessionId) {
|
11
|
+
const sessionId = req?.query?.sessionId;
|
12
|
+
transport = transports.get(sessionId);
|
13
|
+
console.error("Client Reconnecting? This shouldn't happen; when client has a sessionId, GET /sse should not be called again.", transport.sessionId);
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
// Create and store transport for new session
|
17
|
+
transport = new SSEServerTransport("/message", res);
|
18
|
+
transports.set(transport.sessionId, transport);
|
19
|
+
// Connect server to transport
|
20
|
+
await server.connect(transport);
|
21
|
+
console.error("Client Connected: ", transport.sessionId);
|
22
|
+
// Handle close of connection
|
23
|
+
server.onclose = async () => {
|
24
|
+
console.error("Client Disconnected: ", transport.sessionId);
|
25
|
+
transports.delete(transport.sessionId);
|
26
|
+
await cleanup();
|
27
|
+
};
|
28
|
+
}
|
16
29
|
});
|
17
30
|
app.post("/message", async (req, res) => {
|
18
|
-
|
19
|
-
|
31
|
+
const sessionId = req?.query?.sessionId;
|
32
|
+
const transport = transports.get(sessionId);
|
33
|
+
if (transport) {
|
34
|
+
console.error("Client Message from", sessionId);
|
35
|
+
await transport.handlePostMessage(req, res);
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
console.error(`No transport found for sessionId ${sessionId}`);
|
39
|
+
}
|
20
40
|
});
|
21
41
|
const PORT = process.env.PORT || 3001;
|
22
42
|
app.listen(PORT, () => {
|
23
|
-
console.
|
43
|
+
console.error(`Server is running on port ${PORT}`);
|
24
44
|
});
|
package/dist/stdio.js
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
3
|
+
import { createServer } from "./everything.js";
|
4
|
+
console.error('Starting default (STDIO) server...');
|
5
|
+
async function main() {
|
6
|
+
const transport = new StdioServerTransport();
|
7
|
+
const { server, cleanup } = createServer();
|
8
|
+
await server.connect(transport);
|
9
|
+
// Cleanup on exit
|
10
|
+
process.on("SIGINT", async () => {
|
11
|
+
await cleanup();
|
12
|
+
await server.close();
|
13
|
+
process.exit(0);
|
14
|
+
});
|
15
|
+
}
|
16
|
+
main().catch((error) => {
|
17
|
+
console.error("Server error:", error);
|
18
|
+
process.exit(1);
|
19
|
+
});
|
package/dist/streamableHttp.js
CHANGED
@@ -3,20 +3,21 @@ import { InMemoryEventStore } from '@modelcontextprotocol/sdk/examples/shared/in
|
|
3
3
|
import express from "express";
|
4
4
|
import { createServer } from "./everything.js";
|
5
5
|
import { randomUUID } from 'node:crypto';
|
6
|
+
console.error('Starting Streamable HTTP server...');
|
6
7
|
const app = express();
|
7
|
-
const
|
8
|
-
const transports = {};
|
8
|
+
const transports = new Map();
|
9
9
|
app.post('/mcp', async (req, res) => {
|
10
|
-
console.
|
10
|
+
console.error('Received MCP POST request');
|
11
11
|
try {
|
12
12
|
// Check for existing session ID
|
13
13
|
const sessionId = req.headers['mcp-session-id'];
|
14
14
|
let transport;
|
15
|
-
if (sessionId && transports
|
15
|
+
if (sessionId && transports.has(sessionId)) {
|
16
16
|
// Reuse existing transport
|
17
|
-
transport = transports
|
17
|
+
transport = transports.get(sessionId);
|
18
18
|
}
|
19
19
|
else if (!sessionId) {
|
20
|
+
const { server, cleanup } = createServer();
|
20
21
|
// New initialization request
|
21
22
|
const eventStore = new InMemoryEventStore();
|
22
23
|
transport = new StreamableHTTPServerTransport({
|
@@ -25,16 +26,17 @@ app.post('/mcp', async (req, res) => {
|
|
25
26
|
onsessioninitialized: (sessionId) => {
|
26
27
|
// Store the transport by session ID when session is initialized
|
27
28
|
// This avoids race conditions where requests might come in before the session is stored
|
28
|
-
console.
|
29
|
-
transports
|
29
|
+
console.error(`Session initialized with ID: ${sessionId}`);
|
30
|
+
transports.set(sessionId, transport);
|
30
31
|
}
|
31
32
|
});
|
32
33
|
// Set up onclose handler to clean up transport when closed
|
33
|
-
|
34
|
+
server.onclose = async () => {
|
34
35
|
const sid = transport.sessionId;
|
35
|
-
if (sid && transports
|
36
|
-
console.
|
37
|
-
delete
|
36
|
+
if (sid && transports.has(sid)) {
|
37
|
+
console.error(`Transport closed for session ${sid}, removing from transports map`);
|
38
|
+
transports.delete(sid);
|
39
|
+
await cleanup();
|
38
40
|
}
|
39
41
|
};
|
40
42
|
// Connect the transport to the MCP server BEFORE handling the request
|
@@ -76,9 +78,9 @@ app.post('/mcp', async (req, res) => {
|
|
76
78
|
});
|
77
79
|
// Handle GET requests for SSE streams (using built-in support from StreamableHTTP)
|
78
80
|
app.get('/mcp', async (req, res) => {
|
79
|
-
console.
|
81
|
+
console.error('Received MCP GET request');
|
80
82
|
const sessionId = req.headers['mcp-session-id'];
|
81
|
-
if (!sessionId || !transports
|
83
|
+
if (!sessionId || !transports.has(sessionId)) {
|
82
84
|
res.status(400).json({
|
83
85
|
jsonrpc: '2.0',
|
84
86
|
error: {
|
@@ -92,18 +94,18 @@ app.get('/mcp', async (req, res) => {
|
|
92
94
|
// Check for Last-Event-ID header for resumability
|
93
95
|
const lastEventId = req.headers['last-event-id'];
|
94
96
|
if (lastEventId) {
|
95
|
-
console.
|
97
|
+
console.error(`Client reconnecting with Last-Event-ID: ${lastEventId}`);
|
96
98
|
}
|
97
99
|
else {
|
98
|
-
console.
|
100
|
+
console.error(`Establishing new SSE stream for session ${sessionId}`);
|
99
101
|
}
|
100
|
-
const transport = transports
|
102
|
+
const transport = transports.get(sessionId);
|
101
103
|
await transport.handleRequest(req, res);
|
102
104
|
});
|
103
105
|
// Handle DELETE requests for session termination (according to MCP spec)
|
104
106
|
app.delete('/mcp', async (req, res) => {
|
105
107
|
const sessionId = req.headers['mcp-session-id'];
|
106
|
-
if (!sessionId || !transports
|
108
|
+
if (!sessionId || !transports.has(sessionId)) {
|
107
109
|
res.status(400).json({
|
108
110
|
jsonrpc: '2.0',
|
109
111
|
error: {
|
@@ -114,9 +116,9 @@ app.delete('/mcp', async (req, res) => {
|
|
114
116
|
});
|
115
117
|
return;
|
116
118
|
}
|
117
|
-
console.
|
119
|
+
console.error(`Received session termination request for session ${sessionId}`);
|
118
120
|
try {
|
119
|
-
const transport = transports
|
121
|
+
const transport = transports.get(sessionId);
|
120
122
|
await transport.handleRequest(req, res);
|
121
123
|
}
|
122
124
|
catch (error) {
|
@@ -137,24 +139,22 @@ app.delete('/mcp', async (req, res) => {
|
|
137
139
|
// Start the server
|
138
140
|
const PORT = process.env.PORT || 3001;
|
139
141
|
app.listen(PORT, () => {
|
140
|
-
console.
|
142
|
+
console.error(`MCP Streamable HTTP Server listening on port ${PORT}`);
|
141
143
|
});
|
142
144
|
// Handle server shutdown
|
143
145
|
process.on('SIGINT', async () => {
|
144
|
-
console.
|
146
|
+
console.error('Shutting down server...');
|
145
147
|
// Close all active transports to properly clean up resources
|
146
148
|
for (const sessionId in transports) {
|
147
149
|
try {
|
148
|
-
console.
|
149
|
-
await transports
|
150
|
-
delete
|
150
|
+
console.error(`Closing transport for session ${sessionId}`);
|
151
|
+
await transports.get(sessionId).close();
|
152
|
+
transports.delete(sessionId);
|
151
153
|
}
|
152
154
|
catch (error) {
|
153
155
|
console.error(`Error closing transport for session ${sessionId}:`, error);
|
154
156
|
}
|
155
157
|
}
|
156
|
-
|
157
|
-
await server.close();
|
158
|
-
console.log('Server shutdown complete');
|
158
|
+
console.error('Server shutdown complete');
|
159
159
|
process.exit(0);
|
160
160
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@modelcontextprotocol/server-everything",
|
3
|
-
"version": "2025.
|
3
|
+
"version": "2025.7.1",
|
4
4
|
"description": "MCP server that exercises all the features of the MCP protocol",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Anthropic, PBC (https://anthropic.com)",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"dist"
|
15
15
|
],
|
16
16
|
"scripts": {
|
17
|
-
"build": "tsc && shx chmod +x dist/*.js",
|
17
|
+
"build": "tsc && shx cp instructions.md dist/ && shx chmod +x dist/*.js",
|
18
18
|
"prepare": "npm run build",
|
19
19
|
"watch": "tsc --watch",
|
20
20
|
"start": "node dist/index.js",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"start:streamableHttp": "node dist/streamableHttp.js"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@modelcontextprotocol/sdk": "^1.
|
25
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
26
26
|
"express": "^4.21.1",
|
27
27
|
"zod": "^3.23.8",
|
28
28
|
"zod-to-json-schema": "^3.23.5"
|