@modelcontextprotocol/server-everything 2025.11.25 → 2026.1.14

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 (45) hide show
  1. package/README.md +10 -159
  2. package/dist/docs/architecture.md +44 -0
  3. package/dist/docs/extension.md +23 -0
  4. package/dist/docs/features.md +52 -0
  5. package/dist/docs/how-it-works.md +45 -0
  6. package/dist/docs/instructions.md +28 -0
  7. package/dist/docs/startup.md +73 -0
  8. package/dist/docs/structure.md +182 -0
  9. package/dist/index.js +19 -14
  10. package/dist/prompts/args.js +34 -0
  11. package/dist/prompts/completions.js +52 -0
  12. package/dist/prompts/index.js +15 -0
  13. package/dist/prompts/resource.js +60 -0
  14. package/dist/prompts/simple.js +23 -0
  15. package/dist/resources/files.js +83 -0
  16. package/dist/resources/index.js +33 -0
  17. package/dist/resources/session.js +44 -0
  18. package/dist/resources/subscriptions.js +125 -0
  19. package/dist/resources/templates.js +171 -0
  20. package/dist/server/index.js +73 -0
  21. package/dist/server/logging.js +64 -0
  22. package/dist/server/roots.js +69 -0
  23. package/dist/tools/echo.js +29 -0
  24. package/dist/tools/get-annotated-message.js +81 -0
  25. package/dist/tools/get-env.js +28 -0
  26. package/dist/tools/get-resource-links.js +62 -0
  27. package/dist/tools/get-resource-reference.js +74 -0
  28. package/dist/tools/get-roots-list.js +71 -0
  29. package/dist/tools/get-structured-content.js +72 -0
  30. package/dist/tools/get-sum.js +40 -0
  31. package/dist/tools/get-tiny-image.js +41 -0
  32. package/dist/tools/gzip-file-as-resource.js +182 -0
  33. package/dist/tools/index.js +42 -0
  34. package/dist/tools/toggle-simulated-logging.js +41 -0
  35. package/dist/tools/toggle-subscriber-updates.js +44 -0
  36. package/dist/tools/trigger-elicitation-request.js +210 -0
  37. package/dist/tools/trigger-long-running-operation.js +59 -0
  38. package/dist/tools/trigger-sampling-request.js +71 -0
  39. package/dist/{sse.js → transports/sse.js} +25 -17
  40. package/dist/transports/stdio.js +27 -0
  41. package/dist/{streamableHttp.js → transports/streamableHttp.js} +68 -57
  42. package/package.json +18 -10
  43. package/dist/everything.js +0 -937
  44. package/dist/instructions.md +0 -23
  45. package/dist/stdio.js +0 -20
package/README.md CHANGED
@@ -1,166 +1,17 @@
1
1
  # Everything MCP Server
2
+ **[Architecture](docs/architecture.md)
3
+ | [Project Structure](docs/structure.md)
4
+ | [Startup Process](docs/startup.md)
5
+ | [Server Features](docs/features.md)
6
+ | [Extension Points](docs/extension.md)
7
+ | [How It Works](docs/how-it-works.md)**
8
+
2
9
 
3
10
  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.
4
11
 
