API Key

To enable API key authentication, you can use the apiKeyAuthMiddleware middleware on your app.

src/middleware.ts

If no headerName is provided, the middleware will default to x-api-key.

This middleware can also be used with a validation function. It should return a boolean value indicating if the API key is valid.

src/middleware.ts

Next time you connect to your MCP server, you'll need to provide the API key in the x-api-key header (or the name you specified in the middleware).

Your connection object will look like this:

Make sure to check the connecting documentation for more details on the different clients.

One framework to rule them all

    API Key | xmcp Documentation