@modelcontextprotocol/server-everything 2025.8.18 → 2025.9.12
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 +20 -1
- package/dist/everything.js +143 -48
- package/dist/sse.js +1 -1
- package/dist/stdio.js +2 -1
- package/dist/streamableHttp.js +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
@@ -89,6 +89,13 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is
|
|
89
89
|
- `structuredContent` field conformant to the output schema
|
90
90
|
- A backward compatible Text Content field, a SHOULD advisory in the specification
|
91
91
|
|
92
|
+
11. `listRoots`
|
93
|
+
- Lists the current MCP roots provided by the client
|
94
|
+
- Demonstrates the roots protocol capability even though this server doesn't access files
|
95
|
+
- No inputs required
|
96
|
+
- Returns: List of current roots with their URIs and names, or a message if no roots are set
|
97
|
+
- Shows how servers can interact with the MCP roots protocol
|
98
|
+
|
92
99
|
### Resources
|
93
100
|
|
94
101
|
The server provides 100 test resources in two formats:
|
@@ -117,7 +124,7 @@ Resource features:
|
|
117
124
|
2. `complex_prompt`
|
118
125
|
- Advanced prompt demonstrating argument handling
|
119
126
|
- Required arguments:
|
120
|
-
- `temperature` (
|
127
|
+
- `temperature` (string): Temperature setting
|
121
128
|
- Optional arguments:
|
122
129
|
- `style` (string): Output style preference
|
123
130
|
- Returns: Multi-turn conversation with images
|
@@ -129,6 +136,18 @@ Resource features:
|
|
129
136
|
- Returns: Multi-turn conversation with an embedded resource reference
|
130
137
|
- Shows how to include resources directly in prompt messages
|
131
138
|
|
139
|
+
### Roots
|
140
|
+
|
141
|
+
The server demonstrates the MCP roots protocol capability:
|
142
|
+
|
143
|
+
- Declares `roots: { listChanged: true }` capability to indicate support for roots
|
144
|
+
- Handles `roots/list_changed` notifications from clients
|
145
|
+
- Requests initial roots during server initialization
|
146
|
+
- Provides a `listRoots` tool to display current roots
|
147
|
+
- Logs roots-related events for demonstration purposes
|
148
|
+
|
149
|
+
Note: This server doesn't actually access files, but demonstrates how servers can interact with the roots protocol for clients that need to understand which directories are available for file operations.
|
150
|
+
|
132
151
|
### Logging
|
133
152
|
|
134
153
|
The server sends random-leveled log messages every 15 seconds, e.g.:
|
package/dist/everything.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
2
|
-
import { CallToolRequestSchema, CompleteRequestSchema, CreateMessageResultSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema,
|
2
|
+
import { CallToolRequestSchema, CompleteRequestSchema, CreateMessageResultSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, RootsListChangedNotificationSchema, SubscribeRequestSchema, ToolSchema, UnsubscribeRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
3
3
|
import { z } from "zod";
|
4
4
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
5
5
|
import { readFileSync } from "fs";
|
@@ -62,6 +62,7 @@ const GetResourceLinksSchema = z.object({
|
|
62
62
|
.default(3)
|
63
63
|
.describe("Number of resource links to return (1-10)"),
|
64
64
|
});
|
65
|
+
const ListRootsSchema = z.object({});
|
65
66
|
const StructuredContentSchema = {
|
66
67
|
input: z.object({
|
67
68
|
location: z
|
@@ -95,6 +96,7 @@ var ToolName;
|
|
95
96
|
ToolName["ELICITATION"] = "startElicitation";
|
96
97
|
ToolName["GET_RESOURCE_LINKS"] = "getResourceLinks";
|
97
98
|
ToolName["STRUCTURED_CONTENT"] = "structuredContent";
|
99
|
+
ToolName["LIST_ROOTS"] = "listRoots";
|
98
100
|
})(ToolName || (ToolName = {}));
|
99
101
|
var PromptName;
|
100
102
|
(function (PromptName) {
|
@@ -119,33 +121,23 @@ export const createServer = () => {
|
|
119
121
|
resources: { subscribe: true },
|
120
122
|
tools: {},
|
121
123
|
logging: {},
|
122
|
-
completions: {}
|
123
|
-
elicitation: {},
|
124
|
+
completions: {}
|
124
125
|
},
|
125
126
|
instructions
|
126
127
|
});
|
127
128
|
let subscriptions = new Set();
|
128
129
|
let subsUpdateInterval;
|
129
130
|
let stdErrUpdateInterval;
|
130
|
-
let logLevel = "debug";
|
131
131
|
let logsUpdateInterval;
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
{ level: "critical", data: "Critical-level message" },
|
139
|
-
{ level: "alert", data: "Alert level-message" },
|
140
|
-
{ level: "emergency", data: "Emergency-level message" },
|
141
|
-
];
|
142
|
-
const isMessageIgnored = (level) => {
|
143
|
-
const currentLevel = messages.findIndex((msg) => logLevel === msg.level);
|
144
|
-
const messageLevel = messages.findIndex((msg) => level === msg.level);
|
145
|
-
return messageLevel < currentLevel;
|
146
|
-
};
|
132
|
+
// Store client capabilities
|
133
|
+
let clientCapabilities;
|
134
|
+
// Roots state management
|
135
|
+
let currentRoots = [];
|
136
|
+
let clientSupportsRoots = false;
|
137
|
+
let sessionId;
|
147
138
|
// Function to start notification intervals when a client connects
|
148
|
-
const startNotificationIntervals = () => {
|
139
|
+
const startNotificationIntervals = (sid) => {
|
140
|
+
sessionId = sid;
|
149
141
|
if (!subsUpdateInterval) {
|
150
142
|
subsUpdateInterval = setInterval(() => {
|
151
143
|
for (const uri of subscriptions) {
|
@@ -156,15 +148,22 @@ export const createServer = () => {
|
|
156
148
|
}
|
157
149
|
}, 10000);
|
158
150
|
}
|
151
|
+
const maybeAppendSessionId = sessionId ? ` - SessionId ${sessionId}` : "";
|
152
|
+
const messages = [
|
153
|
+
{ level: "debug", data: `Debug-level message${maybeAppendSessionId}` },
|
154
|
+
{ level: "info", data: `Info-level message${maybeAppendSessionId}` },
|
155
|
+
{ level: "notice", data: `Notice-level message${maybeAppendSessionId}` },
|
156
|
+
{ level: "warning", data: `Warning-level message${maybeAppendSessionId}` },
|
157
|
+
{ level: "error", data: `Error-level message${maybeAppendSessionId}` },
|
158
|
+
{ level: "critical", data: `Critical-level message${maybeAppendSessionId}` },
|
159
|
+
{ level: "alert", data: `Alert level-message${maybeAppendSessionId}` },
|
160
|
+
{ level: "emergency", data: `Emergency-level message${maybeAppendSessionId}` },
|
161
|
+
];
|
159
162
|
if (!logsUpdateInterval) {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
};
|
165
|
-
if (!isMessageIgnored(message.params.level))
|
166
|
-
server.notification(message);
|
167
|
-
}, 20000);
|
163
|
+
console.error("Starting logs update interval");
|
164
|
+
logsUpdateInterval = setInterval(async () => {
|
165
|
+
await server.sendLoggingMessage(messages[Math.floor(Math.random() * messages.length)], sessionId);
|
166
|
+
}, 15000);
|
168
167
|
}
|
169
168
|
};
|
170
169
|
// Helper method to request sampling from client
|
@@ -425,11 +424,6 @@ export const createServer = () => {
|
|
425
424
|
description: "Returns a resource reference that can be used by MCP clients",
|
426
425
|
inputSchema: zodToJsonSchema(GetResourceReferenceSchema),
|
427
426
|
},
|
428
|
-
{
|
429
|
-
name: ToolName.ELICITATION,
|
430
|
-
description: "Demonstrates the Elicitation feature by asking the user to provide information about their favorite color, number, and pets.",
|
431
|
-
inputSchema: zodToJsonSchema(ElicitationSchema),
|
432
|
-
},
|
433
427
|
{
|
434
428
|
name: ToolName.GET_RESOURCE_LINKS,
|
435
429
|
description: "Returns multiple resource links that reference different types of resources",
|
@@ -442,9 +436,21 @@ export const createServer = () => {
|
|
442
436
|
outputSchema: zodToJsonSchema(StructuredContentSchema.output),
|
443
437
|
},
|
444
438
|
];
|
439
|
+
if (clientCapabilities.roots)
|
440
|
+
tools.push({
|
441
|
+
name: ToolName.LIST_ROOTS,
|
442
|
+
description: "Lists the current MCP roots provided by the client. Demonstrates the roots protocol capability even though this server doesn't access files.",
|
443
|
+
inputSchema: zodToJsonSchema(ListRootsSchema),
|
444
|
+
});
|
445
|
+
if (clientCapabilities.elicitation)
|
446
|
+
tools.push({
|
447
|
+
name: ToolName.ELICITATION,
|
448
|
+
description: "Demonstrates the Elicitation feature by asking the user to provide information about their favorite color, number, and pets.",
|
449
|
+
inputSchema: zodToJsonSchema(ElicitationSchema),
|
450
|
+
});
|
445
451
|
return { tools };
|
446
452
|
});
|
447
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
453
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
448
454
|
const { name, arguments: args } = request.params;
|
449
455
|
if (name === ToolName.ECHO) {
|
450
456
|
const validatedArgs = EchoSchema.parse(args);
|
@@ -479,7 +485,7 @@ export const createServer = () => {
|
|
479
485
|
total: steps,
|
480
486
|
progressToken,
|
481
487
|
},
|
482
|
-
});
|
488
|
+
}, { relatedRequestId: extra.requestId });
|
483
489
|
}
|
484
490
|
}
|
485
491
|
return {
|
@@ -692,6 +698,47 @@ export const createServer = () => {
|
|
692
698
|
structuredContent: weather
|
693
699
|
};
|
694
700
|
}
|
701
|
+
if (name === ToolName.LIST_ROOTS) {
|
702
|
+
ListRootsSchema.parse(args);
|
703
|
+
if (!clientSupportsRoots) {
|
704
|
+
return {
|
705
|
+
content: [
|
706
|
+
{
|
707
|
+
type: "text",
|
708
|
+
text: "The MCP client does not support the roots protocol.\n\n" +
|
709
|
+
"This means the server cannot access information about the client's workspace directories or file system roots."
|
710
|
+
}
|
711
|
+
]
|
712
|
+
};
|
713
|
+
}
|
714
|
+
if (currentRoots.length === 0) {
|
715
|
+
return {
|
716
|
+
content: [
|
717
|
+
{
|
718
|
+
type: "text",
|
719
|
+
text: "The client supports roots but no roots are currently configured.\n\n" +
|
720
|
+
"This could mean:\n" +
|
721
|
+
"1. The client hasn't provided any roots yet\n" +
|
722
|
+
"2. The client provided an empty roots list\n" +
|
723
|
+
"3. The roots configuration is still being loaded"
|
724
|
+
}
|
725
|
+
]
|
726
|
+
};
|
727
|
+
}
|
728
|
+
const rootsList = currentRoots.map((root, index) => {
|
729
|
+
return `${index + 1}. ${root.name || 'Unnamed Root'}\n URI: ${root.uri}`;
|
730
|
+
}).join('\n\n');
|
731
|
+
return {
|
732
|
+
content: [
|
733
|
+
{
|
734
|
+
type: "text",
|
735
|
+
text: `Current MCP Roots (${currentRoots.length} total):\n\n${rootsList}\n\n` +
|
736
|
+
"Note: This server demonstrates the roots protocol capability but doesn't actually access files. " +
|
737
|
+
"The roots are provided by the MCP client and can be used by servers that need file system access."
|
738
|
+
}
|
739
|
+
]
|
740
|
+
};
|
741
|
+
}
|
695
742
|
throw new Error(`Unknown tool: ${name}`);
|
696
743
|
});
|
697
744
|
server.setRequestHandler(CompleteRequestSchema, async (request) => {
|
@@ -714,20 +761,68 @@ export const createServer = () => {
|
|
714
761
|
}
|
715
762
|
throw new Error(`Unknown reference type`);
|
716
763
|
});
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
764
|
+
// Roots protocol handlers
|
765
|
+
server.setNotificationHandler(RootsListChangedNotificationSchema, async () => {
|
766
|
+
try {
|
767
|
+
// Request the updated roots list from the client
|
768
|
+
const response = await server.listRoots();
|
769
|
+
if (response && 'roots' in response) {
|
770
|
+
currentRoots = response.roots;
|
771
|
+
// Log the roots update for demonstration
|
772
|
+
await server.sendLoggingMessage({
|
773
|
+
level: "info",
|
774
|
+
logger: "everything-server",
|
775
|
+
data: `Roots updated: ${currentRoots.length} root(s) received from client`,
|
776
|
+
}, sessionId);
|
777
|
+
}
|
778
|
+
}
|
779
|
+
catch (error) {
|
780
|
+
await server.sendLoggingMessage({
|
781
|
+
level: "error",
|
782
|
+
logger: "everything-server",
|
783
|
+
data: `Failed to request roots from client: ${error instanceof Error ? error.message : String(error)}`,
|
784
|
+
}, sessionId);
|
785
|
+
}
|
730
786
|
});
|
787
|
+
// Handle post-initialization setup for roots
|
788
|
+
server.oninitialized = async () => {
|
789
|
+
clientCapabilities = server.getClientCapabilities();
|
790
|
+
if (clientCapabilities?.roots) {
|
791
|
+
clientSupportsRoots = true;
|
792
|
+
try {
|
793
|
+
const response = await server.listRoots();
|
794
|
+
if (response && 'roots' in response) {
|
795
|
+
currentRoots = response.roots;
|
796
|
+
await server.sendLoggingMessage({
|
797
|
+
level: "info",
|
798
|
+
logger: "everything-server",
|
799
|
+
data: `Initial roots received: ${currentRoots.length} root(s) from client`,
|
800
|
+
}, sessionId);
|
801
|
+
}
|
802
|
+
else {
|
803
|
+
await server.sendLoggingMessage({
|
804
|
+
level: "warning",
|
805
|
+
logger: "everything-server",
|
806
|
+
data: "Client returned no roots set",
|
807
|
+
}, sessionId);
|
808
|
+
}
|
809
|
+
}
|
810
|
+
catch (error) {
|
811
|
+
await server.sendLoggingMessage({
|
812
|
+
level: "error",
|
813
|
+
logger: "everything-server",
|
814
|
+
data: `Failed to request initial roots from client: ${error instanceof Error ? error.message : String(error)}`,
|
815
|
+
}, sessionId);
|
816
|
+
}
|
817
|
+
}
|
818
|
+
else {
|
819
|
+
await server.sendLoggingMessage({
|
820
|
+
level: "info",
|
821
|
+
logger: "everything-server",
|
822
|
+
data: "Client does not support MCP roots protocol",
|
823
|
+
}, sessionId);
|
824
|
+
}
|
825
|
+
};
|
731
826
|
const cleanup = async () => {
|
732
827
|
if (subsUpdateInterval)
|
733
828
|
clearInterval(subsUpdateInterval);
|
package/dist/sse.js
CHANGED
@@ -20,7 +20,7 @@ app.get("/sse", async (req, res) => {
|
|
20
20
|
await server.connect(transport);
|
21
21
|
console.error("Client Connected: ", transport.sessionId);
|
22
22
|
// Start notification intervals after client connects
|
23
|
-
startNotificationIntervals();
|
23
|
+
startNotificationIntervals(transport.sessionId);
|
24
24
|
// Handle close of connection
|
25
25
|
server.onclose = async () => {
|
26
26
|
console.error("Client Disconnected: ", transport.sessionId);
|
package/dist/stdio.js
CHANGED
@@ -4,8 +4,9 @@ import { createServer } from "./everything.js";
|
|
4
4
|
console.error('Starting default (STDIO) server...');
|
5
5
|
async function main() {
|
6
6
|
const transport = new StdioServerTransport();
|
7
|
-
const { server, cleanup } = createServer();
|
7
|
+
const { server, cleanup, startNotificationIntervals } = createServer();
|
8
8
|
await server.connect(transport);
|
9
|
+
startNotificationIntervals();
|
9
10
|
// Cleanup on exit
|
10
11
|
process.on("SIGINT", async () => {
|
11
12
|
await cleanup();
|
package/dist/streamableHttp.js
CHANGED
@@ -17,7 +17,7 @@ app.post('/mcp', async (req, res) => {
|
|
17
17
|
transport = transports.get(sessionId);
|
18
18
|
}
|
19
19
|
else if (!sessionId) {
|
20
|
-
const { server, cleanup } = createServer();
|
20
|
+
const { server, cleanup, startNotificationIntervals } = createServer();
|
21
21
|
// New initialization request
|
22
22
|
const eventStore = new InMemoryEventStore();
|
23
23
|
transport = new StreamableHTTPServerTransport({
|
@@ -43,6 +43,8 @@ app.post('/mcp', async (req, res) => {
|
|
43
43
|
// so responses can flow back through the same transport
|
44
44
|
await server.connect(transport);
|
45
45
|
await transport.handleRequest(req, res);
|
46
|
+
// Wait until initialize is complete and transport will have a sessionId
|
47
|
+
startNotificationIntervals(transport.sessionId);
|
46
48
|
return; // Already handled
|
47
49
|
}
|
48
50
|
else {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@modelcontextprotocol/server-everything",
|
3
|
-
"version": "2025.
|
3
|
+
"version": "2025.9.12",
|
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)",
|
@@ -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.18.0",
|
26
26
|
"express": "^4.21.1",
|
27
27
|
"zod": "^3.23.8",
|
28
28
|
"zod-to-json-schema": "^3.23.5"
|