Guidance and examples for extracting User API Keys from incoming HTTP requests.
consume()
or validate_api_key()
methods, your MCP server first needs to extract the User API Key sent by the client. By convention, AgentPay User API Keys are sent in the HTTP header.
X-AGENTPAY-API-KEY
Clients (like Cursor or Claude) should be configured to send the User API Key in this header when using remote MCP Servers.
http.server
), you’ll need to adapt the above Starlette + FastMCP pattern to work with your framework. Here are conceptual examples showing how to integrate User API Key extraction and validation with your framework’s routing:
Example (Conceptual - Flask with FastMCP):
X-AGENTPAY-API-KEY
is the standard casing, your extraction logic should ideally handle variations if your framework doesn’t normalize them (most modern ones do).