@olaservo/mcp-server-everything-sep834 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.
- package/README.md +106 -0
- package/dist/docs/architecture.md +44 -0
- package/dist/docs/extension.md +23 -0
- package/dist/docs/features.md +52 -0
- package/dist/docs/how-it-works.md +45 -0
- package/dist/docs/instructions.md +28 -0
- package/dist/docs/startup.md +73 -0
- package/dist/docs/structure.md +182 -0
- package/dist/index.js +41 -0
- package/dist/prompts/args.js +34 -0
- package/dist/prompts/completions.js +52 -0
- package/dist/prompts/index.js +15 -0
- package/dist/prompts/resource.js +60 -0
- package/dist/prompts/simple.js +23 -0
- package/dist/resources/files.js +83 -0
- package/dist/resources/index.js +33 -0
- package/dist/resources/session.js +44 -0
- package/dist/resources/subscriptions.js +125 -0
- package/dist/resources/templates.js +171 -0
- package/dist/server/index.js +73 -0
- package/dist/server/logging.js +64 -0
- package/dist/server/roots.js +69 -0
- package/dist/test-with-agent-sdk.js +192 -0
- package/dist/tools/echo.js +29 -0
- package/dist/tools/find-by-id-or-name.js +79 -0
- package/dist/tools/get-annotated-message.js +87 -0
- package/dist/tools/get-array-content.js +77 -0
- package/dist/tools/get-count.js +71 -0
- package/dist/tools/get-env.js +28 -0
- package/dist/tools/get-resource-links.js +62 -0
- package/dist/tools/get-resource-reference.js +74 -0
- package/dist/tools/get-roots-list.js +71 -0
- package/dist/tools/get-structured-content.js +72 -0
- package/dist/tools/get-sum.js +40 -0
- package/dist/tools/get-tiny-image.js +41 -0
- package/dist/tools/gzip-file-as-resource.js +182 -0
- package/dist/tools/index.js +50 -0
- package/dist/tools/simulate-research-query.js +251 -0
- package/dist/tools/toggle-dynamic-tool.js +29 -0
- package/dist/tools/toggle-simulated-logging.js +41 -0
- package/dist/tools/toggle-subscriber-updates.js +44 -0
- package/dist/tools/trigger-agentic-sampling.js +242 -0
- package/dist/tools/trigger-elicitation-request-async.js +201 -0
- package/dist/tools/trigger-elicitation-request.js +210 -0
- package/dist/tools/trigger-long-running-operation.js +59 -0
- package/dist/tools/trigger-sampling-request-async.js +169 -0
- package/dist/tools/trigger-sampling-request.js +71 -0
- package/dist/transports/sse.js +61 -0
- package/dist/transports/stdio.js +27 -0
- package/dist/transports/streamableHttp.js +185 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
|
|
9
|
+
|
|
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.
|
|
11
|
+
|
|
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))
|
|
17
|
+
|
|
18
|
+
Add to your `claude_desktop_config.json`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"everything": {
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": [
|
|
26
|
+
"-y",
|
|
27
|
+
"@modelcontextprotocol/server-everything"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage with VS Code
|
|
35
|
+
|
|
36
|
+
For quick installation, use of of the one-click install buttons below...
|
|
37
|
+
|
|
38
|
+
[](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) [](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)
|
|
39
|
+
|
|
40
|
+
[](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) [](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)
|
|
41
|
+
|
|
42
|
+
For manual installation, you can configure the MCP server using one of these methods:
|
|
43
|
+
|
|
44
|
+
**Method 1: User Configuration (Recommended)**
|
|
45
|
+
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.
|
|
46
|
+
|
|
47
|
+
**Method 2: Workspace Configuration**
|
|
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.
|
|
49
|
+
|
|
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).
|
|
51
|
+
|
|
52
|
+
#### NPX
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"servers": {
|
|
57
|
+
"everything": {
|
|
58
|
+
"command": "npx",
|
|
59
|
+
"args": ["-y", "@modelcontextprotocol/server-everything"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 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))
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
cd src/everything
|
|
69
|
+
npm install
|
|
70
|
+
npm run start:sse
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Run from source with [Streamable HTTP Transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http)
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
cd src/everything
|
|
77
|
+
npm install
|
|
78
|
+
npm run start:streamableHttp
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Running as an installed package
|
|
82
|
+
### Install
|
|
83
|
+
```shell
|
|
84
|
+
npm install -g @modelcontextprotocol/server-everything@latest
|
|
85
|
+
````
|
|
86
|
+
|
|
87
|
+
### Run the default (stdio) server
|
|
88
|
+
```shell
|
|
89
|
+
npx @modelcontextprotocol/server-everything
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Or specify stdio explicitly
|
|
93
|
+
```shell
|
|
94
|
+
npx @modelcontextprotocol/server-everything stdio
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Run the SSE server
|
|
98
|
+
```shell
|
|
99
|
+
npx @modelcontextprotocol/server-everything sse
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Run the streamable HTTP server
|
|
103
|
+
```shell
|
|
104
|
+
npx @modelcontextprotocol/server-everything streamableHttp
|
|
105
|
+
```
|
|
106
|
+
|
|
@@ -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 both tool-level annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) and content 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.
|
|
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.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Parse command line arguments first
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
const scriptName = args[0] || "stdio";
|
|
5
|
+
async function run() {
|
|
6
|
+
try {
|
|
7
|
+
// Dynamically import only the requested module to prevent all modules from initializing
|
|
8
|
+
switch (scriptName) {
|
|
9
|
+
case "stdio":
|
|
10
|
+
// Import and run the default server
|
|
11
|
+
await import("./transports/stdio.js");
|
|
12
|
+
break;
|
|
13
|
+
case "sse":
|
|
14
|
+
// Import and run the SSE server
|
|
15
|
+
await import("./transports/sse.js");
|
|
16
|
+
break;
|
|
17
|
+
case "streamableHttp":
|
|
18
|
+
// Import and run the streamable HTTP server
|
|
19
|
+
await import("./transports/streamableHttp.js");
|
|
20
|
+
break;
|
|
21
|
+
default:
|
|
22
|
+
console.error(`-`.repeat(53));
|
|
23
|
+
console.error(` Everything Server Launcher`);
|
|
24
|
+
console.error(` Usage: node ./index.js [stdio|sse|streamableHttp]`);
|
|
25
|
+
console.error(` Default transport: stdio`);
|
|
26
|
+
console.error(`-`.repeat(53));
|
|
27
|
+
console.error(`Unknown transport: ${scriptName}`);
|
|
28
|
+
console.log("Available transports:");
|
|
29
|
+
console.log("- stdio");
|
|
30
|
+
console.log("- sse");
|
|
31
|
+
console.log("- streamableHttp");
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error("Error running script:", error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
await run();
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Register a prompt with arguments
|
|
4
|
+
* - Two arguments, one required and one optional
|
|
5
|
+
* - Combines argument values in the returned prompt
|
|
6
|
+
*
|
|
7
|
+
* @param server
|
|
8
|
+
*/
|
|
9
|
+
export const registerArgumentsPrompt = (server) => {
|
|
10
|
+
// Prompt arguments
|
|
11
|
+
const promptArgsSchema = {
|
|
12
|
+
city: z.string().describe("Name of the city"),
|
|
13
|
+
state: z.string().describe("Name of the state").optional(),
|
|
14
|
+
};
|
|
15
|
+
// Register the prompt
|
|
16
|
+
server.registerPrompt("args-prompt", {
|
|
17
|
+
title: "Arguments Prompt",
|
|
18
|
+
description: "A prompt with two arguments, one required and one optional",
|
|
19
|
+
argsSchema: promptArgsSchema,
|
|
20
|
+
}, (args) => {
|
|
21
|
+
const location = `${args?.city}${args?.state ? `, ${args?.state}` : ""}`;
|
|
22
|
+
return {
|
|
23
|
+
messages: [
|
|
24
|
+
{
|
|
25
|
+
role: "user",
|
|
26
|
+
content: {
|
|
27
|
+
type: "text",
|
|
28
|
+
text: `What's weather in ${location}?`,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
};
|