UNPKG

mcp-ts-template

Version:

A production-grade TypeScript template for building robust Model Context Protocol (MCP) servers, featuring built-in observability with OpenTelemetry, advanced error handling, comprehensive utilities, and a modular architecture.

71 lines 2.88 kB
/** * @fileoverview Defines the core logic, schemas, and types for the `echo_message` tool. * This module is the single source of truth for the tool's data contracts (Zod schemas) * and its pure business logic. * @module src/mcp-server/tools/echoTool/logic * @see {@link src/mcp-server/tools/echoTool/registration.ts} for the handler and registration logic. */ import { z } from "zod"; import { type RequestContext } from "../../../utils/index.js"; /** * Defines the valid formatting modes for the echo tool operation. */ export declare const ECHO_MODES: readonly ["standard", "uppercase", "lowercase"]; /** * Zod schema defining the input parameters for the `echo_message` tool. * CRITICAL: The descriptions are sent to the LLM and must be clear. */ export declare const EchoToolInputSchema: z.ZodObject<{ message: z.ZodString; mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<["standard", "uppercase", "lowercase"]>>>; repeat: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; includeTimestamp: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { message: string; repeat: number; mode: "standard" | "uppercase" | "lowercase"; includeTimestamp: boolean; }, { message: string; repeat?: number | undefined; mode?: "standard" | "uppercase" | "lowercase" | undefined; includeTimestamp?: boolean | undefined; }>; /** * Zod schema for the successful response of the `echo_message` tool. */ export declare const EchoToolResponseSchema: z.ZodObject<{ originalMessage: z.ZodString; formattedMessage: z.ZodString; repeatedMessage: z.ZodString; mode: z.ZodEnum<["standard", "uppercase", "lowercase"]>; repeatCount: z.ZodNumber; timestamp: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { originalMessage: string; mode: "standard" | "uppercase" | "lowercase"; formattedMessage: string; repeatedMessage: string; repeatCount: number; timestamp?: string | undefined; }, { originalMessage: string; mode: "standard" | "uppercase" | "lowercase"; formattedMessage: string; repeatedMessage: string; repeatCount: number; timestamp?: string | undefined; }>; export type EchoToolInput = z.infer<typeof EchoToolInputSchema>; export type EchoToolResponse = z.infer<typeof EchoToolResponseSchema>; /** * Processes the core logic for the `echo_message` tool. * This function is pure; it processes inputs and returns a result or throws an error. * * @param params - The validated input parameters. * @param context - The request context for logging and tracing. * @returns A promise resolving with the structured response data. * @throws {McpError} If the logic encounters an unrecoverable issue. */ export declare function echoToolLogic(params: EchoToolInput, context: RequestContext): Promise<EchoToolResponse>; //# sourceMappingURL=logic.d.ts.map