@civic/nexus-bridge
Version:
Stdio <-> HTTP/SSE MCP bridge with Civic auth handling
59 lines • 1.98 kB
TypeScript
/**
* Utility functions used throughout the nexus bridge.
*/
import type { Result } from "@modelcontextprotocol/sdk/types.js";
import type { z } from "zod";
/**
* Interface for request handlers
*/
export interface RequestHandler {
schema: z.ZodType<any, any, any>;
process: (result: Result) => Promise<Result>;
defaultResult?: Result;
}
/**
* Maps MCP method names to their corresponding result schemas and processors
*/
export declare const METHOD_HANDLERS: Record<string, RequestHandler>;
/**
* Type for MCP method names
*/
export type McpMethod = keyof typeof METHOD_HANDLERS;
/**
* Check if a method is supported by the bridge
* @param method The method name to check
* @returns true if the method is supported, false otherwise
*/
export declare const isSupportedMethod: (method: string) => method is McpMethod;
/**
* Get the handler for a given MCP method
* @param method The MCP method
* @returns The handler for the method, or undefined if not supported
*/
export declare const getHandlerForMethod: (method: string) => RequestHandler | undefined;
/**
* Extract a human-readable message from an error of any type
* @param error The error to extract a message from
* @returns A string representing the error message
*/
export declare const messageFromError: (error: unknown) => string;
/**
* Type guard using Zod schema
*/
export declare const is: <T extends z.ZodType>(schema: T) => (data: unknown) => data is z.infer<T>;
/**
* Check if a request is a tool call request using Zod schema
*/
export declare const isToolCallRequest: (data: unknown) => data is {
params: {
name: string;
_meta?: z.objectOutputType<{
progressToken: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
}, z.ZodTypeAny, "passthrough"> | undefined;
arguments?: Record<string, unknown> | undefined;
} & {
[k: string]: unknown;
};
method: "tools/call";
};
//# sourceMappingURL=utils.d.ts.map