Skip to main content

Class Definition

Properties

Factory Methods

bootstrap(options)

Create and start an HTTP server.
Best for: Standalone HTTP server deployments.

createHandler(options)

Create a serverless handler without starting a server.
Best for: Serverless deployments (Vercel, AWS Lambda).

createFetchHandler(options)

Create a Web-standard fetch handler, (request: Request) => Promise<Response>, for runtimes without Node req/res: Cloudflare Workers, Deno and Bun.
It accepts the same config as @FrontMcp(). A server the startup checks refuse (an approval or featureFlag field no installed plugin enforces, authorities without the authorities option, a missing secret) rejects here, as with createDirect(). On an edge isolate (Cloudflare Workers, Vercel Edge, Deno) the instance is built on the first request instead, because isolates forbid timers and I/O at module evaluation: the checks the config’s metadata settles still reject here, and a failed build is answered, never thrown: a configuration fault (a missing secret, a startup check, a config the schema refuses) with a 500 { "error": "server_misconfigured", "code", "message" } body, anything else (a remote that refused the connection, a package that failed to load) with a 503 { "error": "server_unavailable", "code": "SERVER_START_FAILED" } body and Retry-After. A failed build is kept until a retry delay passes (1 s, doubling up to 60 s); the first request after it builds again. Requests run through the same http:request flow as the Express host, with the same request context: the user agent, x-frontmcp-* headers, traceparent and the MCP 2026-07-28 _meta client info.
The client IP comes from Deno’s info.remoteAddr, Bun’s server.requestIP(request), or, only on Cloudflare Workers, the CF-Connecting-IP header. The handler is stateless: session-based (2025-06-18) clients get no Mcp-Session-Id and every request stands alone. See Cloudflare Worker for stateful sessions with Durable Objects.

createDirect(options)

Create a DirectMcpServer for programmatic access.
Best for: Testing, embedding, CLI tools, agent backends.

createForGraph(options)

Create an instance for introspection without starting server.
Best for: Graph visualization, introspection, analysis.

runStdio(optionsOrClass)

Run the server over stdio (stdin/stdout JSON-RPC). No HTTP/TCP port is bound — the HTTP server is disabled for this entry point.
Best for: Claude Desktop, Claude Code, Cursor, and other stdio MCP clients. Accepts either a @FrontMcp-decorated class or the same config object you pass to @FrontMcp().
Importing a @FrontMcp-decorated class starts an HTTP server at import time unless FRONTMCP_STDIO=1 is set before the import. For a hand-written stdio entry, keep the config object in its own module (as above) so no decorated class is evaluated. For built servers, use the --stdio runner (./dist/node/<name> --stdio) or a --target cli binary (<bin> --stdio) — both set the flag for you, so the decorated server connects over stdio and binds no port.

Instance Methods

getConfig()

Get the server configuration.

getScopes()

Get all initialized scopes.

getPrimaryScope()

Get the scope that holds the server’s own apps. createDirect, createFetchHandler, runStdio and connect() serve this scope.
A standalone app, such as DashboardApp, gets a scope of its own that comes first in getScopes(), so the first scope is not always the server’s. When no app shares the server’s scope (every app is standalone, or splitByApp), this is the first scope.
Up to 1.8.2, those entry points served the first scope: with DashboardApp in apps they served the dashboard’s tools instead of the server’s.

start()

Start the HTTP server (called internally by bootstrap).

Initialization Sequence

Usage Examples

Development Server

Serverless (Vercel)

Testing

Claude Desktop Integration

Keep serverConfig separate from your @FrontMcp-decorated main.ts. The decorator starts an HTTP server when its module is imported, so a stdio entry that imports the decorated class would bind a port alongside stdio. Importing just the config object avoids that.

@FrontMcp

Server decorator

Scope

Registry access

DirectClient

Programmatic access

Deployment

Deployment guides