@modelcontextprotocol/server-everything 0.6.2 → 1.0.0

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 (51) hide show
  1. package/README.md +121 -72
  2. package/dist/docs/architecture.md +44 -0
  3. package/dist/docs/extension.md +23 -0
  4. package/dist/docs/features.md +105 -0
  5. package/dist/docs/how-it-works.md +45 -0
  6. package/dist/docs/instructions.md +37 -0
  7. package/dist/docs/startup.md +76 -0
  8. package/dist/docs/structure.md +212 -0
  9. package/dist/index.js +73 -16
  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 +62 -0
  18. package/dist/resources/subscriptions.js +144 -0
  19. package/dist/resources/templates.js +166 -0
  20. package/dist/server/index.js +95 -0
  21. package/dist/server/logging.js +70 -0
  22. package/dist/server/roots.js +70 -0
  23. package/dist/tools/echo.js +35 -0
  24. package/dist/tools/get-annotated-message.js +89 -0
  25. package/dist/tools/get-env.js +34 -0
  26. package/dist/tools/get-resource-links.js +68 -0
  27. package/dist/tools/get-resource-reference.js +81 -0
  28. package/dist/tools/get-roots-list.js +77 -0
  29. package/dist/tools/get-structured-content.js +78 -0
  30. package/dist/tools/get-sum.js +46 -0
  31. package/dist/tools/get-tiny-image.js +47 -0
  32. package/dist/tools/gzip-file-as-resource.js +194 -0
  33. package/dist/tools/index.js +52 -0
  34. package/dist/tools/simulate-research-query.js +251 -0
  35. package/dist/tools/toggle-simulated-logging.js +47 -0
  36. package/dist/tools/toggle-subscriber-updates.js +50 -0
  37. package/dist/tools/trigger-elicitation-request-async.js +227 -0
  38. package/dist/tools/trigger-elicitation-request.js +222 -0
  39. package/dist/tools/trigger-long-running-operation.js +65 -0
  40. package/dist/tools/trigger-sampling-request-async.js +174 -0
  41. package/dist/tools/trigger-sampling-request.js +77 -0
  42. package/dist/tools/trigger-url-elicitation.js +169 -0
  43. package/dist/transports/in-memory-event-store.js +44 -0
  44. package/dist/transports/listen.js +36 -0
  45. package/dist/transports/sse.js +103 -0
  46. package/dist/transports/stdio.js +48 -0
  47. package/dist/transports/streamableHttp.js +240 -0
  48. package/dist/version.js +35 -0
  49. package/package.json +32 -13
  50. package/dist/everything.js +0 -361
  51. package/dist/sse.js +0 -24
package/README.md CHANGED
@@ -1,78 +1,19 @@
1
- # Everything MCP Server
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. `sampleLLM`
31
- - Demonstrates LLM sampling capability using MCP sampling feature
32
- - Inputs:
33
- - `prompt` (string): The prompt to send to the LLM
34
- - `maxTokens` (number, default: 100): Maximum tokens to generate
35
- - Returns: Generated LLM response
36
-
37
- 5. `getTinyImage`
38
- - Returns a small test image
39
- - No inputs required
40
- - Returns: Base64 encoded PNG image data
41
-
42
- ### Resources
43
-
44
- The server provides 100 test resources in two formats:
45
- - Even numbered resources:
46
- - Plaintext format
47
- - URI pattern: `test://static/resource/{even_number}`
48
- - Content: Simple text description
49
-
50
- - Odd numbered resources:
51
- - Binary blob format
52
- - URI pattern: `test://static/resource/{odd_number}`
53
- - Content: Base64 encoded binary data
54
-
55
- Resource features:
56
- - Supports pagination (10 items per page)
57
- - Allows subscribing to resource updates
58
- - Demonstrates resource templates
59
- - Auto-updates subscribed resources every 5 seconds
60
-
61
- ### Prompts
62
-
63
- 1. `simple_prompt`
64
- - Basic prompt without arguments
65
- - Returns: Single message exchange
66
-
67
- 2. `complex_prompt`
68
- - Advanced prompt demonstrating argument handling
69
- - Required arguments:
70
- - `temperature` (number): Temperature setting
71
- - Optional arguments:
72
- - `style` (string): Output style preference
73
- - Returns: Multi-turn conversation with images
74
-
75
- ## Usage with Claude Desktop
12
+ ## Tools, Resources, Prompts, and Other Features
13
+
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
+
16
+ ## Usage with Claude Desktop (uses [stdio Transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#stdio))
76
17
 
