@apideck/docs-mcp
Version:
MCP server that lets agents search and retrieve your documentation at query time instead of relying on stale training data.
40 lines • 2.02 kB
TypeScript
/**
* Stateless Streamable HTTP handler over Node's request/response objects.
* Works as a Vercel function, a Next.js API route, or behind `http.createServer`.
* GET returns a JSON summary of the index; POST speaks MCP; each POST gets a
* fresh McpServer bound to the shared DocStore.
*/
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { NodeHttpTransport } from './node-http.js';
import type { DocStore } from './store.js';
import type { AnyToolDefinition, ToolCallHook } from './types.js';
export interface HttpHandlerOptions {
/** Store to serve, or a function returning one (called per request, so it can lazy-load and cache). */
store: DocStore | (() => Promise<DocStore>);
name?: string;
version?: string;
/** One-line description of what the docs cover, shown to agents and in the GET summary. */
about?: string;
/** Host-specific guidance appended to the server instructions. See `CreateServerOptions.instructions`. */
instructions?: string;
/**
* Extra tools registered alongside search_docs/get_doc/list_docs, or a
* function returning them (called per request, so it can depend on the
* same lazily-loaded data as a `store` function). See
* `CreateServerOptions.extraTools`.
*/
extraTools?: AnyToolDefinition[] | (() => Promise<AnyToolDefinition[]>);
/**
* Called after every tool call with the tool, arguments, timing, result
* count and caller (`X-MCP-Client` header, User-Agent). See `ToolCallHook`.
*/
onToolCall?: ToolCallHook;
/** Extra fields merged into the GET summary. */
info?: Record<string, unknown>;
/** Set to false to skip CORS headers (e.g. when a gateway adds them). Default true. */
cors?: boolean;
transportFactory?: () => NodeHttpTransport;
}
export type NodeHandler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
export declare const createHttpHandler: (opts: HttpHandlerOptions) => NodeHandler;
//# sourceMappingURL=http.d.ts.map