Connect an AI agent - Cursor, Claude, or any MCP-compatible tool - to the HostAfrica API using a remote HTTP MCP server and Bearer token authentication.
This guide explains how to connect an AI agent (such as Cursor or Claude) to an HTTP MCP server using Bearer token authentication.
An HTTP MCP server runs as a remote web service rather than a local process on your machine. This is the transport used by the HostAfrica API MCP server. You access it at https://api.hostafrica.com/mcp, and every request is authenticated with a Bearer token that you generate yourself in the client area.
What is an HTTP MCP server?
Traditional MCP servers run locally as a subprocess on your machine (stdio transport). An HTTP server instead runs at a fixed URL and accepts connections over HTTPS. The agent sends tool calls as HTTP requests - no local installation of the server is required.
We provide two endpoints.
The first endpoint is https://api.hostafrica.com/mcp and it uses the same authentication mechanism as the API. This endpoint is suitable for use with MCP clients that support the Bearer token authentication mechanism. The Bearer token takes the place of a username and password. You include it in every request as an Authorization header. The server validates the token and either processes the request or returns a 401 Unauthorized error.
The second endpoint is https://mcp.hostafrica.com/mcp which is an OAuth 2.0 endpoint. It is compliant with MCP clients including https://claude.ai (Claude web) and Claude desktop. When using the OAuth 2.0 endpoint, you will be asked to authenticate with your HostAfrica API token. If you add a HostAfrica AI Connector in Claude.ai or Claude Desktop this will be the authentication mechanism used.
Cursor IDE setup
Configure the MCP server in ~/.cursor/mcp.json:
{
"mcpServers": {
"hostafrica-api": {
"type": "http",
"url": "https://api.hostafrica.com/mcp",
"headers": {
"Authorization": "Bearer <your-token>"
}
}
}
}
Replace <your-token> with the token you generated. Cursor sends the Authorization header automatically with every tool call - you do not need to include it in your prompts.
Once configured, check the settings in your Cursor IDE, which will show you whether the connection to the MCP server has succeeded. Open Cursor IDE or CLI and describe what you want in plain language. The agent will use the available MCP tools to carry out the operation.
Example
User: List my VPS services
Agent: [calls list_vps_services] -> returns your active services
Claude CLI setup
Add the MCP server to Claude's configuration:
claude mcp add --transport http hostafrica-api https://api.hostafrica.com/mcp \
--header "Authorization: Bearer <your-token>"
~/.claude/claude.json should reflect the change:
...
"mcpServers": {
"hostafrica-api": {
"type": "http",
"url": "https://api.hostafrica.com/mcp",
"headers": {
"Authorization": "Bearer <your-token>"
}
}
},
...
For more information, see the Claude Code remote HTTP server documentation.
Raw HTTP setup
If you are calling the server directly from a script or another tool, include the token in every request:
POST https://api.hostafrica.com/mcp
Authorization: Bearer <your-token>
Content-Type: application/json
Getting your token
Your Bearer token is fully self-service. If you do not have a HostAfrica account yet, register in the client area first, then log in to the HostAfrica Client Area to generate, rotate, or revoke your token at any time. Treat it like a password:
- Do not share it with others.
- Do not commit it to version control - use environment variables or a secrets manager.
- If you believe it has been compromised, rotate or revoke it yourself in the HostAfrica Client Area. Contact support if you need assistance.
For the full token walkthrough, see Getting Started with the Public API.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
401 Unauthorized | Token missing or incorrect | Check the value and confirm the Bearer prefix is present. |
401 Unauthorized | Invalid IP | Check that your source IP address is allowlisted for using the public API. You can configure this in the HostAfrica Client Area. |
403 Forbidden | Token valid but lacks permissions | Confirm your account has access to the resource, and contact support if the problem persists. |
| Connection refused / timeout | Wrong URL or server is down | Verify the URL and check server status. |
| Token expired | Tokens may have an expiry | Rotate the token yourself in the HostAfrica Client Area. |
| Tools not appearing in Cursor | mcp.json syntax error or wrong key name | Validate your JSON and check the server name matches what you expect. |
Security notes
- Always use HTTPS - never send a Bearer token over plain HTTP.
- Store tokens in environment variables or a secrets manager, not hardcoded in config files committed to version control.
- If you use
~/.cursor/mcp.json, restrict the file permissions (chmod 600 ~/.cursor/mcp.json). - Rotate or revoke tokens promptly if you suspect exposure - do this yourself in the HostAfrica Client Area.
For general support and feedback, submit a query through your client area.