Middlewares
Middlewares intercept HTTP requests and responses, enabling authentication, rate limiting, and other processing tasks.
Create a src/middleware.ts file to define your middleware:
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.