Documentation Index Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
Use this file to discover all available pages before exploring further.
Class Definition
export class FrontMcpServerInstance extends FrontMcpServer {
config : HttpOptions ;
host : HostServerAdapter ;
}
Properties
Property Type Description configHttpOptionsHTTP configuration hostHostServerAdapterHost adapter (Express, etc.)
Methods
registerMiddleware(entryPath, handler)
Register middleware at a specific entry path.
registerMiddleware ( entryPath : string , handler : ServerRequestHandler ) : void
registerRoute(method, path, handler)
Register an HTTP route.
registerRoute (
method : HttpMethod ,
path : string ,
handler : ServerRequestHandler
) : void
prepare()
Prepare routes without starting the server.
Registers /health endpoint automatically
Prepares all configured routes
Call before getHandler() for serverless
getHandler()
Get the underlying HTTP handler for serverless export.
Returns the host adapter’s handler (e.g., Express app).
start()
Start the HTTP server on the configured port.
HttpOptions
interface HttpOptions {
port ?: number ; // default 3001
entryPath ?: string ; // MCP JSON-RPC entry path (default: '')
hostFactory ?: HostFactory ; // Custom host adapter
socketPath ?: string ; // Unix socket path (overrides port)
cors ?: CorsOptions | false ; // CORS config (default: permissive with built-in adapter)
}
Host Adapters
Default (Express)
Express is the default host adapter:
@ FrontMcp ({
info : { name : ' Server ' , version : ' 1.0.0 ' },
apps : [ MyApp ],
http : { port : 3001 },
// Uses ExpressHostAdapter by default
})
Custom Host Factory
Provide a custom host adapter:
import { FastifyHostAdapter } from ' ./adapters/fastify ' ;
@ FrontMcp ({
info : { name : ' Server ' , version : ' 1.0.0 ' },
apps : [ MyApp ],
http : {
port : 3000 ,
hostFactory : ( config ) => new FastifyHostAdapter ( config ),
},
})
Host Adapter Interface
export abstract class HostServerAdapter extends FrontMcpServer {
abstract prepare (): void ;
abstract getHandler (): unknown ;
abstract start ( port : number ): Promise < void > | void ;
}
Usage Examples
Standard Deployment
import { FrontMcpInstance } from ' @frontmcp/sdk ' ;
import config from ' ./server ' ;
// bootstrap() handles server creation and start
await FrontMcpInstance . bootstrap ( config );
Manual Server Access
import { FrontMcpInstance , FrontMcpServer } from ' @frontmcp/sdk ' ;
const instance = await FrontMcpInstance . createForGraph ( config );
await instance . ready ;
// Access server from providers
const server = instance . providers . get ( FrontMcpServer );
// Register additional routes
server . registerRoute ( ' GET ' , ' /custom ' , ( req , res ) => {
res . json ({ custom : true });
});
// Start server
server . start ();
Serverless Deployment
// api/mcp.ts
import { FrontMcpInstance } from ' @frontmcp/sdk ' ;
import config from ' ../src/server ' ;
// createHandler() prepares and returns the handler
export default FrontMcpInstance . createHandler ( config );
Custom CORS
@ FrontMcp ({
info : { name : ' Server ' , version : ' 1.0.0 ' },
apps : [ MyApp ],
http : {
port : 3001 ,
cors : {
origin : [ ' https://app.example.com ' , ' http://localhost:3000 ' ],
credentials : true ,
maxAge : 86400 ,
},
},
})
Health Endpoint
FrontMCP automatically registers a /health endpoint:
curl http://localhost:3001/health
# {"status":"ok"}
This is useful for:
Load balancer health checks
Kubernetes liveness probes
Monitoring systems
FrontMcpInstance Server bootstrap
@FrontMcp Server configuration
Serverless Deployment Serverless guide
Production Build Production deployment