@modelcontextprotocol/server-everything 2.0.1 → 2.2.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.
Files changed (40) hide show
  1. package/README.md +45 -0
  2. package/dist/docs/features.md +9 -4
  3. package/dist/docs/instructions.md +2 -1
  4. package/dist/docs/structure.md +9 -2
  5. package/dist/prompts/args.js +2 -0
  6. package/dist/prompts/completions.js +2 -0
  7. package/dist/prompts/resource.js +2 -0
  8. package/dist/prompts/simple.js +2 -0
  9. package/dist/resources/collections.js +108 -0
  10. package/dist/resources/files.js +7 -1
  11. package/dist/resources/index.js +2 -0
  12. package/dist/resources/minted.js +4 -0
  13. package/dist/resources/templates.js +12 -2
  14. package/dist/server/icons.js +51 -0
  15. package/dist/server/index.js +2 -0
  16. package/dist/tools/echo.js +2 -0
  17. package/dist/tools/get-annotated-message.js +2 -0
  18. package/dist/tools/get-env.js +60 -4
  19. package/dist/tools/get-header-params.js +2 -0
  20. package/dist/tools/get-resource-links.js +9 -7
  21. package/dist/tools/get-resource-reference.js +2 -0
  22. package/dist/tools/get-roots-list.js +2 -0
  23. package/dist/tools/get-structured-content.js +2 -0
  24. package/dist/tools/get-sum.js +2 -0
  25. package/dist/tools/get-tiny-image.js +3 -1
  26. package/dist/tools/gzip-file-as-resource.js +184 -33
  27. package/dist/tools/simulate-research-query.js +2 -0
  28. package/dist/tools/toggle-simulated-logging.js +2 -0
  29. package/dist/tools/toggle-subscriber-updates.js +2 -0
  30. package/dist/tools/trigger-elicitation-request-async.js +2 -0
  31. package/dist/tools/trigger-elicitation-request.js +140 -123
  32. package/dist/tools/trigger-list-changed.js +2 -0
  33. package/dist/tools/trigger-log-messages.js +2 -0
  34. package/dist/tools/trigger-long-running-operation.js +26 -2
  35. package/dist/tools/trigger-multi-step-elicitation.js +2 -0
  36. package/dist/tools/trigger-resource-update.js +2 -0
  37. package/dist/tools/trigger-sampling-request-async.js +2 -0
  38. package/dist/tools/trigger-sampling-request.js +2 -0
  39. package/dist/tools/trigger-url-elicitation.js +2 -0
  40. package/package.json +1 -1
package/README.md CHANGED
@@ -13,6 +13,12 @@ This MCP server attempts to exercise all the features of the MCP protocol. It is
13
13
 
14
14
  A complete list of the registered MCP primitives and other protocol features demonstrated can be found in the [Server Features](docs/features.md) document.
15
15
 
