mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-02-19 11:54:58 -05:00
* Updated docs * Refactor/renamed toggle-logging.ts to toggle-simulated-logging.ts - refactor/renamed registerToggleLoggingTool to registerToggleSimulatedLoggingTool
9.5 KiB
9.5 KiB
Everything Server - Project Structure
Architecture | Project Structure | Startup Process | Server Features | Extension Points | How It Works
src/everything
├── index.ts
├── AGENTS.md
├── package.json
├── docs
│ ├── architecture.md
│ └── server-instructions.md
├── prompts
│ ├── index.ts
│ ├── args.ts
│ ├── completions.ts
│ ├── simple.ts
│ └── resource.ts
├── resources
│ ├── index.ts
│ ├── files.ts
│ ├── session.ts
│ ├── subscriptions.ts
│ └── templates.ts
├── server
│ ├── index.ts
│ ├── logging.ts
│ └── roots.ts
├── tools
│ ├── index.ts
│ ├── echo.ts
│ ├── get-annotated-message.ts
│ ├── get-env.ts
│ ├── get-resource-links.ts
│ ├── get-resource-reference.ts
│ ├── get-roots-list.ts
│ ├── get-structured-content.ts
│ ├── get-sum.ts
│ ├── get-tiny-image.ts
│ ├── gzip-file-as-resource.ts
│ ├── long-running-operation.ts
│ ├── toggle-simulated-logging.ts
│ ├── toggle-subscriber-updates.ts
│ ├── trigger-elicitation-request.ts
│ └── trigger-sampling-request.ts
└── transports
├── sse.ts
├── stdio.ts
└── streamableHttp.ts
Project Contents
src/everything:
index.ts
- CLI entry point that selects and runs a specific transport module based on the first CLI argument:
stdio,sse, orstreamableHttp.
AGENTS.md
- Directions for Agents/LLMs explaining coding guidelines and how to appropriately extend the server.
package.json
- Package metadata and scripts:
build: TypeScript compile todist/, copiesdocs/intodist/and marks the compiled entry scripts as executable.start:stdio,start:sse,start:streamableHttp: Run built transports fromdist/.
- Declares dependencies on
@modelcontextprotocol/sdk,express,cors,zod, etc.
docs/
architecture.md- This document.
server-instructions.md- 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.
prompts/
index.tsregisterPrompts(server)orchestrator; delegates to prompt factory/registration methods from in individual prompt files.
simple.ts- Registers
simple-prompt: a prompt with no arguments that returns a single user message.
- Registers
args.ts- Registers
args-prompt: a prompt with two arguments (cityrequired,stateoptional) used to compose a message.
- Registers
completions.ts- Registers
completable-prompt: a prompt whose arguments support server-driven completions using the SDK’scompletable(...)helper (e.g., completingdepartmentand context-awarename).
- Registers
resource.ts- Exposes
registerEmbeddedResourcePrompt(server)which registersresource-prompt— a prompt that acceptsresourceType("Text" or "Blob") andresourceId(integer), and embeds a dynamically generated resource of the requested type within the returned messages. Internally reuses helpers fromresources/templates.ts.
- Exposes
resources/
index.tsregisterResources(server)orchestrator; delegates to resource factory/registration methods from individual resource files.
templates.ts- Registers two dynamic, template‑driven resources using
ResourceTemplate:- Text:
demo://resource/dynamic/text/{index}(MIME:text/plain) - Blob:
demo://resource/dynamic/blob/{index}(MIME:application/octet-stream, Base64 payload)
- Text:
- The
{index}path variable must be a finite positive integer. Content is generated on demand with a timestamp. - Exposes helpers
textResource(uri, index),textResourceUri(index),blobResource(uri, index), andblobResourceUri(index)so other modules can construct and embed dynamic resources directly (e.g., from prompts).
- Registers two dynamic, template‑driven resources using
files.ts- Registers static file-based resources for each file in the
docs/folder. - URIs follow the pattern:
demo://resource/static/document/<filename>. - Serves markdown files as
text/markdown,.txtastext/plain,.jsonasapplication/json, others default totext/plain.
- Registers static file-based resources for each file in the
server/
index.ts- Server factory that creates an
McpServerwith declared capabilities, loads server instructions, and registers tools, prompts, and resources. - Sets resource subscription handlers via
setSubscriptionHandlers(server). - Exposes
{ server, cleanup }to the chosen transport. Cleanup stops any running intervals in the server when the transport disconnects.
- Server factory that creates an
logging.ts- Implements simulated logging. Periodically sends randomized log messages at various levels to the connected client session. Started/stopped on demand via a dedicated tool.
tools/
index.tsregisterTools(server)orchestrator; delegates to tool factory/registration methods in individual tool files.
echo.ts- Registers an
echotool that takes a message and returnsEcho: {message}.
- Registers an
get-annotated-message.ts- Registers an
annotated-messagetool which demonstrates annotated content items by emitting a primarytextmessage withannotationsthat vary bymessageType("error" | "success" | "debug"), and optionally includes an annotatedimage(tiny PNG) whenincludeImageis true.
- Registers an
get-env.ts- Registers a
get-envtool that returns the current process environment variables as formatted JSON text; useful for debugging configuration.
- Registers a
get-resource-links.ts- Registers a
get-resource-linkstool that returns an introtextblock followed by multipleresource_linkitems.
- Registers a
get-resource-reference.ts- Registers a
get-resource-referencetool that returns a reference for a selected dynamic resource.
- Registers a
get-roots-list.ts- Registers a
get-roots-listtool that returns the last list of roots sent by the client.
- Registers a
gzip-file-as-resource.ts- Registers a
gzip-file-as-resourcetool that fetches content from a URL or data URI, compresses it, and then either:- returns a
resource_linkto a session-scoped resource (default), or - returns an inline
resourcewith the gzipped data. The resource will be still discoverable for the duration of the session viaresources/list.
- returns a
- Uses
resources/session.tsto register the gzipped blob as a per-session resource at a URI likedemo://resource/session/<name>withmimeType: application/gzip. - Environment controls:
GZIP_MAX_FETCH_SIZE(bytes, default 10 MiB)GZIP_MAX_FETCH_TIME_MILLIS(ms, default 30000)GZIP_ALLOWED_DOMAINS(comma-separated allowlist; empty means all domains allowed)
- Registers a
trigger-elicitation-request.ts- Registers a
trigger-elicitation-requesttool that sends anelicitation/createrequest to the client/LLM and returns the elicitation result.
- Registers a
trigger-sampling-request.ts- Registers a
trigger-sampling-requesttool that sends asampling/createMessagerequest to the client/LLM and returns the sampling result.
- Registers a
get-structured-content.ts- Registers a
get-structured-contenttool that demonstrates structuredContent block responses.
- Registers a
get-sum.ts- Registers an
get-sumtool with a Zod input schema that sums two numbersaandband returns the result.
- Registers an
get-tiny-image.ts- Registers a
get-tiny-imagetool, which returns a tiny PNG MCP logo as animagecontent item, along with surrounding descriptivetextitems.
- Registers a
long-running-operation.ts- Registers a
long-running-operationtool that simulates a long-running task over a specifiedduration(seconds) and number ofsteps; emitsnotifications/progressupdates when the client supplies aprogressToken.
- Registers a
toggle-simulated-logging.ts- Registers a
toggle-simulated-loggingtool, which starts or stops simulated logging for the invoking session.
- Registers a
toggle-subscriber-updates.ts- Registers a
toggle-subscriber-updatestool, which starts or stops simulated resource subscription update checks for the invoking session.
- Registers a
transports/
stdio.ts- Starts a
StdioServerTransport, created the server viacreateServer(), and connects it. - Calls
clientConnected()to inform the server of the connection. - Handles
SIGINTto close cleanly and callscleanup()to remove any live intervals.
- Starts a
sse.ts- Express server exposing:
GET /sseto establish an SSE connection per session.POST /messagefor client messages.
- Manages multiple connected clients via a transport map.
- Starts an
SSEServerTransport, created the server viacreateServer(), and connects it to a new transport. - Calls
clientConnected(sessionId)to inform the server of the connection. - On server disconnect, calls
cleanup()to remove any live intervals.
- Express server exposing:
streamableHttp.ts- Express server exposing a single
/mcpendpoint for POST (JSON‑RPC), GET (SSE stream), and DELETE (session termination) usingStreamableHTTPServerTransport. - Uses an
InMemoryEventStorefor resumable sessions and tracks transports bysessionId. - Connects a fresh server instance on initialization POST and reuses the transport for subsequent requests.
- Calls
clientConnected(sessionId)to inform the server of the connection.
- Express server exposing a single