UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

92 lines (91 loc) 3.72 kB
/** * Eufemia Docs MCP Server — runtime-agnostic core. * * This module deliberately avoids importing any Node built-ins so that it can * be bundled for non-Node runtimes (Cloudflare Workers, Deno, Bun, ...). * The Node-only stdio entry point lives in `./mcp-stdio.ts` and the local * Express HTTP server lives in `./mcp-http-server.ts`. */ import { z } from 'zod'; import type { CallToolResult } from '@modelcontextprotocol/sdk/types'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { type DocsSource } from './docs-source'; type ToolResult = CallToolResult; /** * Verify that the docs source is populated before the MCP server starts * serving requests. We have hit cases where the server is pointed at a * relative path that resolves to the wrong working directory and silently * returns empty results for every tool call. Failing fast here makes that * misconfiguration impossible to miss. * * The source is considered valid when it can read `llm.md` and reports at * least one markdown/MDX file. */ export declare function validateDocsSource(source: DocsSource): Promise<void>; /** * Backwards-compatible wrapper: validates a Node docs directory by path. * Throws an immediate, clear error when the directory is missing or not a * directory; otherwise delegates to {@link validateDocsSource}. */ export declare function validateDocsRoot(docsRootAbs: string): Promise<void>; declare const EmptyInput: z.ZodObject<{}, z.core.$strip>; declare const DocsReadInput: z.ZodObject<{ path: z.ZodString; }, z.core.$strip>; declare const DocsSearchInput: z.ZodObject<{ query: z.ZodAny; limit: z.ZodDefault<z.ZodNumber>; prefix: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare const DocsListInput: z.ZodObject<{ prefix: z.ZodOptional<z.ZodString>; limit: z.ZodDefault<z.ZodNumber>; }, z.core.$strip>; declare const ComponentNameInput: z.ZodObject<{ name: z.ZodString; }, z.core.$strip>; type DocsReadInputType = z.infer<typeof DocsReadInput>; type DocsListInputType = z.infer<typeof DocsListInput>; type DocsSearchInputType = z.infer<typeof DocsSearchInput>; type ComponentNameInputType = z.infer<typeof ComponentNameInput>; type EmptyInputType = z.infer<typeof EmptyInput>; type DocsToolHandlers = { docsEntry: (_input: EmptyInputType) => Promise<ToolResult>; docsIndex: (_input: EmptyInputType) => Promise<ToolResult>; docsList: (input: DocsListInputType) => Promise<ToolResult>; docsRead: (input: DocsReadInputType) => Promise<ToolResult>; docsSearch: (input: DocsSearchInputType) => Promise<ToolResult>; componentFind: (input: ComponentNameInputType) => Promise<ToolResult>; componentDoc: (input: ComponentNameInputType) => Promise<ToolResult>; componentApi: (input: ComponentNameInputType) => Promise<ToolResult>; componentProps: (input: ComponentNameInputType) => Promise<ToolResult>; source: DocsSource; /** * Convenience accessor for Node deployments. Equals the absolute docs root * when the tools were created with `{ docsRoot }`; otherwise mirrors the * source `label` so log lines stay readable. */ docsRoot: string; }; export declare function createDocsTools(options?: { docsRoot?: string; source?: never; } | { source: DocsSource; docsRoot?: never; } | { docsRoot?: string; source?: DocsSource; }): DocsToolHandlers; export declare const SERVER_INFO: { name: string; version: string; }; export declare function registerDocsTools(server: McpServer, tools: DocsToolHandlers): void; export declare function createDocsServer(options?: { docsRoot?: string; }): { server: McpServer; tools: DocsToolHandlers; }; export {};