5
- ## Components
6
-
7
- ### Tools
8
-
9
- 1. `echo`
10
- - Simple tool to echo back input messages
11
- - Input:
12
- - `message` (string): Message to echo back
13
- - Returns: Text content with echoed message
14
-
15
- 2. `add`
16
- - Adds two numbers together
17
- - Inputs:
18
- - `a` (number): First number
19
- - `b` (number): Second number
20
- - Returns: Text result of the addition
21
-
22
- 3. `longRunningOperation`
23
- - Demonstrates progress notifications for long operations
24
- - Inputs:
25
- - `duration` (number, default: 10): Duration in seconds
26
- - `steps` (number, default: 5): Number of progress steps
27
- - Returns: Completion message with duration and steps
28
- - Sends progress notifications during execution
29
-
30
- 4. `printEnv`
31
- - Prints all environment variables
32
- - Useful for debugging MCP server configuration
33
- - No inputs required
34
- - Returns: JSON string of all environment variables
35
-
36
- 5. `sampleLLM`
37
- - Demonstrates LLM sampling capability using MCP sampling feature
38
- - Inputs:
39
- - `prompt` (string): The prompt to send to the LLM
40
- - `maxTokens` (number, default: 100): Maximum tokens to generate
41
- - Returns: Generated LLM response
42
-
43
- 6. `getTinyImage`
44
- - Returns a small test image
45
- - No inputs required
46
- - Returns: Base64 encoded PNG image data
47
-
48
- 7. `annotatedMessage`
49
- - Demonstrates how annotations can be used to provide metadata about content
50
- - Inputs:
51
- - `messageType` (enum: "error" | "success" | "debug"): Type of message to demonstrate different annotation patterns
52
- - `includeImage` (boolean, default: false): Whether to include an example image
53
- - Returns: Content with varying annotations:
54
- - Error messages: High priority (1.0), visible to both user and assistant
55
- - Success messages: Medium priority (0.7), user-focused
56
- - Debug messages: Low priority (0.3), assistant-focused
57
- - Optional image: Medium priority (0.5), user-focused
58
- - Example annotations:
59
- ```json
60
- {
61
- "priority": 1.0,
62
- "audience": ["user", "assistant"]
63
- }
64
- ```
65
-
66
- 8. `getResourceReference`
67
- - Returns a resource reference that can be used by MCP clients
68
- - Inputs:
69
- - `resourceId` (number, 1-100): ID of the resource to reference
70
- - Returns: A resource reference with:
71
- - Text introduction
72
- - Embedded resource with `type: "resource"`
73
- - Text instruction for using the resource URI
74
-
75
- 9. `startElicitation`
76
- - Initiates an elicitation (interaction) within the MCP client.
77
- - Inputs:
78
- - `color` (string): Favorite color
79
- - `number` (number, 1-100): Favorite number
80
- - `pets` (enum): Favorite pet
81
- - Returns: Confirmation of the elicitation demo with selection summary.
82
-
83
- 10. `structuredContent`
84
- - Demonstrates a tool returning structured content using the example in the specification
85
- - Provides an output schema to allow testing of client SHOULD advisory to validate the result using the schema
86
- - Inputs:
87
- - `location` (string): A location or ZIP code, mock data is returned regardless of value
88
- - Returns: a response with
89
- - `structuredContent` field conformant to the output schema
90
- - A backward compatible Text Content field, a SHOULD advisory in the specification
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
-
99
- ### Resources
100
-
101
- The server provides 100 test resources in two formats:
102
- - Even numbered resources:
103
- - Plaintext format
104
- - URI pattern: `test://static/resource/{even_number}`
105
- - Content: Simple text description
106
-
107
- - Odd numbered resources:
108
- - Binary blob format
109
- - URI pattern: `test://static/resource/{odd_number}`
110
- - Content: Base64 encoded binary data
111
-
112
- Resource features:
113
- - Supports pagination (10 items per page)
114
- - Allows subscribing to resource updates
115
- - Demonstrates resource templates
116
- - Auto-updates subscribed resources every 5 seconds
117
-
118
- ### Prompts
119
-
120
- 1. `simple_prompt`
121
- - Basic prompt without arguments
122
- - Returns: Single message exchange
123
-
124
- 2. `complex_prompt`
125
- - Advanced prompt demonstrating argument handling
126
- - Required arguments:
127
- - `temperature` (string): Temperature setting
128
- - Optional arguments:
129
- - `style` (string): Output style preference
130
- - Returns: Multi-turn conversation with images
131
-
132
- 3. `resource_prompt`
133
- - Demonstrates embedding resource references in prompts
134
- - Required arguments:
135
- - `resourceId` (number): ID of the resource to embed (1-100)
136
- - Returns: Multi-turn conversation with an embedded resource reference
137
- - Shows how to include resources directly in prompt messages
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
-
151
- ### Logging
152
-
153
- The server sends random-leveled log messages every 15 seconds, e.g.:
12
+ ## Tools, Resources, Prompts, and Other Features
154
13
 
155
- ```json
156
- {
157
- "method": "notifications/message",
158
- "params": {
159
- "level": "info",
160
- "data": "Info-level message"
161
- }
162
- }
163
- ```
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.
164
15
 
165
16
  ## Usage with Claude Desktop (uses [stdio Transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#stdio))
166
17
 
@@ -196,7 +47,7 @@ Add the configuration to your user-level MCP configuration file. Open the Comman
196
47
  **Method 2: Workspace Configuration**
197
48
  Alternatively, you can add the configuration to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others.
198
49
 
