Once you have obtained your API Key for an MCP Server from the AgentPay Hub, you’ll need to configure your MCP Client to use it. This guide focuses on using mcp-remote to connect to remote MCP Servers.

Basic Configuration

To use an MCP Server, you’ll need to configure your client to send your User API Key in the request headers. The standard header name is X-AGENTPAY-API-KEY.

Using mcp.json

If you are using an MCP Client like Claude or Cursor that uses an mcp.json configuration file, you would add the header there. Here’s an example snippet for a remote MCP Server:
{
  "mcpServers": {
    "mcp-server-name": { // Choose a descriptive name
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "<MCP_SERVER_URL>", // e.g., "http://mcpserver.io/sse"
        "--header",
        "X-AGENTPAY-API-KEY:YOUR_USER_API_KEY_HERE",
        "--allow-http"  // Required for local development without HTTPS
      ],
      "env": {}
    }
  }
}
To configure your client:
  1. Replace mcp-server-name with a name you want to use for this tool in your client.
  2. Replace <MCP_SERVER_URL> with the MCP server’s endpoint URL (found in the Server’s metadata on the AgentPay Hub).
  3. Replace YOUR_USER_API_KEY_HERE with your actual User API Key.

Configuration Details

Let’s break down the key components of the configuration:
  • Server Name: Choose a descriptive name for your MCP Server configuration.
  • Command: Uses npx to run the mcp-remote package.
  • Arguments:
    • -y: Automatically answers “yes” to any prompts.
    • mcp-remote: The package name.
    • <MCP_SERVER_URL>: The Server’s endpoint URL.
    • --header: Specifies the API Key header.
    • X-AGENTPAY-API-KEY:YOUR_USER_API_KEY_HERE: Your authentication header.
    • --allow-http: Required for local development without HTTPS.

Testing Your Configuration

After configuring your client:
  1. Save your mcp.json file.
  2. Restart your MCP Client if necessary.
  3. Try making a request to the MCP Server.
  4. Check the “My API Keys” tab in the AgentPay Hub to verify the usage is being recorded.

Troubleshooting

If you encounter issues:
  • Invalid API Key: Ensure you’ve copied the API Key correctly from the AgentPay Hub.
  • Connection Errors: Verify the Server URL is correct and accessible.
  • Usage Not Recorded: Check your API Key status in the “My API Keys” tab.
For more details on monitoring your usage and API Key status, see our Understanding Usage guide.