[WIP] Refactor everything server to be more modular and use recommended APIs.

Added long-running-operation tool and improved comments in all tools

* Updated architecture.md

* In tools/
  - add.ts
  - echo.ts
  - toggle-logging.ts
  - toggle-subscriber-updates.ts
    - Add better function and inline docs

* Added tools/long-running-operation.ts
  - similar implementation as in everything v1

* In tools/index.ts
  - import registerLongRunningOperationTool
  - in registerTools
    - registerLongRunningOperationTool
This commit is contained in:
cliffhall
2025-12-08 17:55:04 -05:00
parent 346c29a086
commit 1df8623bcc
6 changed files with 127 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import {
stopSimulatedResourceUpdates,
} from "../resources/subscriptions.js";
// Tool configuration
const name = "toggle-subscriber-updates";
const config = {
title: "Toggle Subscriber Updates",
@@ -12,8 +13,23 @@ const config = {
inputSchema: {},
};
// Track enabled clients by session id
const clients: Set<string | undefined> = new Set<string | undefined>();
/**
* Registers the `toggle-subscriber-updates` tool with the provided MCP server.
* This tool enables or disables simulated resource update notifications for a client.
*
*
* Toggles the state of the updates based on whether the session is already active.
* When enabled, the simulated resource updates are sent to the client at a regular interval.
* When disabled, updates are stopped for the session.
*
* The response provides feedback indicating whether simulated updates were started or stopped,
* including the session ID.
*
* @param {McpServer} server - The MCP server instance on which the tool is registered.
*/
export const registerToggleSubscriberUpdatesTool = (server: McpServer) => {
server.registerTool(
name,