@apideck/docs-mcp
Version:
MCP server that lets agents search and retrieve your documentation at query time instead of relying on stale training data.
33 lines • 1.71 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 { NodeStreamableHTTPServerTransport } from '@modelcontextprotocol/node';
import type { DocStore } from './store.js';
import type { AnyToolDefinition } 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;
/**
* 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[]>);
/** 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?: () => NodeStreamableHTTPServerTransport;
}
export type NodeHandler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
export declare const createHttpHandler: (opts: HttpHandlerOptions) => NodeHandler;
//# sourceMappingURL=http.d.ts.map