@frontmcp/host-express
Covers FrontMCP 1.15.2 as of
Use @frontmcp/host-express when your server needs Express middleware or request and response APIs such as req.ip and res.sendFile(). A server whose routes only need web Request and Response objects can use the built-in host.
import { expressHost, type ExpressHostAdapterOptions } from "@frontmcp/host-express";
const hostFactory = expressHost();
Reference
expressHost(overrides?)
| Parameter | Type | Default | Description |
|---|---|---|---|
overrides | ExpressHostAdapterOptions | none | Host options to override after FrontMCP resolves CORS, security, body limits and timeouts. This type aliases the SDK's HostAdapterOptions. |
Returns a factory for http.hostFactory. The package also exports ExpressHostAdapter, UserContentListener and DEFAULT_EXPRESS_BODY_LIMIT. Its host's getHandler() returns the Express app.
Caveats
The package takes Express 4.18 or later in the 4.x line, or Express 5.
With future.builtInHost: true and no hostFactory, FrontMCP selects this host when the package is installed. An explicit hostFactory controls the choice in either mode.
Usage
Selecting Express explicitly
npm install @frontmcp/host-express@1.15.2 express corsimport { expressHost } from "@frontmcp/host-express";
import { FrontMcp } from "@frontmcp/sdk";
import { Reports } from "./reports";
@FrontMcp({
info: { name: "reports", version: "1.0.0" },
apps: [Reports],
http: { hostFactory: expressHost() },
})
export default class ReportsServer {}Troubleshooting
HttpHostFeatureError
If the error names an Express member, verify that the server selects expressHost(). If you only need to return an HTTP response, a web-standard route works across hosts.