77
18
  Add to your `claude_desktop_config.json`:
78
19
 
@@ -89,3 +30,111 @@ Add to your `claude_desktop_config.json`:
89
30
  }
90
31
  }
91
32
  ```
33
+
34
+ On Windows, use `cmd /c` to launch `npx`:
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "everything": {
40
+ "command": "cmd",
41
+ "args": [
42
+ "/c",
43
+ "npx",
44
+ "-y",
45
+ "@modelcontextprotocol/server-everything"
46
+ ]
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## Usage with VS Code
53
+
54
+ For quick installation, use one of the one-click install buttons below...
55
+
56
+ [![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-NPM-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=everything&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40modelcontextprotocol%2Fserver-everything%22%5D%7D) [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-NPM-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=everything&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40modelcontextprotocol%2Fserver-everything%22%5D%7D&quality=insiders)
57
+
58
+ [![Install with Docker in VS Code](https://img.shields.io/badge/VS_Code-Docker-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=everything&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22mcp%2Feverything%22%5D%7D) [![Install with Docker in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Docker-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=everything&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22mcp%2Feverything%22%5D%7D&quality=insiders)
59
+
60
+ For manual installation, you can configure the MCP server using one of these methods:
61
+
62
+ **Method 1: User Configuration (Recommended)**
63
+ Add the configuration to your user-level MCP configuration file. Open the Command Palette (`Ctrl + Shift + P`) and run `MCP: Open User Configuration`. This will open your user `mcp.json` file where you can add the server configuration.
64
+
65
+ **Method 2: Workspace Configuration**
66
+ 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.
67
+
68
+ > 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).
69
+
70
+ #### NPX
71
+
72
+ ```json
73
+ {
74
+ "servers": {
75
+ "everything": {
76
+ "command": "npx",
77
+ "args": ["-y", "@modelcontextprotocol/server-everything"]
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ On Windows, use:
84
+
85
+ ```json
86
+ {
87
+ "servers": {
88
+ "everything": {
89
+ "command": "cmd",
90
+ "args": ["/c", "npx", "-y", "@modelcontextprotocol/server-everything"]
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ## Running from source with [HTTP+SSE Transport](https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse) (deprecated as of [2025-03-26](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports))
97
+
98
+ ```shell
99
+ cd src/everything
100
+ npm install
101
+ npm run start:sse
102
+ ```
103
+
104
+ ## Run from source with [Streamable HTTP Transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http)
105
+
106
+ ```shell
107
+ cd src/everything
108
+ npm install
109
+ npm run start:streamableHttp
110
+ ```
111
+
112
+ ## Running as an installed package
113
+ ### Install
114
+ ```shell
115
+ npm install -g @modelcontextprotocol/server-everything@latest
116
+ ```
117
+
118
+ ### Run the default (stdio) server
119
+ ```shell
120
+ npx @modelcontextprotocol/server-everything
121
+ ```
122
+
123
+ ### Or specify stdio explicitly
124
+ ```shell
125
+ npx @modelcontextprotocol/server-everything stdio
126
+ ```
127
+
128
+ ### Run the SSE server
129
+ ```shell
130
+ npx @modelcontextprotocol/server-everything sse
131
+ ```
132
+
133
+ ### Run the streamable HTTP server
134
+ ```shell
135
+ npx @modelcontextprotocol/server-everything streamableHttp
136
+ ```
137
+
138
+ ## License
139
+
140
+ 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.
@@ -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,105 @@
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-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-elicitation-request` (tools/trigger-elicitation-request.ts): Issues an `elicitation/create` request using form-mode fields (strings, numbers, booleans, enums, and format validation) and returns the resulting action/content. Requires client form-mode elicitation: `elicitation.form`, or an `elicitation` object that declares neither mode.
26
+ - `trigger-url-elicitation` (tools/trigger-url-elicitation.ts): Issues an `elicitation/create` request in URL mode (`mode: "url"`) with an `elicitationId`, or throws MCP error `-32042` (`UrlElicitationRequiredError`) when `errorPath=true`. On the error path the prerequisite elicitation it returns points at a different URL than the failing request (`https://modelcontextprotocol.io`); when the client satisfies it and retries the same call, the retry ignores `errorPath` and proceeds via the request path, so the client does not loop on the same error. The retry marker is one-shot per `(session, url, elicitationId)`: it is cleared on the recognized retry, so re-running the error path with identical arguments without an intervening prerequisite is treated as a retry and proceeds. Requires client capability `elicitation.url`.
27
+ - `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.
28
+ - `simulate-research-query` (tools/simulate-research-query.ts): Demonstrates MCP Tasks (SEP-1686) with a simulated multi-stage research operation. Accepts `topic` and `ambiguous` parameters. Returns a task that progresses through stages with status updates. If `ambiguous` is true and client supports elicitation, sends an elicitation request directly to gather clarification before completing.
29
+ - `trigger-sampling-request-async` (tools/trigger-sampling-request-async.ts): Demonstrates bidirectional tasks where the server sends a sampling request that the client executes as a background task. Server polls for status and retrieves the LLM result when complete. Requires client to support `tasks.requests.sampling.createMessage`.
30
+ - `trigger-elicitation-request-async` (tools/trigger-elicitation-request-async.ts): Demonstrates bidirectional tasks where the server sends an elicitation request that the client executes as a background task. Server polls while waiting for user input. Requires client form-mode elicitation (as for `trigger-elicitation-request`) and `tasks.requests.elicitation.create`.
31
+
32
+ ## Prompts
33
+
34
+ - `simple-prompt` (prompts/simple.ts): No-argument prompt that returns a static user message.
35
+ - `args-prompt` (prompts/args.ts): Two-argument prompt with `city` (required) and `state` (optional) used to compose a question.
36
+ - `completable-prompt` (prompts/completions.ts): Demonstrates argument auto-completions with the SDK’s `completable` helper; `department` completions drive context-aware `name` suggestions.
37
+ - `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`.
38
+
39
+ ## Resources
40
+
41
+ - Dynamic Text: `demo://resource/dynamic/text/{index}` (content generated on the fly)
42
+ - Dynamic Blob: `demo://resource/dynamic/blob/{index}` (base64 payload generated on the fly)
43
+ - Static Documents: `demo://resource/static/document/<filename>` (serves files from `src/everything/docs/` as static file-based resources)
44
+ - Session Scoped: `demo://resource/session/<name>` (per-session resources registered dynamically; available only for the lifetime of the session)
45
+
46
+ ## Resource Subscriptions and Notifications
47
+
48
+ - Simulated update notifications are opt‑in and off by default.
49
+ - Clients may subscribe/unsubscribe to resource URIs using the MCP `resources/subscribe` and `resources/unsubscribe` requests.
50
+ - 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.
51
+ - 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.
52
+
53
+ ## Simulated Logging
54
+
55
+ - Simulated logging is available but off by default.
56
+ - 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.
57
+ - Clients can control the minimum level they receive via the standard MCP `logging/setLevel` request.
58
+
59
+ ## Tasks (SEP-1686)
60
+
61
+ The server advertises support for MCP Tasks, enabling long-running operations with status tracking:
62
+
63
+ - **Capabilities advertised**: `tasks.list`, `tasks.cancel`, `tasks.requests.tools.call`
64
+ - **Task Store**: Uses `InMemoryTaskStore` from SDK experimental for task lifecycle management
65
+ - **Message Queue**: Uses `InMemoryTaskMessageQueue` for task-related messaging
66
+
67
+ ### Task Lifecycle
68
+
69
+ 1. Client calls `tools/call` with `task: true` parameter
70
+ 2. Server returns `CreateTaskResult` with `taskId` instead of immediate result
71
+ 3. Client polls `tasks/get` to check status and receive `statusMessage` updates
72
+ 4. When status is `completed`, client calls `tasks/result` to retrieve the final result
73
+
74
+ ### Task Statuses
75
+
76
+ - `working`: Task is actively processing
77
+ - `input_required`: Task needs additional input (server sends elicitation request directly)
78
+ - `completed`: Task finished successfully
79
+ - `failed`: Task encountered an error
80
+ - `cancelled`: Task was cancelled by client
81
+
82
+ ### Demo Tools
83
+
84
+ **Server-side tasks (client calls server):**
85
+ Use the `simulate-research-query` tool to exercise the full task lifecycle. Set `ambiguous: true` to trigger elicitation - the server will send an `elicitation/create` request directly and await the response before completing.
86
+
87
+ **Client-side tasks (server calls client):**
88
+ Use `trigger-sampling-request-async` or `trigger-elicitation-request-async` to demonstrate bidirectional tasks where the server sends requests that the client executes as background tasks. These require the client to advertise `sampling` with `tasks.requests.sampling.createMessage`, or form-mode `elicitation` with `tasks.requests.elicitation.create`, respectively.
89
+
90
+ ### Bidirectional Task Flow
91
+
92
+ MCP Tasks are bidirectional - both server and client can be task executors:
93
+
94
+ | Direction | Request Type | Task Executor | Demo Tool |
95
+ | ---------------- | ------------------------ | ------------- | ----------------------------------- |
96
+ | Client -> Server | `tools/call` | Server | `simulate-research-query` |
97
+ | Server -> Client | `sampling/createMessage` | Client | `trigger-sampling-request-async` |
98
+ | Server -> Client | `elicitation/create` | Client | `trigger-elicitation-request-async` |
99
+
100
+ For client-side tasks:
101
+
102
+ 1. Server sends request with task metadata (e.g., `params.task.ttl`)
103
+ 2. Client creates task and returns `CreateTaskResult` with `taskId`
104
+ 3. Server polls `tasks/get` for status updates
105
+ 4. When complete, server calls `tasks/result` to retrieve the result
@@ -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,37 @@
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
+ - If `get-roots-list` is in your tool list, use it 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
+
18
+ ## Capability-Gated Tools
19
+
20
+ Registered only if your client declared the capability shown. Otherwise they are absent from `tools/list`, so do not call them:
21
+
22
+ - `get-roots-list`: `roots`
23
+ - `trigger-sampling-request`: `sampling`
24
+ - `trigger-elicitation-request`: `elicitation.form`, or `elicitation` with no mode
25
+ - `trigger-url-elicitation`: `elicitation.url`
26
+ - `trigger-sampling-request-async`: `sampling` and `tasks.requests.sampling.createMessage`
27
+ - `trigger-elicitation-request-async`: form-mode `elicitation` and `tasks.requests.elicitation.create`
28
+
29
+ ## Operational Patterns
30
+
31
+ - For long operations, use `trigger-long-running-operation` which sends progress notifications
32
+ - Prefer reading resources before calling mutating tools
33
+ - If `get-roots-list` is in your tool list, check its output to understand the client's workspace context
34
+
35
+ ## Easter Egg
36
+
37
+ 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,76 @@
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
+ - **SSE** and **Streamable HTTP** bind their port (`PORT`, default `3001`) through `listenOrExit()` in `transports/listen.ts`.
47
+ - The listening line is printed only once the port is bound.
48
+ - A bind failure, such as a port already in use, is reported on stderr and the process exits non-zero.
49
+
50
+ ## 3. The Server Factory
51
+
52
+ - Invoke `createServer()` from `server/index.ts`
53
+ - Creates a new `McpServer` instance with
54
+ - **Capabilities**:
55
+ - `tools: {}`
56
+ - `logging: {}`
57
+ - `prompts: {}`
58
+ - `resources: { subscribe: true }`
59
+ - **Server Instructions**
60
+ - Loaded from the docs folder (`instructions.md`).
61
+ - **Registrations**
62
+ - Registers **tools** via `registerTools(server)`.
63
+ - Registers **resources** via `registerResources(server)`.
64
+ - Registers **prompts** via `registerPrompts(server)`.
65
+ - **Other Request Handlers**
66
+ - Sets up resource subscription handlers via `setSubscriptionHandlers(server)`.
67
+ - Roots list change handler is added post-connection via
68
+ - **Returns**
69
+ - The `McpServer` instance
70
+ - A `clientConnect(sessionId)` callback that enables post-connection setup
71
+ - A `cleanup(sessionId?)` callback that stops any active intervals and removes any session‑scoped state
72
+
73
+ ## Enabling Multiple Clients
74
+
75
+ Some of the transport managers defined in the `transports` folder can support multiple clients.
76
+ In order to do so, they must map certain data to a session identifier.