FrontMCP API reference

Reference is the complete documentation for FrontMCP: every decorator, option and API, what it does, and what to do when it doesn't work. Each page is checked against the FrontMCP version this site documents, and most examples run right on the page. To learn FrontMCP from the beginning, start with the Quick Start; to see how it differs from the official MCP SDK and other TypeScript frameworks, read Compare.

Each page follows the same structure:

  • Reference: the signature, every option, what it returns, and caveats.
  • Usage: common tasks, each with a runnable example.
  • Troubleshooting: problems you might hit, titled by what you'll see.

@frontmcp/sdk

Every page of the SDK reference, grouped, with which page answers which task, is in the SDK overview.

Decorators

Decorators declare what your server exposes.

DecoratorDeclares
@FrontMcpThe server: its apps and server-wide settings
@AppA group of tools, resources, prompts and providers
@ToolA function the model can call
@ResourceData at a fixed URI
@ResourceTemplateData at a family of URIs, like ticket://{id}
@PromptA reusable message template
@ProviderA service tools can share, via dependency injection
@JobA unit of work that can run in the background, with retries and a run record
@WorkflowJobs run as steps, in dependency order
@AgentA tool that runs its own model loop, with its own tools and instructions
@SkillInstructions a client's model can find and follow, served as resources
@PluginA reusable package of providers, hooks and context extensions
@ChannelEvents a server pushes to clients
Hook decoratorsCode that runs before, after or around a stage of a call

Context

Inside execute(), this is the call's context. Context classes lists what each kind of context has; the most used members have their own pages:

MemberDoes
this.authWho is calling: user, scopes and roles
this.contextThe request: its id, trace, auth info and headers
this.elicit()Asks the user for input in the middle of a call
this.progress()Reports how far a long call has got
this.notify()Sends a log message to the client
this.get()Gets a provider (see @Provider)
this.fetch()Makes an outbound HTTP request
this.fail()Ends the call with an error the model can read
this.callTool()Calls another tool on the server
this.respond()Ends the call early with a finished result

Running a server

APIDoes
FrontMcpInstanceStarts the HTTP server a decorated class describes
createFetchHandler()A web-standard Request → Response handler, for Workers, Deno, Bun and frameworks
create() and createDirect()A server in your own process, called without HTTP
connect() and client adaptersThe server's tools, ready for Claude, OpenAI, LangChain or the Vercel AI SDK

Limits, errors and the scope

Server and configuration

How a server is put together and configured, across decorators:

PageCovers
Server overviewEvery page in this section, grouped, and which page answers which task
Apps, discovery and splittingComposing a server from apps, what clients discover, and serving apps separately
Flows and stagesEvery flow FrontMCP runs for a request, and the stages hooks attach to
Loading apps from npm (ESM)App.esm(): apps loaded from a registry at run time
Remote serversAnother MCP server mounted as an app
Configuration filesConfig files and every environment variable FrontMCP reads
LoggingThe server's own logs, levels and transports
Observability and telemetryTracing, metrics and health endpoints
Environment awarenessCapabilities that depend on the runtime and environment

Authentication

How a server authenticates MCP clients, and decides what each caller may do:

PageCovers
Authentication overviewEvery page in this section, grouped, and which page answers which task
Auth modesEvery mode, what it protects, and how to choose
Tokens and sessionsHow tokens are verified, sessions, and the secrets behind them
Local authFrontMCP as its own OAuth authorization server
Custom login UIThe login and consent pages, and replacing them
Progressive authAsking for more access later, when a tool needs it
Remote and proxied authAn external identity provider as the authorization server
Client ID metadata (CIMD)Clients identified by a metadata document instead of registration
AuthoritiesRoles, permissions and rules on tools, resources, prompts, agents and skills
Auth in productionThe checklist for running an authenticated server

Plugins and adapters

Official packages that add behaviour to a server, or turn an API into tools:

PageCovers
Plugins overviewThe official plugins and adapters, their packages, and how to add them to a server
CacheReusing a tool's result for identical calls, per caller or shared
RememberMemory tools can read and write across calls, per session, user or tool
ApprovalRequiring the user's approval before a tool runs
Feature flagsTurning tools, resources and prompts on and off with flags
CodeCallLetting the model search many tools and call them from a short script
Skilled OpenAPIServing a REST API as a few skills instead of one tool per endpoint
OpenAPI adapterEvery operation in an OpenAPI spec as a tool

Tool UI and React

Widgets a tool shows in the host, and React apps that talk to a server:

PageCovers
Tool UIA tool's ui option, the ui://widget resource, serving modes and the widget's Content Security Policy
Widget componentsWidgets written as React files, @frontmcp/ui hooks and components, and @frontmcp/uipack
Hosts and platformsHow the client is recognized, the widget's bridge, MCP Apps hosts and the OpenAI Apps SDK
@frontmcp/reactA server in the same process as a React app: the provider, its client, several servers, stores
React hooksCalling tools, reading resources and prompts, and registering tools from components
React componentsGenerated forms, result viewers, mcpComponent, DOM resources and the router bridge

@frontmcp/testing

End-to-end tests that start a server and call it like a client:

PageCovers
test and the mcp clientWriting tests, the client, and the result wrappers
MatchersThe MCP-specific expect matchers
Fixturestest.use(), and the mcp, server and auth fixtures and their lifetimes
Interceptors and HTTP mockingmcp.mock, mcp.intercept, MockAPIServer and httpMock
Testing authenticationTokens, clients that call as a user, and MockOAuthServer

CLI and Nx

Creating, running and building servers, alone or in an Nx workspace:

PageCovers
frontmcp CLIEvery command and option: create, dev, build and its targets, test, inspector and more
Nx pluginWhat @frontmcp/nx adds, installing it, and the workspace layout
Nx generatorsEvery generator, its options, and what it writes
Nx executorsEvery executor, its options, and the command it runs
Monorepo patternsApps, shared libraries and server shells, and composing apps into one server

Deployment

Building a server and running it in production:

PageCovers
Deployment overviewEvery page in this section, grouped, and which page answers which task
Production buildfrontmcp build, what each target writes and bundles, and how the result runs
Node.js and DockerThe node build on a machine, in Docker, with Redis in Compose, behind nginx, or on a Unix socket
VercelThe Vercel target, what the function serves, and Vercel KV
AWS LambdaThe Lambda handler, what ships beside it, and the events it accepts
Cloudflare WorkersThe Worker entry, wrangler.toml, secrets and bindings
RedisThe redis option, what's kept under which keys, and what happens when Redis is down
SQLiteSessions, tasks and pending questions in a SQLite file on one machine
High availabilitySeveral instances behind a load balancer, and what they must share
Health checks and metrics/healthz, /readyz and /metrics on each runtime, and wiring them to probes
Security headers and transportHeaders, bind address and host checks, body limits, and exposed endpoints
Connecting MCP clientsClients over Streamable HTTP, stdio or a Unix socket, and MCP Bundles

Guides