From 03d3da0d5570f0e845390eafc6522b9daed166ff Mon Sep 17 00:00:00 2001 From: cliffhall Date: Tue, 9 Dec 2025 19:24:39 -0500 Subject: [PATCH] [WIP] Refactor everything server to be more modular and use recommended APIs. Refactor/rename `print-env` tool to `get-env` * Updated architecture.md * Refactor rename print-env.ts to get-env.ts * In tools/index.ts - reorder tools alphabetically --- src/everything/docs/architecture.md | 9 +++++---- src/everything/tools/{print-env.ts => get-env.ts} | 6 +++--- src/everything/tools/index.ts | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) rename src/everything/tools/{print-env.ts => get-env.ts} (85%) diff --git a/src/everything/docs/architecture.md b/src/everything/docs/architecture.md index c9573ff8..94c9f26b 100644 --- a/src/everything/docs/architecture.md +++ b/src/everything/docs/architecture.md @@ -34,7 +34,7 @@ src/everything │ ├── echo.ts │ ├── get-tiny-image.ts │ ├── long-running-operation.ts -│ ├── print-env.ts +│ ├── get-env.ts │ ├── sampling-request.ts │ ├── toggle-logging.ts │ └── toggle-subscriber-updates.ts @@ -97,12 +97,13 @@ At `src/everything`: - 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. - echo.ts - Registers an `echo` tool that takes a message and returns `Echo: {message}`. + - get-env.ts + - Registers a `get-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration. + - get-tiny-image.ts - Registers a `get-tiny-image` tool, which returns a tiny PNG MCP logo as an `image` content item, along with surrounding descriptive `text` items. - long-running-operation.ts - 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`. - - print-env.ts - - Registers a `print-env` tool that returns the current process environment variables as formatted JSON text; useful for debugging configuration. - sampling-request.ts - Registers a `sampling-request` tool that sends a `sampling/createMessage` request to the client/LLM and returns the sampling result. - toggle-logging.ts @@ -189,7 +190,7 @@ At `src/everything`: - `echo` (tools/echo.ts): Echoes the provided `message: string`. Uses Zod to validate inputs. - `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. - `long-running-operation` (tools/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. - - `print-env` (tools/print-env.ts): Returns all environment variables from the running process as pretty-printed JSON text. + - `get-env` (tools/get-env.ts): Returns all environment variables from the running process as pretty-printed JSON text. - `sampling-request` (tools/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. - `toggle-logging` (tools/toggle-logging.ts): Starts or stops simulated, random‑leveled logging for the invoking session. Respects the client’s selected minimum logging level. - `toggle-subscriber-updates` (tools/toggle-subscriber-updates.ts): Starts or stops simulated resource update notifications for URIs the invoking session has subscribed to. diff --git a/src/everything/tools/print-env.ts b/src/everything/tools/get-env.ts similarity index 85% rename from src/everything/tools/print-env.ts rename to src/everything/tools/get-env.ts index 421f51fb..6df3aa59 100644 --- a/src/everything/tools/print-env.ts +++ b/src/everything/tools/get-env.ts @@ -2,7 +2,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; // Tool configuration -const name = "print-env"; +const name = "get-env"; const config = { title: "Print Environment Tool", description: @@ -11,7 +11,7 @@ const config = { }; /** - * Registers the 'print-env' tool with the given MCP server. + * Registers the 'get-env' tool with the given MCP server. * * The registered tool Retrieves and returns the environment variables * of the current process as a JSON-formatted string encapsulated in a text response. @@ -19,7 +19,7 @@ const config = { * @param {McpServer} server - The MCP server instance where the Echo Tool is to be registered. * @returns {void} */ -export const registerPrintEnvTool = (server: McpServer) => { +export const registerGetEnvTool = (server: McpServer) => { server.registerTool(name, config, async (args): Promise => { return { content: [ diff --git a/src/everything/tools/index.ts b/src/everything/tools/index.ts index e9c9b724..1266d7cd 100644 --- a/src/everything/tools/index.ts +++ b/src/everything/tools/index.ts @@ -2,11 +2,11 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { registerAddTool } from "./add.js"; import { registerAnnotatedMessageTool } from "./annotated-message.js"; import { registerEchoTool } from "./echo.js"; -import { registerGetTinyImageTool } from "./get-tiny-image.js"; +import { registerGetEnvTool } from "./get-env.js"; import { registerGetResourceLinksTool } from "./get-resource-links.js"; import { registerGetResourceReferenceTool } from "./get-resource-reference.js"; +import { registerGetTinyImageTool } from "./get-tiny-image.js"; import { registerLongRunningOperationTool } from "./long-running-operation.js"; -import { registerPrintEnvTool } from "./print-env.js"; import { registerSamplingRequestTool } from "./sampling-request.js"; import { registerToggleLoggingTool } from "./toggle-logging.js"; import { registerToggleSubscriberUpdatesTool } from "./toggle-subscriber-updates.js"; @@ -19,11 +19,11 @@ export const registerTools = (server: McpServer) => { registerAddTool(server); registerAnnotatedMessageTool(server); registerEchoTool(server); - registerGetTinyImageTool(server); + registerGetEnvTool(server); registerGetResourceLinksTool(server); registerGetResourceReferenceTool(server); + registerGetTinyImageTool(server); registerLongRunningOperationTool(server); - registerPrintEnvTool(server); registerSamplingRequestTool(server); registerToggleLoggingTool(server); registerToggleSubscriberUpdatesTool(server);