199
- > For more details about MCP configuration in VS Code, see the [official VS Code MCP documentation](https://code.visualstudio.com/docs/copilot/mcp).
50
+ > For more details about MCP configuration in VS Code, see the [official VS Code MCP documentation](https://code.visualstudio.com/docs/copilot/customization/mcp-servers).
200
51
 
201
52
  #### NPX
202
53
 
@@ -0,0 +1,44 @@
1
+ # Everything Server – Architecture
2
+
3
+ **Architecture
4
+ | [Project Structure](structure.md)
5
+ | [Startup Process](startup.md)
6
+ | [Server Features](features.md)
7
+ | [Extension Points](extension.md)
8
+ | [How It Works](how-it-works.md)**
9
+
10
+ This documentation summarizes the current layout and runtime architecture of the `src/everything` package.
11
+ It explains how the server starts, how transports are wired, where tools, prompts, and resources are registered, and how to extend the system.
12
+
13
+ ## High‑level Overview
14
+
15
+ ### Purpose
16
+
17
+ A minimal, modular MCP server showcasing core Model Context Protocol features. It exposes simple tools, prompts, and resources, and can be run over multiple transports (STDIO, SSE, and Streamable HTTP).
18
+
19
+ ### Design
20
+
21
+ A small “server factory” constructs the MCP server and registers features.
22
+ Transports are separate entry points that create/connect the server and handle network concerns.
23
+ Tools, prompts, and resources are organized in their own submodules.
24
+
25
+ ### Multi‑client
26
+
27
+ The server supports multiple concurrent clients. Tracking per session data is demonstrated with
28
+ resource subscriptions and simulated logging.
29
+
30
+ ## Build and Distribution
31
+
32
+ - TypeScript sources are compiled into `dist/` via `npm run build`.
33
+ - The `build` script copies `docs/` into `dist/` so instruction files ship alongside the compiled server.
34
+ - The CLI bin is configured in `package.json` as `mcp-server-everything` → `dist/index.js`.
35
+
36
+ ## [Project Structure](structure.md)
37
+
38
+ ## [Startup Process](startup.md)
39
+
40
+ ## [Server Features](features.md)
41
+
42
+ ## [Extension Points](extension.md)
43
+
44
+ ## [How It Works](how-it-works.md)
@@ -0,0 +1,23 @@
1
+ # Everything Server - Extension Points
2
+
3
+ **[Architecture](architecture.md)
4
+ | [Project Structure](structure.md)
5
+ | [Startup Process](startup.md)
6
+ | [Server Features](features.md)
7
+ | Extension Points
8
+ | [How It Works](how-it-works.md)**
9
+
10
+ ## Adding Tools
11
+
12
+ - Create a new file under `tools/` with your `registerXTool(server)` function that registers the tool via `server.registerTool(...)`.
13
+ - Export and call it from `tools/index.ts` inside `registerTools(server)`.
14
+
15
+ ## Adding Prompts
16
+
17
+ - Create a new file under `prompts/` with your `registerXPrompt(server)` function that registers the prompt via `server.registerPrompt(...)`.
18
+ - Export and call it from `prompts/index.ts` inside `registerPrompts(server)`.
19
+
20
+ ## Adding Resources
21
+
22
+ - Create a new file under `resources/` with your `registerXResources(server)` function using `server.registerResource(...)` (optionally with `ResourceTemplate`).
23
+ - Export and call it from `resources/index.ts` inside `registerResources(server)`.
@@ -0,0 +1,52 @@
1
+ # Everything Server - Features
2
+
3
+ **[Architecture](architecture.md)
4
+ | [Project Structure](structure.md)
5
+ | [Startup Process](startup.md)
6
+ | Server Features
7
+ | [Extension Points](extension.md)
8
+ | [How It Works](how-it-works.md)**
9
+
10
+ ## Tools
11
+
12
+ - `echo` (tools/echo.ts): Echoes the provided `message: string`. Uses Zod to validate inputs.
13
+ - `get-annotated-message` (tools/get-annotated-message.ts): Returns a `text` message annotated with `priority` and `audience` based on `messageType` (`error`, `success`, or `debug`); can optionally include an annotated `image`.
14
+ - `get-env` (tools/get-env.ts): Returns all environment variables from the running process as pretty-printed JSON text.
15
+ - `get-resource-links` (tools/get-resource-links.ts): 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`.
16
+ - `get-resource-reference` (tools/get-resource-reference.ts): 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`.
17
+ - `get-roots-list` (tools/get-roots-list.ts): Returns the last list of roots sent by the client.
18
+ - `gzip-file-as-resource` (tools/gzip-file-as-resource.ts): Accepts a `name` and `data` (URL or data URI), fetches the data subject to size/time/domain constraints, compresses it, registers it as a session resource at `demo://resource/session/<name>` with `mimeType: application/gzip`, and returns either a `resource_link` (default) or an inline `resource` depending on `outputType`.
19
+ - `get-structured-content` (tools/get-structured-content.ts): Demonstrates structured responses. Accepts `location` input and returns both backward‑compatible `content` (a `text` block containing JSON) and `structuredContent` validated by an `outputSchema` (temperature, conditions, humidity).
20
+ - `get-sum` (tools/get-sum.ts): For two numbers `a` and `b` calculates and returns their sum. Uses Zod to validate inputs.
21
+ - `get-tiny-image` (tools/get-tiny-image.ts): Returns a tiny PNG MCP logo as an `image` content item with brief descriptive text before and after.
22
+ - `trigger-long-running-operation` (tools/trigger-trigger-long-running-operation.ts): 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.
23
+ - `toggle-simulated-logging` (tools/toggle-simulated-logging.ts): Starts or stops simulated, random‑leveled logging for the invoking session. Respects the client’s selected minimum logging level.
24
+ - `toggle-subscriber-updates` (tools/toggle-subscriber-updates.ts): Starts or stops simulated resource update notifications for URIs the invoking session has subscribed to.
25
+ - `trigger-sampling-request` (tools/trigger-sampling-request.ts): Issues a `sampling/createMessage` request to the client/LLM using provided `prompt` and optional generation controls; returns the LLM’s response payload.
26
+
27
+ ## Prompts
28
+
29
+ - `simple-prompt` (prompts/simple.ts): No-argument prompt that returns a static user message.
30
+ - `args-prompt` (prompts/args.ts): Two-argument prompt with `city` (required) and `state` (optional) used to compose a question.
31
+ - `completable-prompt` (prompts/completions.ts): Demonstrates argument auto-completions with the SDK’s `completable` helper; `department` completions drive context-aware `name` suggestions.
32
+ - `resource-prompt` (prompts/resource.ts): Accepts `resourceType` ("Text" or "Blob") and `resourceId` (string convertible to integer) and returns messages that include an embedded dynamic resource of the selected type generated via `resources/templates.ts`.
33
+
34
+ ## Resources
35
+
36
+ - Dynamic Text: `demo://resource/dynamic/text/{index}` (content generated on the fly)
37
+ - Dynamic Blob: `demo://resource/dynamic/blob/{index}` (base64 payload generated on the fly)
38
+ - Static Documents: `demo://resource/static/document/<filename>` (serves files from `src/everything/docs/` as static file-based resources)
39
+ - Session Scoped: `demo://resource/session/<name>` (per-session resources registered dynamically; available only for the lifetime of the session)
40
+
41
+ ## Resource Subscriptions and Notifications
42
+
43
+ - Simulated update notifications are opt‑in and off by default.
44
+ - Clients may subscribe/unsubscribe to resource URIs using the MCP `resources/subscribe` and `resources/unsubscribe` requests.
45
+ - Use the `toggle-subscriber-updates` tool to start/stop a per‑session interval that emits `notifications/resources/updated { uri }` only for URIs that session has subscribed to.
46
+ - Multiple concurrent clients are supported; each client’s subscriptions are tracked per session and notifications are delivered independently via the server instance associated with that session.
47
+
48
+ ## Simulated Logging
49
+
50
+ - Simulated logging is available but off by default.
51
+ - Use the `toggle-simulated-logging` tool to start/stop periodic log messages of varying levels (debug, info, notice, warning, error, critical, alert, emergency) per session.
52
+ - Clients can control the minimum level they receive via the standard MCP `logging/setLevel` request.
@@ -0,0 +1,45 @@
1
+ # Everything Server - How It Works
2
+
3
+ **[Architecture](architecture.md)
4
+ | [Project Structure](structure.md)
5
+ | [Startup Process](startup.md)
6
+ | [Server Features](features.md)
7
+ | [Extension Points](extension.md)
8
+ | How It Works**
9
+
10
+ # Conditional Tool Registration
11
+
12
+ ### Module: `server/index.ts`
13
+
14
+ - Some tools require client support for the capability they demonstrate. These are:
15
+ - `get-roots-list`
16
+ - `trigger-elicitation-request`
17
+ - `trigger-sampling-request`
18
+ - Client capabilities aren't known until after initilization handshake is complete.
19
+ - Most tools are registered immediately during the Server Factory execution, prior to client connection.
20
+ - To defer registration of these commands until client capabilities are known, a `registerConditionalTools(server)` function is invoked from an `onintitialized` handler.
21
+
22
+ ## Resource Subscriptions
23
+
24
+ ### Module: `resources/subscriptions.ts`
25
+
26
+ - Tracks subscribers per URI: `Map<uri, Set<sessionId>>`.
27
+ - Installs handlers via `setSubscriptionHandlers(server)` to process subscribe/unsubscribe requests and keep the map updated.
28
+ - Updates are started/stopped on demand by the `toggle-subscriber-updates` tool, which calls `beginSimulatedResourceUpdates(server, sessionId)` and `stopSimulatedResourceUpdates(sessionId)`.
29
+ - `cleanup(sessionId?)` calls `stopSimulatedResourceUpdates(sessionId)` to clear intervals and remove session‑scoped state.
30
+
31
+ ## Session‑scoped Resources
32
+
33
+ ### Module: `resources/session.ts`
34
+
35
+ - `getSessionResourceURI(name: string)`: Builds a session resource URI: `demo://resource/session/<name>`.
36
+ - `registerSessionResource(server, resource, type, payload)`: Registers a resource with the given `uri`, `name`, and `mimeType`, returning a `resource_link`. The content is served from memory for the life of the session only. Supports `type: "text" | "blob"` and returns data in the corresponding field.
37
+ - Intended usage: tools can create and expose per-session artifacts without persisting them. For example, `tools/gzip-file-as-resource.ts` compresses fetched content, registers it as a session resource with `mimeType: application/gzip`, and returns either a `resource_link` or an inline `resource` based on `outputType`.
38
+
39
+ ## Simulated Logging
40
+
41
+ ### Module: `server/logging.ts`
42
+
43
+ - Periodically sends randomized log messages at different levels. Messages can include the session ID for clarity during demos.
44
+ - Started/stopped on demand via the `toggle-simulated-logging` tool, which calls `beginSimulatedLogging(server, sessionId?)` and `stopSimulatedLogging(sessionId?)`. Note that transport disconnect triggers `cleanup()` which also stops any active intervals.
45
+ - Uses `server.sendLoggingMessage({ level, data }, sessionId?)` so that the client’s configured minimum logging level is respected by the SDK.
@@ -0,0 +1,28 @@
1
+ # Everything Server – Server Instructions
2
+
3
+ Audience: These instructions are written for an LLM or autonomous agent integrating with the Everything MCP Server.
4
+ Follow them to use, extend, and troubleshoot the server safely and effectively.
5
+
6
+ ## Cross-Feature Relationships
7
+
8
+ - Use `get-roots-list` to see client workspace roots before file operations
9
+ - `gzip-file-as-resource` creates session-scoped resources accessible only during the current session
10
+ - Enable `toggle-simulated-logging` before debugging to see server log messages
11
+ - Enable `toggle-subscriber-updates` to receive periodic resource update notifications
12
+
13
+ ## Constraints & Limitations
14
+
15
+ - `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`
16
+ - Session resources are ephemeral and lost when the session ends
17
+ - Sampling requests (`trigger-sampling-request`) require client sampling capability
18
+ - Elicitation requests (`trigger-elicitation-request`) require client elicitation capability
19
+
20
+ ## Operational Patterns
21
+
22
+ - For long operations, use `trigger-long-running-operation` which sends progress notifications
23
+ - Prefer reading resources before calling mutating tools
24
+ - Check `get-roots-list` output to understand the client's workspace context
25
+
26
+ ## Easter Egg
27
+
28
+ 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."
@@ -0,0 +1,73 @@
1
+ # Everything Server - Startup Process
2
+
3
+ **[Architecture](architecture.md)
4
+ | [Project Structure](structure.md)
5
+ | Startup Process
6
+ | [Server Features](features.md)
7
+ | [Extension Points](extension.md)
8
+ | [How It Works](how-it-works.md)**
9
+
10
+ ## 1. Everything Server Launcher
11
+
12
+ - Usage `node dist/index.js [stdio|sse|streamableHttp]`
13
+ - Runs the specified **transport manager** to handle client connections.
14
+ - Specify transport type on command line (default `stdio`)
15
+ - `stdio` → `transports/stdio.js`
16
+ - `sse` → `transports/sse.js`
17
+ - `streamableHttp` → `transports/streamableHttp.js`
18
+
19
+ ## 2. The Transport Manager
20
+
21
+ - Creates a server instance using `createServer()` from `server/index.ts`
22
+ - Connects it to the chosen transport type from the MCP SDK.
23
+ - Handles communication according to the MCP specs for the chosen transport.
24
+ - **STDIO**:
25
+ - One simple, process‑bound connection.
26
+ - Calls`clientConnect()` upon connection.
27
+ - Closes and calls `cleanup()` on `SIGINT`.
28
+ - **SSE**:
29
+ - Supports multiple client connections.
30
+ - Client transports are mapped to `sessionId`;
31
+ - Calls `clientConnect(sessionId)` upon connection.
32
+ - Hooks server’s `onclose` to clean and remove session.
33
+ - Exposes
34
+ - `/sse` **GET** (SSE stream)
35
+ - `/message` **POST** (JSON‑RPC messages)
36
+ - **Streamable HTTP**:
37
+ - Supports multiple client connections.
38
+ - Client transports are mapped to `sessionId`;
39
+ - Calls `clientConnect(sessionId)` upon connection.
40
+ - Exposes `/mcp` for
41
+ - **POST** (JSON‑RPC messages)
42
+ - **GET** (SSE stream)
43
+ - **DELETE** (termination)
44
+ - Uses an event store for resumability and stores transports by `sessionId`.
45
+ - Calls `cleanup(sessionId)` on **DELETE**.
46
+
47
+ ## 3. The Server Factory
48
+
49
+ - Invoke `createServer()` from `server/index.ts`
50
+ - Creates a new `McpServer` instance with
51
+ - **Capabilities**:
52
+ - `tools: {}`
53
+ - `logging: {}`
54
+ - `prompts: {}`
55
+ - `resources: { subscribe: true }`
56
+ - **Server Instructions**
57
+ - Loaded from the docs folder (`server-instructions.md`).
58
+ - **Registrations**
59
+ - Registers **tools** via `registerTools(server)`.
60
+ - Registers **resources** via `registerResources(server)`.
61
+ - Registers **prompts** via `registerPrompts(server)`.
62
+ - **Other Request Handlers**
63
+ - Sets up resource subscription handlers via `setSubscriptionHandlers(server)`.
64
+ - Roots list change handler is added post-connection via
65
+ - **Returns**
66
+ - The `McpServer` instance
67
+ - A `clientConnect(sessionId)` callback that enables post-connection setup
68
+ - A `cleanup(sessionId?)` callback that stops any active intervals and removes any session‑scoped state
69
+
70
+ ## Enabling Multiple Clients
71
+
72
+ Some of the transport managers defined in the `transports` folder can support multiple clients.
73
+ In order to do so, they must map certain data to a session identifier.
@@ -0,0 +1,182 @@
1
+ # Everything Server - Project Structure
2
+
3
+ **[Architecture](architecture.md)
4
+ | Project Structure
5
+ | [Startup Process](startup.md)
6
+ | [Server Features](features.md)
7
+ | [Extension Points](extension.md)
8
+ | [How It Works](how-it-works.md)**
9
+
10
+ ```
11
+ src/everything
12
+ ├── index.ts
13
+ ├── AGENTS.md
14
+ ├── package.json
15
+ ├── docs
16
+ │ ├── architecture.md
17
+ │ ├── extension.md
18
+ │ ├── features.md
19
+ │ ├── how-it-works.md
20
+ │ ├── instructions.md
21
+ │ ├── startup.md
22
+ │ └── structure.md
23
+ ├── prompts
24
+ │ ├── index.ts
25
+ │ ├── args.ts
26
+ │ ├── completions.ts
27
+ │ ├── simple.ts
28
+ │ └── resource.ts
29
+ ├── resources
30
+ │ ├── index.ts
31
+ │ ├── files.ts
32
+ │ ├── session.ts
33
+ │ ├── subscriptions.ts
34
+ │ └── templates.ts
35
+ ├── server
36
+ │ ├── index.ts
37
+ │ ├── logging.ts
38
+ │ └── roots.ts
39
+ ├── tools
40
+ │ ├── index.ts
41
+ │ ├── echo.ts
42
+ │ ├── get-annotated-message.ts
43
+ │ ├── get-env.ts
44
+ │ ├── get-resource-links.ts
45
+ │ ├── get-resource-reference.ts
46
+ │ ├── get-roots-list.ts
47
+ │ ├── get-structured-content.ts
48
+ │ ├── get-sum.ts
49
+ │ ├── get-tiny-image.ts
50
+ │ ├── gzip-file-as-resource.ts
51
+ │ ├── toggle-simulated-logging.ts
52
+ │ ├── toggle-subscriber-updates.ts
53
+ │ ├── trigger-elicitation-request.ts
54
+ │ ├── trigger-long-running-operation.ts
55
+ │ └── trigger-sampling-request.ts
56
+ └── transports
57
+ ├── sse.ts
58
+ ├── stdio.ts
59
+ └── streamableHttp.ts
60
+ ```
61
+
62
+ # Project Contents
63
+
64
+ ## `src/everything`:
65
+
66
+ ### `index.ts`
67
+
68
+ - CLI entry point that selects and runs a specific transport module based on the first CLI argument: `stdio`, `sse`, or `streamableHttp`.
69
+
70
+ ### `AGENTS.md`
71
+
72
+ - Directions for Agents/LLMs explaining coding guidelines and how to appropriately extend the server.
73
+
74
+ ### `package.json`
75
+
76
+ - Package metadata and scripts:
77
+ - `build`: TypeScript compile to `dist/`, copies `docs/` into `dist/` and marks the compiled entry scripts as executable.
78
+ - `start:stdio`, `start:sse`, `start:streamableHttp`: Run built transports from `dist/`.
79
+ - Declares dependencies on `@modelcontextprotocol/sdk`, `express`, `cors`, `zod`, etc.
80
+
81
+ ### `docs/`
82
+
83
+ - `architecture.md`
84
+ - This document.
85
+ - `server-instructions.md`
86
+ - Human‑readable instructions intended to be passed to the client/LLM as for guidance on server use. Loaded by the server at startup and returned in the "initialize" exchange.
87
+
88
+ ### `prompts/`
89
+
90
+ - `index.ts`
91
+ - `registerPrompts(server)` orchestrator; delegates to prompt factory/registration methods from in individual prompt files.
92
+ - `simple.ts`
93
+ - Registers `simple-prompt`: a prompt with no arguments that returns a single user message.
94
+ - `args.ts`
95
+ - Registers `args-prompt`: a prompt with two arguments (`city` required, `state` optional) used to compose a message.
96
+ - `completions.ts`
97
+ - Registers `completable-prompt`: a prompt whose arguments support server-driven completions using the SDK’s `completable(...)` helper (e.g., completing `department` and context-aware `name`).
98
+ - `resource.ts`
99
+ - Exposes `registerEmbeddedResourcePrompt(server)` which registers `resource-prompt` — a prompt that accepts `resourceType` ("Text" or "Blob") and `resourceId` (integer), and embeds a dynamically generated resource of the requested type within the returned messages. Internally reuses helpers from `resources/templates.ts`.
100
+
101
+ ### `resources/`
102
+
103
+ - `index.ts`
104
+ - `registerResources(server)` orchestrator; delegates to resource factory/registration methods from individual resource files.
105
+ - `templates.ts`
106
+ - Registers two dynamic, template‑driven resources using `ResourceTemplate`:
107
+ - Text: `demo://resource/dynamic/text/{index}` (MIME: `text/plain`)
108
+ - Blob: `demo://resource/dynamic/blob/{index}` (MIME: `application/octet-stream`, Base64 payload)
109
+ - The `{index}` path variable must be a finite positive integer. Content is generated on demand with a timestamp.
110
+ - 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).
111
+ - `files.ts`
112
+ - Registers static file-based resources for each file in the `docs/` folder.
113
+ - URIs follow the pattern: `demo://resource/static/document/<filename>`.
114
+ - Serves markdown files as `text/markdown`, `.txt` as `text/plain`, `.json` as `application/json`, others default to `text/plain`.
115
+
116
+ ### `server/`
117
+
118
+ - `index.ts`
119
+ - Server factory that creates an `McpServer` with declared capabilities, loads server instructions, and registers tools, prompts, and resources.
120
+ - Sets resource subscription handlers via `setSubscriptionHandlers(server)`.
121
+ - Exposes `{ server, cleanup }` to the chosen transport. Cleanup stops any running intervals in the server when the transport disconnects.
122
+ - `logging.ts`
123
+ - Implements simulated logging. Periodically sends randomized log messages at various levels to the connected client session. Started/stopped on demand via a dedicated tool.
124
+
125
+ ### `tools/`
126
+
127
+ - `index.ts`
128
+ - `registerTools(server)` orchestrator; delegates to tool factory/registration methods in individual tool files.
129
+ - `echo.ts`
130
+ - Registers an `echo` tool that takes a message and returns `Echo: {message}`.
131
+ - `get-annotated-message.ts`
132
+ - Registers an `annotated-message` tool which demonstrates annotated content items by emitting a primary `text` message with `annotations` that vary by `messageType` (`"error" | "success" | "debug"`), and optionally includes an annotated `image` (tiny PNG) when `includeImage` is true.
133
+ - `get-env.ts`
134
+ - Registers a `get-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration.
135
+ - `get-resource-links.ts`
136
+ - Registers a `get-resource-links` tool that returns an intro `text` block followed by multiple `resource_link` items.
137
+ - `get-resource-reference.ts`
138
+ - Registers a `get-resource-reference` tool that returns a reference for a selected dynamic resource.
139
+ - `get-roots-list.ts`
140
+ - Registers a `get-roots-list` tool that returns the last list of roots sent by the client.
141
+ - `gzip-file-as-resource.ts`
142
+ - Registers a `gzip-file-as-resource` tool that fetches content from a URL or data URI, compresses it, and then either:
143
+ - returns a `resource_link` to a session-scoped resource (default), or
144
+ - returns an inline `resource` with the gzipped data. The resource will be still discoverable for the duration of the session via `resources/list`.
145
+ - Uses `resources/session.ts` to register the gzipped blob as a per-session resource at a URI like `demo://resource/session/<name>` with `mimeType: application/gzip`.
146
+ - Environment controls:
147
+ - `GZIP_MAX_FETCH_SIZE` (bytes, default 10 MiB)
148
+ - `GZIP_MAX_FETCH_TIME_MILLIS` (ms, default 30000)
149
+ - `GZIP_ALLOWED_DOMAINS` (comma-separated allowlist; empty means all domains allowed)
150
+ - `trigger-elicitation-request.ts`
151
+ - Registers a `trigger-elicitation-request` tool that sends an `elicitation/create` request to the client/LLM and returns the elicitation result.
152
+ - `trigger-sampling-request.ts`
153
+ - Registers a `trigger-sampling-request` tool that sends a `sampling/createMessage` request to the client/LLM and returns the sampling result.
154
+ - `get-structured-content.ts`
155
+ - Registers a `get-structured-content` tool that demonstrates structuredContent block responses.
156
+ - `get-sum.ts`
157
+ - Registers an `get-sum` tool with a Zod input schema that sums two numbers `a` and `b` and returns the result.
158
+ - `get-tiny-image.ts`
159
+ - Registers a `get-tiny-image` tool, which returns a tiny PNG MCP logo as an `image` content item, along with surrounding descriptive `text` items.
160
+ - `trigger-long-running-operation.ts`
161
+ - Registers a `long-running-operation` tool that simulates a long-running task over a specified `duration` (seconds) and number of `steps`; emits `notifications/progress` updates when the client supplies a `progressToken`.
162
+ - `toggle-simulated-logging.ts`
163
+ - Registers a `toggle-simulated-logging` tool, which starts or stops simulated logging for the invoking session.
164
+ - `toggle-subscriber-updates.ts`
165
+ - Registers a `toggle-subscriber-updates` tool, which starts or stops simulated resource subscription update checks for the invoking session.
166
+
167
+ ### `transports/`
168
+
169
+ - `stdio.ts`
170
+ - Starts a `StdioServerTransport`, created the server via `createServer()`, and connects it.
171
+ - Handles `SIGINT` to close cleanly and calls `cleanup()` to remove any live intervals.
172
+ - `sse.ts`
173
+ - Express server exposing:
174
+ - `GET /sse` to establish an SSE connection per session.
175
+ - `POST /message` for client messages.
176
+ - Manages multiple connected clients via a transport map.
177
+ - Starts an `SSEServerTransport`, created the server via `createServer()`, and connects it to a new transport.
178
+ - On server disconnect, calls `cleanup()` to remove any live intervals.
179
+ - `streamableHttp.ts`
180
+ - Express server exposing a single `/mcp` endpoint for POST (JSON‑RPC), GET (SSE stream), and DELETE (session termination) using `StreamableHTTPServerTransport`.
181
+ - Uses an `InMemoryEventStore` for resumable sessions and tracks transports by `sessionId`.
182
+ - Connects a fresh server instance on initialization POST and reuses the transport for subsequent requests.