Fastify
Run an xmcp MCP server on Fastify. Works on any Node.js deployment target including AWS Lambda.
For the complete documentation index, see llms.txt. Markdown variants of every page are available by appending .md to the URL.Installation
xmcp can work on top of your existing Fastify project. To get started, run the following command in your project directory:
After setting up the project, your build command should look like this:
xmcp build bundles your tools into .xmcp/adapter.
Usage
Install Fastify and register the MCP handler on your server:
For browser-origin clients, add CORS and preflight handling at the Fastify app
level (e.g. @fastify/cors). The xmcpHandler handles the MCP endpoint only
— it does not register an OPTIONS route.
AWS Lambda
Use @fastify/aws-lambda as the Lambda bridge:
The default buffered form (awsLambdaFastify(app)) works for all JSON-RPC POST requests (initialize, tools/call, etc.). GET/SSE is not supported in buffered mode — see the streaming form below.
SSE support on Lambda
To support SSE via GET /mcp, use a Lambda Function URL with InvokeMode: RESPONSE_STREAM and switch to the streaming form:
middleware.ts is not supported in adapter mode.