import { type FrontMcpConfigInput, type FrontMcpConfigType, type FrontMcpInterface, type ScopeEntry } from '../common'; import { type SqliteOptionsInput } from '../common/types/options/sqlite/schema'; import { type DirectMcpServer } from '../direct'; import { type WebFetchHandler } from '../transport/web-fetch-handler'; /** * A `@FrontMcp`-decorated server class, or the raw config object it wraps. * Entry points that accept either resolve a class to its stored config via * {@link resolveConfigInput}. */ export type ConfigOrServerClass = FrontMcpConfigInput | (abstract new (...args: never[]) => unknown); export declare class FrontMcpInstance implements FrontMcpInterface { config: FrontMcpConfigType; readonly ready: Promise; private logger; private providers; private scopes; private log?; constructor(config: FrontMcpConfigType); initialize(): Promise; start(): Promise; /** * Get the configuration used to create this FrontMCP instance. */ getConfig(): FrontMcpConfigType; /** * Get all initialized scope instances. * Useful for graph visualization and introspection. */ getScopes(): ScopeEntry[]; /** * Wire the health service from the first scope into the server instance. * Called before server.start() or server.prepare() to register health routes. */ private wireHealthService; /** * Wire the `/metrics` service into the server instance (issue #397). * * Off by default — `metrics.enabled` must be set to `true` explicitly. * The `MetricsService` is instantiated here (not in scope construction) * because the endpoint is server-wide, not per-app — counters and process * stats are process-global. */ private wireMetricsService; static bootstrap(options: FrontMcpConfigInput | FrontMcpConfigType): Promise; /** * Creates and initializes a FrontMCP instance without starting the HTTP server. * Returns the underlying HTTP handler for serverless deployments (Vercel, Lambda). * * @example * // In index.ts for Vercel * import { FrontMcpInstance } from '@frontmcp/sdk'; * import config from '../src/main'; * * export default FrontMcpInstance.createHandler(config); */ static createHandler(options: FrontMcpConfigType): Promise; /** * Creates and initializes a FrontMCP instance and returns a Web-standard * `fetch` handler — `(request: Request) => Promise` — backed by the * MCP WebStandard transport. Unlike {@link createHandler} this needs no * Express / Node `req`/`res` and runs on V8-isolate targets (Cloudflare * Workers, Deno Deploy, Bun). * * @example * // worker entry * const handler = await FrontMcpInstance.createFetchHandler(config); * export default { fetch: (request) => handler(request) }; */ static createFetchHandler(options: FrontMcpConfigType): Promise; /** * Creates and initializes a FrontMCP instance without starting any server. * Returns the instance for graph extraction and introspection purposes. * * @example * // For graph visualization * const instance = await FrontMcpInstance.createForGraph(config); * const scopes = instance.getScopes(); */ static createForGraph(options: FrontMcpConfigInput): Promise; /** * Creates a FrontMCP instance optimized for CLI execution. * Skips non-essential registries (UI widget compilation, event stores, * elicitation stores) for faster startup (~100-150ms savings). * * @example * const instance = await FrontMcpInstance.createForCli(config); * const scopes = instance.getScopes(); */ static createForCli(options: FrontMcpConfigInput): Promise; /** * Creates a DirectMcpServer from a FrontMCP configuration. * This provides direct programmatic access to MCP operations * without requiring HTTP transport. * * Use cases: * - Unit/integration testing tools, resources, prompts * - Embedding MCP capabilities in other applications * - CLI tools that need direct access * - Agent backends with custom invocation * * @example * ```typescript * import { FrontMcpInstance } from '@frontmcp/sdk'; * import MyServer from './my-server'; * * const server = await FrontMcpInstance.createDirect(MyServer); * * // List all tools * const tools = await server.listTools(); * * // Call a tool with auth context * const result = await server.callTool('my-tool', { param: 'value' }, { * authContext: { sessionId: 'user-123', token: 'jwt-token' } * }); * * // Cleanup when done * await server.dispose(); * ``` */ static createDirect(options: FrontMcpConfigInput): Promise; /** * Runs the FrontMCP server on a Unix socket for local-only access. * * This enables a persistent background FrontMCP server accessible only via * a Unix `.sock` file. The entire HTTP feature set (streamable HTTP, SSE, * elicitation, sessions) works unchanged over Unix sockets. * * Pass the same config object you give to `@FrontMcp()` (not the decorated * class — spreading a class yields no config) plus the socket path. * * @example * ```typescript * import { FrontMcpInstance } from '@frontmcp/sdk'; * import { serverConfig } from './server-config'; * * const handle = await FrontMcpInstance.runUnixSocket({ * ...serverConfig, * socketPath: '/tmp/my-app.sock', * sqlite: { path: '~/.frontmcp/data/my-app.sqlite' }, * }); * * // Later: graceful shutdown * await handle.close(); * ``` */ static runUnixSocket(options: (FrontMcpConfigInput | FrontMcpConfigType) & { socketPath: string; sqlite?: SqliteOptionsInput; }): Promise<{ close: () => Promise; }>; /** * Runs the FrontMCP server over **stdio** (stdin/stdout JSON-RPC) for local * MCP clients such as Claude Desktop, Claude Code, and Cursor. Connects the * transport and returns only when the connection closes. **No TCP port is * bound** — the HTTP server is disabled for this entry point (#451). * * Accepts either a `@FrontMcp`-decorated class or the same config object you * pass to `@FrontMcp()` (#450). * * IMPORTANT — importing a `@FrontMcp`-decorated class starts an HTTP server at * import time unless `FRONTMCP_STDIO=1` is set *before* the import. Two safe * patterns avoid that: * * 1. Built bundles — `frontmcp build --target node`, then run the emitted * runner with `--stdio` (it sets `FRONTMCP_STDIO=1` for you, so the * decorator serves over stdio). A `--target cli` binary supports * ` --stdio` the same way. * 2. Hand-written entry — keep the config object in its own module (no * decorated class in the import graph) and pass it directly, as below. * * @example Hand-written stdio entry (config kept separate from the class) * ```typescript * // server-config.ts — a plain object, no @FrontMcp decorator here * export const serverConfig = { info: { name: 'my-server', version: '0.1.0' }, apps: [MyApp] }; * * // stdio.ts * import { FrontMcpInstance } from '@frontmcp/sdk'; * import { serverConfig } from './server-config'; * FrontMcpInstance.runStdio(serverConfig); * ``` * * @example Claude Desktop config (built `--target node` runner) * ```json * { * "mcpServers": { * "my-server": { "command": "/abs/path/dist/node/my-server", "args": ["--stdio"] } * } * } * ``` */ static runStdio(optionsOrClass: ConfigOrServerClass): Promise; } //# sourceMappingURL=front-mcp.d.ts.map