mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 00:03:23 +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:
@@ -2,10 +2,12 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
||||
import { z } from "zod";
|
||||
|
||||
// Tool input schema
|
||||
export const EchoSchema = z.object({
|
||||
message: z.string().describe("Message to echo"),
|
||||
});
|
||||
|
||||
// Tool configuration
|
||||
const name = "echo";
|
||||
const config = {
|
||||
title: "Echo Tool",
|
||||
@@ -13,6 +15,15 @@ const config = {
|
||||
inputSchema: EchoSchema,
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers the Echo Tool with the provided McpServer instance.
|
||||
*
|
||||
* The Echo Tool validates input arguments using the EchoSchema and returns
|
||||
* a response that echoes the message provided in the arguments.
|
||||
*
|
||||
* @param {McpServer} server - The server instance where the Echo Tool will be registered.
|
||||
* @returns {void}
|
||||
*/
|
||||
export const registerEchoTool = (server: McpServer) => {
|
||||
server.registerTool(name, config, async (args): Promise<CallToolResult> => {
|
||||
const validatedArgs = EchoSchema.parse(args);
|
||||
|
||||
Reference in New Issue
Block a user