Express

Plug xmcp into your existing Express application.

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 Express project. To get started, run the following command in your project directory:

Code
npx init-xmcp@latest

After setting up the project, your build and dev command should look like this:

Code
{
  "scripts": {
    "dev": "xmcp dev & existing-build-command",
    "build": "xmcp build && existing-build-command"
  }
}

When running dev or build command, xmcp will bundle your tools into .xmcp/adapter.

You should add the /mcp endpoint in your existing server.

Code
import { xmcpHandler } from "path/to/.xmcp/adapter";

app.get("/mcp", xmcpHandler);

app.post("/mcp", xmcpHandler);
Info
middleware.ts is not supported in this mode.