mattrguerra/meridian-orders-mcpmainPrivate on GitHub, published here in full

types.ts

Language TypeScript1.2 KB37 lines

mcp-server/src/tools/types.ts

  1. import type { ZodRawShape } from "zod";
  2. import type { PlinthConfig } from "../lib/config.js";
  3. import type { RateLimiter } from "../lib/rateLimit.js";
  4. /** MCP tool call result (text content only). */
  5. export type ToolResult = {
  6. content: Array<{ type: "text"; text: string }>;
  7. isError?: boolean;
  8. /** SDK result type carries an open index signature. */
  9. [key: string]: unknown;
  10. };
  11. /**
  12. * Per-invocation context. Config is injected rather than read from a global so
  13. * handlers are portable across Node (stdio) and the Workers isolate, where each
  14. * request/instance carries its own env-derived config.
  15. */
  16. export interface ToolContext {
  17. config: PlinthConfig;
  18. /** Shared rate limiter enforcing the 10/10s cap. Optional in tests. */
  19. limiter?: RateLimiter;
  20. }
  21. /**
  22. * A self-contained tool module. Every handler goes through plinthRequest(),
  23. * which refuses to run until live requests are deliberately enabled, so a tool
  24. * is always discoverable (ListTools) but cannot reach production by accident.
  25. */
  26. export interface ToolModule {
  27. name: string;
  28. config: {
  29. title: string;
  30. description: string;
  31. inputSchema: ZodRawShape;
  32. };
  33. handler: (args: Record<string, unknown>, ctx: ToolContext) => Promise<ToolResult> | ToolResult;
  34. }