mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-19 00:33:22 +02:00
[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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user