Middlewares
For the complete documentation index, see llms.txt. Markdown variants of every page are available by appending .md to the URL.Middlewares intercept HTTP requests and responses, enabling authentication, rate limiting, and other processing tasks.
Create a src/middleware.ts file to define your middleware:
Info
xmcp provides built-in middlewares for common tasks like API key authentication and JSON web token authentication.
Chaining middlewares
Define multiple middlewares as an array to chain them in sequence:
Accessing headers
Use the xmcp/headers module to read request headers in your tools, prompts, or resources—useful for API keys, authentication tokens, and other custom headers.