16
+ The resource collections (`demo://resource/collection/summer-specials`, and the `by-category/{category}` and `item/{itemId}` templates beside it) show a single `resources/read` returning several contents, each under its own URI: reading a collection returns one content per item, and each item's URI can be read on its own.
17
+
18
+ The server info and every tool, prompt, resource and resource template carry a pair of [icons](docs/features.md#icons), one for a light theme and one for a dark theme, so a client can show the variant that suits its own background.
19
+
20
+ The `get-env` tool returns the server's environment variables, but masks the value of any credential-like name (a `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `PASSWD`, `CREDENTIAL`, `AUTH` or `COOKIE` segment, such as `OPENAI_API_KEY`) as `"<redacted>"`. To see every value unmasked while debugging, start the server with `GET_ENV_INCLUDE_SECRETS=1` (or `true`). Leave it unset otherwise: with it set, every credential in the server's environment reaches the model's context.
21
+
16
22
  ## Protocol versions
17
23
 
18
24
  The server serves both protocol eras, over stdio and Streamable HTTP, from one process:
@@ -22,6 +28,19 @@ The server serves both protocol eras, over stdio and Streamable HTTP, from one p
22
28
 
23
29
  Roots, sampling and logging are deprecated as of 2026-07-28 and stay available, labelled deprecated. [Server Features](docs/features.md) marks which era each feature belongs to.
24
30
 
31
+ ## Configuring `gzip-file-as-resource`
32
+
33
+ The `gzip-file-as-resource` tool fetches the URL it is given, so these environment variables limit what it will fetch:
34
+
35
+ | Variable | Default | Effect |
36
+ | --- | --- | --- |
37
+ | `GZIP_MAX_FETCH_SIZE` | 10 MiB | The largest response, in bytes, it reads |
38
+ | `GZIP_MAX_FETCH_TIME_MILLIS` | 30000 | How long a fetch may take, redirects included |
39
+ | `GZIP_ALLOWED_DOMAINS` | empty (any name) | Comma-separated host names; a host must be one of them or a subdomain of one. Checked on the caller's URL and on every redirect hop |
40
+ | `GZIP_ALLOW_PRIVATE_IPS` | off | Set to `1` or `true` to allow loopback, private (RFC 1918), CGNAT, link-local (cloud metadata) and other non-public addresses |
41
+
42
+ By default the tool refuses a URL whose host resolves to a non-public address, and follows at most five redirects, checking each hop the same way. `GZIP_ALLOWED_DOMAINS` filters names, not addresses: a listed name that resolves to a private address is still refused unless `GZIP_ALLOW_PRIVATE_IPS` is set. The address is checked before the request and resolved again when it is made, so a DNS answer that changes in between (DNS rebinding) is not caught. `data:` URLs are not fetched, so neither check applies to them.
43
+
25
44
  ## Requirements
26
45
 
27
46
  Node.js 24 or later, when the server runs through `npx` or from source.
@@ -152,6 +171,32 @@ npx @modelcontextprotocol/server-everything streamableHttp
152
171
  npx @modelcontextprotocol/server-everything sse
153
172
  ```
154
173
 
174
+ ## Running with Docker
175
+
176
+ This repository publishes no image; build one from the repository root (the build context):
177
+
178
+ ```shell
179
+ docker build -f src/everything/Dockerfile -t mcp/everything .
180
+ ```
181
+
182
+ The `mcp/everything` image on Docker Hub is built by Docker, not by this repository, and can lag behind it.
183
+
184
+ ### Run over stdio (the default)
185
+
186
+ ```shell
187
+ docker run -i --rm mcp/everything
188
+ ```
189
+
190
+ `-i` keeps stdin open, which the stdio transport reads. This is the command an MCP client configuration launches.
191
+
192
+ ### Run the Streamable HTTP server
193
+
194
+ ```shell
195
+ docker run --rm -p 127.0.0.1:3001:3001 mcp/everything streamableHttp
196
+ ```
197
+
198
+ The endpoint is `http://localhost:3001/mcp`. The server listens on port 3001 on every interface inside the container; `127.0.0.1:` publishes it on the host's loopback only. To use another port, set `PORT` and publish that one (`-e PORT=8080 -p 127.0.0.1:8080:8080`). The localhost-only `Origin` check described above applies inside the container too. `docker stop` ends the server cleanly.
199
+
155
200
  ## License
156
201
 
157
202
  This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
@@ -31,9 +31,9 @@ Each feature below is marked **both**, **2026-07-28** or **2025-era**. Roots, sa
31
31
 
32
32
  - `echo` (tools/echo.ts), **both**: Echoes the provided `message: string`. Uses Zod to validate inputs.
33
33
  - `get-annotated-message` (tools/get-annotated-message.ts), **both**: Returns a `text` message annotated with `priority` and `audience` based on `messageType` (`error`, `success`, or `debug`); can optionally include an annotated `image`.
34
- - `get-env` (tools/get-env.ts), **both**: Returns all environment variables from the running process as pretty-printed JSON text.
34
+ - `get-env` (tools/get-env.ts), **both**: Returns all environment variables from the running process as pretty-printed JSON text. Every name is returned, but the value of a credential-like name (one with a `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `PASSWD`, `CREDENTIAL`, `AUTH` or `COOKIE` segment between underscores, in any case) is replaced with `"<redacted>"`. Set `GET_ENV_INCLUDE_SECRETS=1` (or `true`) in the server's environment to return every value unmasked, for debugging.
35
35
  - `get-header-params` (tools/get-header-params.ts), **both**: Returns its `region` argument and the `Mcp-Param-Region` HTTP header it arrived in. Its input and output schemas are plain JSON Schema 2020-12, and `region` carries `x-mcp-header: "Region"`, so a 2026-07-28 Streamable HTTP client mirrors it into that header and the server refuses a call whose header disagrees with the body (`-32020`). The header is `null` on stdio and for a 2025-era client.
36
- - `get-resource-links` (tools/get-resource-links.ts), **both**: Returns an intro `text` block followed by multiple `resource_link` items. For a requested `count` (1–10), alternates between dynamic Text and Blob resources using URIs from `resources/templates.ts`.
36
+ - `get-resource-links` (tools/get-resource-links.ts), **both**: Returns an intro `text` block followed by multiple `resource_link` items. For a requested `count` (1–10), alternates between dynamic Text resources (even IDs) and Blob resources (odd IDs), using URIs from `resources/templates.ts`.
37
37
  - `get-resource-reference` (tools/get-resource-reference.ts), **both**: Accepts `resourceType` (`text` or `blob`) and `resourceId` (positive integer). Returns a concrete `resource` content block (with its `uri`, `mimeType`, and data) with surrounding explanatory `text`.
38
38
  - `get-roots-list` (tools/get-roots-list.ts), **both**, deprecated: Asks the client for its roots with a multi-round-trip request (`inputRequired.listRoots()`) and lists them. Needs client capability `roots`.
39
39
  - `gzip-file-as-resource` (tools/gzip-file-as-resource.ts), **both**: Accepts a `name` and `data` (URL or data URI), fetches the data subject to size/time/domain constraints, compresses it, and returns either a `resource_link` (default) or an inline `resource` depending on `outputType`, with `mimeType: application/gzip`. The linked resource is registered as a session resource at `demo://resource/session/<name>` for a 2025-era client, and stored for ten minutes at a minted `demo://resource/minted/<id>/<name>` for a 2026-07-28 client.
@@ -47,7 +47,7 @@ Each feature below is marked **both**, **2026-07-28** or **2025-era**. Roots, sa
47
47
  - `trigger-elicitation-request-async` (tools/trigger-elicitation-request-async.ts), **2026-07-28**: Runs as a task whose `input_required` status carries a form elicitation; the client answers with `tasks/update` and the task completes with a summary. Needs a client that declares the tasks extension and form-mode elicitation.
48
48
  - `trigger-list-changed` (tools/trigger-list-changed.ts), **both**: Sends `notifications/<list>/list_changed` for `tools`, `prompts` or `resources`: on 2026-07-28 to each `subscriptions/listen` stream that asked for that list, on a 2025-era connection unsolicited.
49
49
  - `trigger-log-messages` (tools/trigger-log-messages.ts), **both**, deprecated: Sends one log message at each level during the call. A 2026-07-28 request gets those at or above the level its `_meta` names (none if it names none); a 2025-era client those at or above its `logging/setLevel` level.
50
- - `trigger-long-running-operation` (tools/trigger-long-running-operation.ts), **both**: Simulates a multi-step operation over a given `duration` and number of `steps`; reports progress via `notifications/progress` when a `progressToken` is provided by the client.
50
+ - `trigger-long-running-operation` (tools/trigger-long-running-operation.ts), **both**: Simulates a multi-step operation over a given `duration` and number of `steps`; reports progress via `notifications/progress` when a `progressToken` is provided by the client. Honors cancellation: a cancelled call clears its timer and sends no further progress.
51
51
  - `trigger-multi-step-elicitation` (tools/trigger-multi-step-elicitation.ts), **both**: Asks for a name, then for a favorite color addressed by that name, carrying the first answer to the second round in `requestState`. The state is HMAC-signed and expires after ten minutes; a tampered or expired one is refused with `-32602`. A blank name or a color that is not a choice is asked again. Needs form-mode elicitation.
52
52
  - `trigger-resource-update` (tools/trigger-resource-update.ts), **both**: Sends `notifications/resources/updated` for a URI: on 2026-07-28 to each listen stream whose `resourceSubscriptions` name it, on a 2025-era connection once the client has subscribed to it.
53
53
  - `trigger-sampling-request` (tools/trigger-sampling-request.ts), **both**, deprecated: Asks the client's LLM for a completion with a multi-round-trip request, using the provided `prompt` and `maxTokens`; returns the LLM's response payload. Needs client capability `sampling`.
@@ -70,8 +70,9 @@ On a 2025-era connection the tools that need a client capability are registered
70
70
  - Static Documents: `demo://resource/static/document/<filename>` (serves files from `src/everything/docs/` as static file-based resources; a 2026-07-28 read carries a one-hour public cache hint)
71
71
  - Session Scoped, **2025-era**: `demo://resource/session/<name>` (per-session resources registered dynamically; available only for the lifetime of the session)
72
72
  - Minted, **2026-07-28**: `demo://resource/minted/<id>/<name>` (resources a tool created, under a server-minted id; readable by any client that has the URI, for ten minutes; the process keeps at most 100 of them and 64 MiB of content, dropping the oldest first)
73
+ - Collections: `demo://resource/collection/summer-specials`, `demo://resource/collection/by-category/{category}` and `demo://resource/collection/item/{itemId}` (resources/collections.ts; one `resources/read` of a collection returns several contents, one per item, each under its item's own URI, which reads back on its own; `category` and `itemId` complete)
73
74
 
74
- A read of a resource that does not exist (an unknown URI, a template id that is not a positive integer, an expired minted resource) is answered with `-32602` and the URI in the error's `data`.
75
+ A read of a resource that does not exist (an unknown URI, a template id that is not a positive integer, a collection category or item that is not in the catalog, an expired minted resource) is answered with `-32602` and the URI in the error's `data`.
75
76
 
76
77
  ## Resource Subscriptions and Notifications
77
78
 
@@ -79,6 +80,10 @@ A read of a resource that does not exist (an unknown URI, a template id that is
79
80
  - **2025-era**: clients subscribe and unsubscribe to resource URIs with `resources/subscribe` and `resources/unsubscribe`. `toggle-subscriber-updates` starts or stops a per-connection interval that emits `notifications/resources/updated { uri }` for the URIs that connection subscribed to, and `trigger-resource-update` sends one on demand. List changes arrive unsolicited.
80
81
  - Each client's subscriptions belong to the server instance serving its connection, so concurrent clients are independent.
81
82
 
83
+ ## Icons
84
+
85
+ **Both.** The server demonstrates icons with light and dark themes (SEP-973). Its `serverInfo` (in `initialize` and in `server/discover`) and every entry of `tools/list`, `prompts/list`, `resources/list` and `resources/templates/list` carry an `icons` array of two scalable SVG icons, one with `theme: "light"` (drawn for a light background) and one with `theme: "dark"`. Each kind has its own glyph: a server rack, a wrench for tools, a speech bubble for prompts, a document for resources, and a document with braces for templates. The icons are inline `data:` URIs, so a client fetches nothing; they are defined in `server/icons.ts`.
86
+
82
87
  ## Logging
83
88
 
84
89
  Logging is deprecated as of 2026-07-28 (SEP-2577) and remains available on both eras.
@@ -19,7 +19,8 @@ The server serves two protocol eras. A client on protocol version 2026-07-28 con
19
19
 
20
20
  ## Constraints & Limitations
21
21
 
22
- - `gzip-file-as-resource`: Max fetch size controlled by `GZIP_MAX_FETCH_SIZE` (default 10MB), timeout by `GZIP_MAX_FETCH_TIME_MILLIS` (default 30s), allowed domains by `GZIP_ALLOWED_DOMAINS`
22
+ - `gzip-file-as-resource`: Max fetch size controlled by `GZIP_MAX_FETCH_SIZE` (default 10MB), timeout by `GZIP_MAX_FETCH_TIME_MILLIS` (default 30s), allowed domains by `GZIP_ALLOWED_DOMAINS` (checked on every redirect hop). It refuses URLs whose host resolves to a loopback, private or link-local address, unless the server was started with `GZIP_ALLOW_PRIVATE_IPS=1`
23
+ - `get-env`: Values of credential-like variable names (`*_KEY`, `*_TOKEN`, `*_SECRET`, `*_PASSWORD` and the like) come back as `"<redacted>"`; the server operator can set `GET_ENV_INCLUDE_SECRETS=1` to return them unmasked
23
24
  - Session resources are ephemeral and lost when the session ends; minted resources expire after ten minutes
24
25
  - Roots, sampling and logging are deprecated as of protocol version 2026-07-28, as is the HTTP+SSE transport
25
26
 
@@ -28,6 +28,7 @@ src/everything
28
28
  │ └── resource.ts
29
29
  ├── resources
30
30
  │ ├── index.ts
31
+ │ ├── collections.ts
31
32
  │ ├── files.ts
32
33
  │ ├── minted.ts
33
34
  │ ├── session.ts
@@ -36,6 +37,7 @@ src/everything
36
37
  ├── server
37
38
  │ ├── index.ts
38
39
  │ ├── context.ts
40
+ │ ├── icons.ts
39
41
  │ ├── logging.ts
40
42
  │ ├── roots.ts
41
43
  │ └── tasks.ts
@@ -132,6 +134,8 @@ src/everything
132
134
  - Blob: `demo://resource/dynamic/blob/{index}` (MIME: `application/octet-stream`, Base64 payload)
133
135
  - The `{index}` path variable must be a finite positive integer; any other is not found (`-32602`). Content is generated on demand with a timestamp.
134
136
  - Exposes helpers `textResource(uri, index)`, `textResourceUri(index)`, `blobResource(uri, index)`, and `blobResourceUri(index)` so other modules can construct and embed dynamic resources directly (e.g., from prompts).
137
+ - `collections.ts`
138
+ - Registers a resource collection example: `summer-specials` (`demo://resource/collection/summer-specials`), whose read returns every item of a small fixed catalog as a separate content under its own URI; the `collection-by-category` template (`demo://resource/collection/by-category/{category}`), which returns one category's items; and the `collection-item` template (`demo://resource/collection/item/{itemId}`), which reads one item back. Both templates complete their variable, and a category or id not in the catalog is not found (`-32602`).
135
139
  - `files.ts`
136
140
  - Registers static file-based resources for each file in the `docs/` folder.
137
141
  - URIs follow the pattern: `demo://resource/static/document/<filename>`.
@@ -152,6 +156,8 @@ src/everything
152
156
  - Exposes `{ server, cleanup }` to the chosen transport. Cleanup stops any running intervals in the server when the connection ends.
153
157
  - `context.ts`
154
158
  - The per-instance context features receive: the era, the change publisher, the 2025-era subscriptions and a cleanup registry.
159
+ - `icons.ts`
160
+ - The light- and dark-themed icon pairs (SEP-973) attached to the server info and to every tool, prompt, resource and resource template, one pair per kind, as inline SVG `data:` URIs.
155
161
  - `logging.ts`
156
162
  - Implements simulated logging (2025 era). Periodically sends randomized log messages at various levels to the connected client. Started/stopped on demand via a dedicated tool.
157
163
  - `roots.ts`
@@ -168,7 +174,7 @@ src/everything
168
174
  - `get-annotated-message.ts`
169
175
  - Registers a `get-annotated-message` tool which demonstrates content-level annotations. Emits a primary `text` message with content `annotations` (`priority`, `audience`) that vary by `messageType` (`"error" | "success" | "debug"`), and optionally includes an annotated `image` (tiny PNG) when `includeImage` is true. All tools in this server include tool-level annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`).
170
176
  - `get-env.ts`
171
- - Registers a `get-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration.
177
+ - Registers a `get-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration. Values of credential-like names are masked as `"<redacted>"` unless `GET_ENV_INCLUDE_SECRETS` is set to a truthy value.
172
178
  - `get-header-params.ts`
173
179
  - Registers a `get-header-params` tool with JSON Schema 2020-12 input and output schemas whose `region` argument carries `x-mcp-header`; returns the argument and the `Mcp-Param-Region` header it arrived in.
174
180
  - `get-resource-links.ts`
@@ -185,7 +191,8 @@ src/everything
185
191
  - Environment controls:
186
192
  - `GZIP_MAX_FETCH_SIZE` (bytes, default 10 MiB)
187
193
  - `GZIP_MAX_FETCH_TIME_MILLIS` (ms, default 30000)
188
- - `GZIP_ALLOWED_DOMAINS` (comma-separated allowlist; empty means all domains allowed)
194
+ - `GZIP_ALLOWED_DOMAINS` (comma-separated name allowlist, checked on the caller's URL and on every redirect hop; empty means any name is allowed)
195
+ - `GZIP_ALLOW_PRIVATE_IPS` (`1`/`true` to allow loopback, private, link-local and other non-public addresses; by default a host that resolves to one is refused, on every hop)
189
196
  - `simulate-research-query.ts`
190
197
  - 2026-07-28: registers a `simulate-research-query` tool that runs as a task on the tasks extension, through four timed stages, pausing at `input_required` for a clarification on an ambiguous topic.
191
198
  - `trigger-elicitation-request.ts`
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { PROMPT_ICONS } from "../server/icons.js";
2
3
  /**
3
4
  * Register a prompt with arguments
4
5
  * - Two arguments, one required and one optional
@@ -15,6 +16,7 @@ export const registerArgumentsPrompt = (server) => {
15
16
  // Register the prompt
16
17
  server.registerPrompt("args-prompt", {
17
18
  title: "Arguments Prompt",
19
+ icons: PROMPT_ICONS,
18
20
  description: "A prompt with two arguments, one required and one optional",
19
21
  argsSchema: promptArgsSchema,
20
22
  }, (args) => {
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { completable } from "@modelcontextprotocol/server";
3
+ import { PROMPT_ICONS } from "../server/icons.js";
3
4
  /**
4
5
  * Register a prompt with completable arguments
5
6
  * - Two required arguments, both with completion handlers
@@ -36,6 +37,7 @@ export const registerPromptWithCompletions = (server) => {
36
37
  // Register the prompt
37
38
  server.registerPrompt("completable-prompt", {
38
39
  title: "Team Management",
40
+ icons: PROMPT_ICONS,
39
41
  description: "First argument choice narrows values for second argument.",
40
42
  argsSchema: promptArgsSchema,
41
43
  }, ({ department, name }) => ({
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { resourceTypeCompleter, resourceIdForPromptCompleter, } from "../resources/templates.js";
3
3
  import { textResource, textResourceUri, blobResourceUri, blobResource, RESOURCE_TYPE_BLOB, RESOURCE_TYPE_TEXT, RESOURCE_TYPES, } from "../resources/templates.js";
4
+ import { PROMPT_ICONS } from "../server/icons.js";
4
5
  /**
5
6
  * Register a prompt with an embedded resource reference
6
7
  * - Takes a resource type and id
@@ -17,6 +18,7 @@ export const registerEmbeddedResourcePrompt = (server) => {
17
18
  // Register the prompt
18
19
  server.registerPrompt("resource-prompt", {
19
20
  title: "Resource Prompt",
21
+ icons: PROMPT_ICONS,
20
22
  description: "A prompt that includes an embedded resource reference",
21
23
  argsSchema: promptArgsSchema,
22
24
  }, (args) => {
@@ -1,3 +1,4 @@
1
+ import { PROMPT_ICONS } from "../server/icons.js";
1
2
  /**
2
3
  * Register a simple prompt with no arguments
3
4
  * - Returns the fixed text of the prompt with no modifications
@@ -8,6 +9,7 @@ export const registerSimplePrompt = (server) => {
8
9
  // Register the prompt
9
10
  server.registerPrompt("simple-prompt", {
10
11
  title: "Simple Prompt",
12
+ icons: PROMPT_ICONS,
11
13
  description: "A prompt with no arguments",
12
14
  }, () => ({
13
15
  messages: [
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Resource collections (#3130): one `resources/read` that answers with several
3
+ * contents, each under a URI of its own. The spec allows a read to return more
4
+ * than one content ("a server could return the contents of several files when
5
+ * a directory resource is read"), and this module shows the pattern with a
6
+ * small, fixed product catalog:
7
+ *
8
+ * - `demo://resource/collection/summer-specials` (static, listed): every item.
9
+ * - `demo://resource/collection/by-category/{category}` (template, with a
10
+ * completer for `category`): the items in one category.
11
+ * - `demo://resource/collection/item/{itemId}` (template, with a completer for
12
+ * `itemId`): one item.
13
+ *
14
+ * Every content a collection returns carries its item's URI, not the
15
+ * collection's, and that URI is readable on its own through the item
16
+ * template, so a client can follow up on any one member. The catalog is a
17
+ * constant, so the module keeps no state and serves both protocol eras alike.
18
+ * Adapted from the example in olaservo's gist linked on the issue.
19
+ */
20
+ import { ResourceNotFoundError, ResourceTemplate, } from "@modelcontextprotocol/server";
21
+ import { RESOURCE_ICONS, RESOURCE_TEMPLATE_ICONS } from "../server/icons.js";
22
+ /** The example catalog the collections are drawn from. */
23
+ export const COLLECTION_ITEMS = [
24
+ { id: 1, name: "Summer Hat", price: 29.99, category: "accessories" },
25
+ { id: 2, name: "Beach Towel", price: 19.99, category: "accessories" },
26
+ { id: 3, name: "Sunglasses", price: 49.99, category: "accessories" },
27
+ { id: 4, name: "Flip Flops", price: 14.99, category: "footwear" },
28
+ { id: 5, name: "Sunscreen SPF50", price: 12.99, category: "skincare" },
29
+ ];
30
+ /** The distinct categories in the catalog, in first-seen order. */
31
+ export const COLLECTION_CATEGORIES = [
32
+ ...new Set(COLLECTION_ITEMS.map((item) => item.category)),
33
+ ];
34
+ const MIME_TYPE = "application/json";
35
+ const collectionUriBase = "demo://resource/collection";
36
+ const itemUriBase = `${collectionUriBase}/item`;
37
+ const categoryUriBase = `${collectionUriBase}/by-category`;
38
+ /** The URI of the collection holding every item. */
39
+ export const SUMMER_SPECIALS_URI = `${collectionUriBase}/summer-specials`;
40
+ /**
41
+ * The URI under which one item can be read on its own.
42
+ * @param id
43
+ */
44
+ export const collectionItemUri = (id) => `${itemUriBase}/${id}`;
45
+ /**
46
+ * The contents of one item: JSON, under the item's own URI.
47
+ * @param item
48
+ */
49
+ const itemContents = (item) => ({
50
+ uri: collectionItemUri(item.id),
51
+ mimeType: MIME_TYPE,
52
+ text: JSON.stringify(item, null, 2),
53
+ });
54
+ /** Completes a category name from its prefix. */
55
+ const categoryCompleter = (value) => COLLECTION_CATEGORIES.filter((category) => category.startsWith(value));
56
+ /** Completes an item id from its prefix. */
57
+ const itemIdCompleter = (value) => COLLECTION_ITEMS.map((item) => String(item.id)).filter((id) => id.startsWith(value));
58
+ /**
59
+ * Register the collection resources with the MCP server.
60
+ * - `summer-specials`: a static resource whose read returns every item
61
+ * - `collection-by-category`: a template whose read returns one category's items
62
+ * - `collection-item`: a template whose read returns one item
63
+ * - A category or item id that is not in the catalog is not found (`-32602`)
64
+ *
65
+ * @param server
66
+ */
67
+ export const registerCollectionResources = (server) => {
68
+ // The whole collection: one read, one content per item, each with its own URI
69
+ server.registerResource("summer-specials", SUMMER_SPECIALS_URI, {
70
+ title: "Summer Specials Collection",
71
+ icons: RESOURCE_ICONS,
72
+ mimeType: MIME_TYPE,
73
+ description: "A resource collection: one read returns every item in the catalog as a separate content, each under its own demo://resource/collection/item/{itemId} URI.",
74
+ }, async () => ({ contents: COLLECTION_ITEMS.map(itemContents) }));
75
+ // A filtered collection: the items in one category
76
+ server.registerResource("collection-by-category", new ResourceTemplate(`${categoryUriBase}/{category}`, {
77
+ list: undefined,
78
+ complete: { category: categoryCompleter },
79
+ }), {
80
+ title: "Collection by Category",
81
+ icons: RESOURCE_TEMPLATE_ICONS,
82
+ mimeType: MIME_TYPE,
83
+ description: `A resource collection filtered by the {category} variable (${COLLECTION_CATEGORIES.join(", ")}): one read returns each item in that category as a separate content, under its own URI.`,
84
+ }, async (uri, variables) => {
85
+ const category = String(variables.category);
86
+ const items = COLLECTION_ITEMS.filter((item) => item.category === category);
87
+ if (items.length === 0)
88
+ throw new ResourceNotFoundError(uri.toString());
89
+ return { contents: items.map(itemContents) };
90
+ });
91
+ // One member of the collections, readable on its own
92
+ server.registerResource("collection-item", new ResourceTemplate(`${itemUriBase}/{itemId}`, {
93
+ list: undefined,
94
+ complete: { itemId: itemIdCompleter },
95
+ }), {
96
+ title: "Collection Item",
97
+ icons: RESOURCE_TEMPLATE_ICONS,
98
+ mimeType: MIME_TYPE,
99
+ description: "One item of the resource collections, selected by the {itemId} variable (1 to 5). The collections return their items under these URIs.",
100
+ }, async (uri, variables) => {
101
+ // Match the id's exact spelling, so "01" is not found rather than item 1
102
+ const itemId = String(variables.itemId);
103
+ const item = COLLECTION_ITEMS.find((candidate) => String(candidate.id) === itemId);
104
+ if (!item)
105
+ throw new ResourceNotFoundError(uri.toString());
106
+ return { contents: [itemContents(item)] };
107
+ });
108
+ };
@@ -1,6 +1,7 @@
1
1
  import { dirname, join } from "path";
2
2
  import { fileURLToPath } from "url";
3
3
  import { readdirSync, readFileSync, statSync } from "fs";
4
+ import { RESOURCE_ICONS } from "../server/icons.js";
4
5
  /** How long a client or shared cache may keep a static document. */
5
6
  export const STATIC_DOCUMENT_CACHE_HINT = {
6
7
  ttlMs: 60 * 60_000,
@@ -49,7 +50,12 @@ export const registerFileResources = (server) => {
49
50
  server.registerResource(name, uri,
50
51
  // A static document changes only when the server is upgraded, so any
51
52
  // cache may keep it for an hour (2026-07-28 clients only; #4852).
52
- { mimeType, description, cacheHint: STATIC_DOCUMENT_CACHE_HINT }, async (uri) => {
53
+ {
54
+ mimeType,
55
+ description,
56
+ icons: RESOURCE_ICONS,
57
+ cacheHint: STATIC_DOCUMENT_CACHE_HINT,
58
+ }, async (uri) => {
53
59
  const text = readFileSafe(fullPath);
54
60
  return {
55
61
  contents: [
@@ -1,6 +1,7 @@
1
1
  import { registerResourceTemplates } from "./templates.js";
2
2
  import { registerFileResources } from "./files.js";
3
3
  import { registerMintedResources } from "./minted.js";
4
+ import { registerCollectionResources } from "./collections.js";
4
5
  import { fileURLToPath } from "url";
5
6
  import { dirname, join } from "path";
6
7
  import { readFileSync } from "fs";
@@ -13,6 +14,7 @@ import { readFileSync } from "fs";
13
14
  export const registerResources = (server, context) => {
14
15
  registerResourceTemplates(server);
15
16
  registerFileResources(server);
17
+ registerCollectionResources(server);
16
18
  if (context.era === "modern")
17
19
  registerMintedResources(server);
18
20
  };
@@ -14,6 +14,7 @@
14
14
  // (-32602).
15
15
  import { randomUUID } from "node:crypto";
16
16
  import { ResourceNotFoundError, ResourceTemplate, } from "@modelcontextprotocol/server";
17
+ import { RESOURCE_ICONS, RESOURCE_TEMPLATE_ICONS } from "../server/icons.js";
17
18
  /** How long a minted resource stays readable, in milliseconds. */
18
19
  export const MINTED_RESOURCE_TTL_MS = 10 * 60_000;
19
20
  /**
@@ -85,6 +86,8 @@ export function mintBlobResource(name, mimeType, blob) {
85
86
  name,
86
87
  mimeType,
87
88
  description: `Created by a tool call; readable for ${MINTED_RESOURCE_TTL_MS / 60_000} minutes at this URI`,
89
+ // #5434: a minted resource is a resource like any other (#3131).
90
+ icons: RESOURCE_ICONS,
88
91
  };
89
92
  }
90
93
  /**
@@ -96,6 +99,7 @@ export function mintBlobResource(name, mimeType, blob) {
96
99
  */
97
100
  export function registerMintedResources(server) {
98
101
  server.registerResource("Minted Resource", new ResourceTemplate(mintedUriTemplate, { list: undefined }), {
102
+ icons: RESOURCE_TEMPLATE_ICONS,
99
103
  description: "A resource a tool created for this client, such as gzip-file-as-resource's output. Readable for ten minutes at the URI the tool returned.",
100
104
  }, async (uri) => {
101
105
  sweep(Date.now());
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { ResourceNotFoundError, ResourceTemplate, completable, } from "@modelcontextprotocol/server";
3
+ import { RESOURCE_TEMPLATE_ICONS } from "../server/icons.js";
3
4
  // Resource types
4
5
  export const RESOURCE_TYPE_TEXT = "Text";
5
6
  export const RESOURCE_TYPE_BLOB = "Blob";
@@ -17,7 +18,12 @@ export const RESOURCE_TYPES = [
17
18
  * The input value is expected to be a string representing the type of resource to fetch.
18
19
  * The completion logic matches the input against available resource types.
19
20
  */
20
- export const resourceTypeCompleter = completable(z.string().describe("Type of resource to fetch"), (value) => {
21
+ export const resourceTypeCompleter = completable(
22
+ // Prompt arguments carry no JSON Schema, only a description, so the
23
+ // description is the only place a client can learn the allowed values (#3985)
24
+ z
25
+ .string()
26
+ .describe(`Type of resource to fetch. Must be "${RESOURCE_TYPE_TEXT}" or "${RESOURCE_TYPE_BLOB}".`), (value) => {
21
27
  return RESOURCE_TYPES.filter((t) => t.startsWith(value));
22
28
  });
23
29
  /**
@@ -36,7 +42,9 @@ export const resourceTypeCompleter = completable(z.string().describe("Type of re
36
42
  * The input string is first transformed into a number and checked to ensure it is an integer.
37
43
  * This helps validate and suggest appropriate resource IDs.
38
44
  */
39
- export const resourceIdForPromptCompleter = completable(z.string().describe("ID of the text resource to fetch"), (value) => {
45
+ export const resourceIdForPromptCompleter = completable(z
46
+ .string()
47
+ .describe("ID of the resource to fetch. Must be a positive integer (1 or greater)."), (value) => {
40
48
  const resourceId = Number(value);
41
49
  return Number.isInteger(resourceId) && resourceId > 0 ? [value] : [];
42
50
  });
@@ -144,6 +152,7 @@ export const registerResourceTemplates = (server) => {
144
152
  complete: { resourceId: resourceIdForResourceTemplateCompleter },
145
153
  }), {
146
154
  mimeType: "text/plain",
155
+ icons: RESOURCE_TEMPLATE_ICONS,
147
156
  description: "Plaintext dynamic resource fabricated from the {resourceId} variable, which must be an integer.",
148
157
  }, async (uri, variables) => {
149
158
  const resourceId = parseResourceId(uri, variables);
@@ -157,6 +166,7 @@ export const registerResourceTemplates = (server) => {
157
166
  complete: { resourceId: resourceIdForResourceTemplateCompleter },
158
167
  }), {
159
168
  mimeType: "application/octet-stream",
169
+ icons: RESOURCE_TEMPLATE_ICONS,
160
170
  description: "Binary (base64) dynamic resource fabricated from the {resourceId} variable, which must be an integer.",
161
171
  }, async (uri, variables) => {
162
172
  const resourceId = parseResourceId(uri, variables);
@@ -0,0 +1,51 @@
1
+ // The icons the everything server attaches to its primitives (#3131).
2
+ //
3
+ // SEP-973 lets a server give `icons` to its implementation info and to each
4
+ // tool, prompt, resource and resource template, and an icon may name the
5
+ // `theme` it is drawn for: "light" for a light background, "dark" for a dark
6
+ // one. This module defines one light/dark pair per primitive kind, so a client
7
+ // such as the Inspector can show which kind an entry is and pick the variant
8
+ // that suits its own theme.
9
+ //
10
+ // One pair per kind, rather than one per item, keeps every registration to a
11
+ // single `icons:` line that names its kind's set. Each icon is a small inline
12
+ // SVG carried as a base64 `data:` URI, the form the spec names for embedded
13
+ // image data: a client fetches nothing, and the package ships no new files.
14
+ /** Stroke colour of the variant drawn for a light background. */
15
+ const LIGHT_THEME_STROKE = "#1F2937";
16
+ /** Stroke colour of the variant drawn for a dark background. */
17
+ const DARK_THEME_STROKE = "#F9FAFB";
18
+ /**
19
+ * Build the light and dark variants of one glyph.
20
+ *
21
+ * @param glyph - The SVG elements of a 24x24, stroke-only glyph.
22
+ * @returns Two scalable SVG icons, one per theme.
23
+ */
24
+ const themedIcons = (glyph) => [
25
+ ["light", LIGHT_THEME_STROKE],
26
+ ["dark", DARK_THEME_STROKE],
27
+ ].map(([theme, stroke]) => {
28
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" ` +
29
+ `fill="none" stroke="${stroke}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">` +
30
+ `${glyph}</svg>`;
31
+ return {
32
+ src: `data:image/svg+xml;base64,${Buffer.from(svg).toString("base64")}`,
33
+ mimeType: "image/svg+xml",
34
+ sizes: ["any"],
35
+ theme,
36
+ };
37
+ });
38
+ /** The server itself (its `serverInfo`): a two-unit server rack. */
39
+ export const SERVER_ICONS = themedIcons('<rect x="3" y="4" width="18" height="7" rx="2"/>' +
40
+ '<rect x="3" y="13" width="18" height="7" rx="2"/>' +
41
+ '<path d="M7 7.5h.01M7 16.5h.01"/>');
42
+ /** Every tool: a wrench. */
43
+ export const TOOL_ICONS = themedIcons('<path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.5 2.5-2.4-.6-.6-2.4z"/>');
44
+ /** Every prompt: a speech bubble. */
45
+ export const PROMPT_ICONS = themedIcons('<path d="M4 5h16v11H9l-5 4z"/><path d="M8 9h8M8 12h5"/>');
46
+ /** Every concrete resource: a document. */
47
+ export const RESOURCE_ICONS = themedIcons('<path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4M9 12h6M9 16h6"/>');
48
+ /** Every resource template: a document with a placeholder in braces. */
49
+ export const RESOURCE_TEMPLATE_ICONS = themedIcons('<path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4"/>' +
50
+ '<path d="M10.5 11c-1 0-1 .8-1 1.5s0 1.5-1 1.5c1 0 1 .8 1 1.5s0 1.5 1 1.5"/>' +
51
+ '<path d="M13.5 11c1 0 1 .8 1 1.5s0 1.5 1 1.5c-1 0-1 .8-1 1.5s0 1.5-1 1.5"/>');
@@ -27,6 +27,7 @@ import { guardTaskTools, registerTasksExtension, TASKS_EXTENSION, } from "./task
27
27
  import { syncRoots } from "./roots.js";
28
28
  import { instancePublisher, } from "./context.js";
29
29
  import { SERVER_VERSION } from "../version.js";
30
+ import { SERVER_ICONS } from "./icons.js";
30
31
  /**
31
32
  * The process-wide `requestState` codec. The key is per process: on the
32
33
  * 2026-07-28 HTTP path a later round may be served by a fresh instance, so
@@ -73,6 +74,7 @@ export const createServer = (options = {}) => {
73
74
  const server = new McpServer({
74
75
  name: "mcp-servers/everything",
75
76
  title: "Everything Reference Server",
77
+ icons: SERVER_ICONS,
76
78
  version: SERVER_VERSION,
77
79
  }, {
78
80
  capabilities: {
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { TOOL_ICONS } from "../server/icons.js";
2
3
  // Tool input schema
3
4
  export const EchoSchema = z.object({
4
5
  message: z.string().describe("Message to echo"),
@@ -9,6 +10,7 @@ const config = {
9
10
  title: "Echo Tool",
10
11
  description: "Echoes back the input string",
11
12
  inputSchema: EchoSchema,
13
+ icons: TOOL_ICONS,
12
14
  annotations: {
13
15
  readOnlyHint: true,
14
16
  destructiveHint: false,
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { MCP_TINY_IMAGE } from "./get-tiny-image.js";
3
+ import { TOOL_ICONS } from "../server/icons.js";
3
4
  // Tool input schema
4
5
  const GetAnnotatedMessageSchema = z.object({
5
6
  messageType: z
@@ -16,6 +17,7 @@ const config = {
16
17
  title: "Get Annotated Message Tool",
17
18
  description: "Demonstrates how annotations can be used to provide metadata about content.",
18
19
  inputSchema: GetAnnotatedMessageSchema,
20
+ icons: TOOL_ICONS,
19
21
  annotations: {
20
22
  readOnlyHint: true, // This tool only returns data, no side effects
21
23
  destructiveHint: false, // Does not delete or modify anything