jsonv-ts
Version:
JSON Schema builder and validator for TypeScript with static type inference, Hono middleware for OpenAPI generation and validation, and MCP server/client implementation. Lightweight, dependency-free, and built on Web Standards.
34 lines (33 loc) • 1.06 kB
TypeScript
import type { Context, MiddlewareHandler } from "hono";
import { McpServer, type LogLevel, type McpServerInfo } from "../server";
import type { Tool } from "../tool";
import type { Resource } from "../resource";
export type McpServerInit = {
tools?: Tool<any, any, any | never>[];
resources?: Resource<any, any, any, any | never>[];
context?: object;
serverInfo?: McpServerInfo;
} | {
server: McpServer;
};
export interface McpOptionsBase {
sessionsEnabled?: boolean;
debug?: {
historyEndpoint?: boolean;
explainEndpoint?: boolean;
logLevel?: LogLevel;
};
endpoint?: {
transport?: "streamableHttp";
path: `/${string}`;
_init?: RequestInit;
};
}
export type McpOptionsStatic = McpOptionsBase & McpServerInit & {
setup?: never;
};
export interface McpOptionsSetup extends McpOptionsBase {
setup: (c: Context) => Promise<McpServerInit>;
}
export type McpOptions = McpOptionsStatic | McpOptionsSetup;
export declare const mcp: (opts: McpOptions) => MiddlewareHandler;