SDK and MCP server

Deva Agent Key supports two integration methods: MCP (Model Context Protocol) for AI agents, and a REST API for any HTTP client. This article covers setup, authentication, and usage for both.

Written By Deva

Last updated About 2 months ago


MCP Server

What is MCP?

MCP (Model Context Protocol) is a standard that lets AI agents discover and call external tools. When you connect Deva as an MCP server, your agent automatically sees all 50+ APIs as callable tools β€” no manual endpoint configuration needed.

Server URL

https://api.deva.me/mcp 

Authentication

All MCP requests require a Bearer token:

Authorization: Bearer deva_YOUR_KEY_HERE 

Setup: Claude Code

claude mcp add deva \ --transport http \ https://api.deva.me/mcp \ --header "Authorization: Bearer deva_YOUR_KEY_HERE" 

Verify:

claude mcp list 

You should see deva in the list. Start a Claude Code session and the Deva tools are available immediately.

Setup: Cursor

Add to .cursor/mcp.json in your project root (or global config):

{ "mcpServers": { "deva": { "url": "https://api.deva.me/mcp", "headers": { "Authorization": "Bearer deva_YOUR_KEY_HERE" } } } } 

Restart Cursor after saving. The Deva tools appear in Cursor's tool list.

Setup: Other MCP-Compatible Agents

Any agent supporting MCP over HTTP can connect:

  • URL: https://api.deva.me/mcp

  • Transport: HTTP (streamable)

  • Auth header: Authorization: Bearer deva_YOUR_KEY_HERE

Consult your agent's documentation for how to add an MCP server.


REST API

For agents, scripts, or applications that don't support MCP, use the REST API directly.

Base URL

https://api.deva.me/v1/run/{resource_id} 

Authentication

Include your API key as a Bearer token:

Authorization: Bearer deva_YOUR_KEY_HERE 

Making a Call

curl -X POST https://api.deva.me/v1/run/google_search \ -H "Authorization: Bearer deva_YOUR_KEY_HERE" \ -H "Content-Type: application/json" \ -d '{"query": "Rust async programming guide"}' 

Response Format

Responses are JSON. The exact schema varies by API, but generally:

{ "result": { ... }, "credits_used": 2, "credits_remaining": 21998 } 

Error Codes

CodeMeaningAction

400

Bad request β€” invalid parameters

Check your request body

401

Unauthorized β€” invalid or missing key

Verify your API key

402

Insufficient credits

Purchase credits or upgrade plan

429

Rate limited

Wait and retry

500

Server error

Retry after a moment


API Key Management

Manage your keys at agentkey.deva.me/app/keys.

Create a Key

  1. Click Create API Key.

  2. The key is displayed once β€” copy and store it immediately.

  3. You can have up to 10 active keys.

Rotate a Key

  1. Click Rotate next to a key.

  2. A new key is generated; the old key is immediately revoked.

  3. Update your agent's configuration with the new key.

Revoke a Key

  1. Click Revoke next to a key.

  2. The key is immediately invalidated.

  3. Any agent using that key will receive 401 errors.

Key Metadata

Each key shows:

  • Creation date

  • Last used timestamp (last_used_at)

  • Key prefix (first few characters for identification)


Integration Patterns

Single Agent, Single Key

The simplest setup. One agent, one API key.

# Claude Code claude mcp add deva --transport http https://api.deva.me/mcp \ --header "Authorization: Bearer deva_abc..." 

Multiple Agents, Separate Keys

Create a dedicated key for each agent. This lets you:

  • Track usage per agent via last_used_at

  • Revoke access for one agent without affecting others

  • Rotate keys independently

CI/CD or Scripts

Use the REST API in scripts, GitHub Actions, or other automation:

# In a GitHub Action - name: Search for security advisories run: | curl -X POST https://api.deva.me/v1/run/google_search \ -H "Authorization: Bearer ${{ secrets.DEVA_API_KEY }}" \ -H "Content-Type: application/json" \ -d '{"query": "CVE-2024 critical vulnerabilities"}' 

Security Best Practices

  • Never commit API keys to version control. Use environment variables or secrets managers.

  • Rotate keys periodically β€” especially if team members change.

  • Use separate keys for development and production.

  • Revoke unused keys β€” don't leave old keys active.

  • Store keys in persona secrets if your agent runtime supports it (see Platform Capabilities).


Troubleshooting

MCP tools not appearing β†’ Restart your agent after adding the MCP server. For Claude Code, run claude mcp list to verify registration.

401 Unauthorized β†’ Check the key format: Authorization: Bearer deva_YOUR_KEY (note the space after "Bearer"). Verify the key hasn't been revoked.

402 Insufficient Credits β†’ Purchase credits at agentkey.deva.me/app/billing.

Slow responses β†’ Some APIs (especially AI model calls) take a few seconds. This is normal β€” the latency comes from the upstream provider.

Key rotation broke my setup β†’ After rotation, the old key is immediately invalid. Update your agent config with the new key. If you have multiple agents, update all of them.