MCP Server Guide
Give AI agents live and historical exchange rates, a searchable currency catalog, and precise conversions through the Currency-Exchange.app Model Context Protocol server. One endpoint, four tools, standard JSON-RPC.
What is MCP?
The Model Context Protocol (MCP) is an open standard that lets AI agents discover and call external tools through one uniform interface. Instead of hand-writing a function schema and HTTP handler for every provider — OpenAI, Anthropic, Google, or open-source models — you connect a server once and every MCP-capable client sees the same tool catalog.
Currency-Exchange.app hosts a read-only MCP server that exposes the same currency engine as the REST API: the fiat catalog, live and historical rates, and amount conversion. Agents authenticate with your API key and pay one credit per tool call, so no per-provider glue code is needed for payroll agents, expense bots, or pricing assistants.
Quick Start
Endpoint, transport, and authentication
One URL for every currency tool. No session setup — the server is stateless.
POST JSON-RPC 2.0 with the Accept: application/json, text/event-stream header.
Use a Currency-Exchange API key (Account → API keys). Keys are host-scoped.
Send demo-key with a valid TOTP in the x-ct header for a limited trial.
Keys are host-scoped: a key created on Currency-Exchange.app only authorizes the currency tools on this host, and credentials from other products are rejected. In local development the endpoint resolves to NEXT_PUBLIC_API_URL_MODULE_APP with the /mcp path appended.
Connect an MCP client
Any client that speaks Streamable HTTP works — Claude Desktop and Claude Code, Cursor, VS Code MCP extensions, or the reference TypeScript and Python SDKs. Add the server to your client configuration:
{
"mcpServers": {
"currency-exchange": {
"type": "http",
"url": "https://currency-exchange.app/api/mcp",
"headers": {
"x-api-key": "YOUR_API_KEY"
}
}
}
}The client must send Accept: application/json, text/event-stream on every POST — that is required by the Streamable HTTP transport. Your API key travels in the x-api-key header and is never part of the URL.
JSON-RPC walkthrough with curl
Start with the initialize handshake. The response carries the protocol version, server info, and agent instructions that document authentication and billing in the result itself.
curl -X POST https://currency-exchange.app/api/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-11-25",
"capabilities": {},
"clientInfo": { "name": "curl", "version": "1.0.0" }
}
}'{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2025-11-25",
"serverInfo": { "name": "any-xyz", "version": "1.0.0" },
"instructions": "Billing and usage: - Every successful tool call consumes 1 credit ... except account_whoami which is free. - A HTTP 402 PAYMENT_REQUIRED response means the account is out of credits — direct the user to the product pricing page to top up, then retry."
}
}Then call a tool. This example converts 250 USD to EUR — every response includes both a machine-readable structuredContent object and a text mirror, so simple clients can render the text line directly.
curl -X POST https://currency-exchange.app/api/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "currency_convert",
"arguments": { "amount": 250, "from": "USD", "to": "EUR" }
}
}'{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "text",
"text": "{\"from\":\"USD\",\"to\":\"EUR\",\"exchangeRate\":0.9125,...}"
}
],
"structuredContent": {
"from": "USD",
"to": "EUR",
"exchangeRate": 0.9125,
"rateTime": "2026-11-10T09:41:23.000Z",
"originalAmount": 250,
"convertedAmount": 228.125,
"convertedText": "250 USD equal to 228.13 EUR"
}
}
}Tool reference
Four read-only tools are exposed on this host. All of them declare readOnlyHint and idempotentHint, so agents can retry safely and providers know nothing here mutates state.
| Tool | What it returns | Key arguments | Credits |
|---|---|---|---|
| account_whoami | Identify the account behind the API key: user id, email, username. | none | Free |
| currency_list | Paginated fiat currency catalog with names, symbols, and locales. | codes, search, active, page, pageSize, sort | 1 per call |
| currency_get_rate | Live or historical exchange rate for a pair, plus the inverse rate. | from, to, date? | 1 per call |
| currency_convert | Convert an amount with full rate detail and a ready-to-read text line. | amount?, from, to, date? | 1 per call |
Historical lookups use the date argument (YYYY-MM-DD) on currency_get_rate and currency_convert. Omit it for the latest rate, or pass skipCache when freshness matters more than credits.
Billing and credits
⚡ One credit per tool call
Every successful tool call consumes one credit from the API key owner and appears in daily usage and billing. account_whoami is free, so agents can check identity and remaining credits before spending.
⚠️ HTTP 402 means out of credits
When the account runs dry, the server answers 402 PAYMENT_REQUIRED before the tool runs. Agents should tell the user to top up at /pricing and retry — this exact guidance is part of the initialize instructions.
🌍 Agents self-serve the contract
The initialize result carries agent instructions covering authentication, per-call cost, and the 402 policy, so any connected model learns the rules without hard-coded prompts.
Discovery surfaces
Plain-text site summary with the MCP endpoint, auth, and billing contract.
Machine-readable MCP server card for agent-side discovery.
Interactive Scalar reference with an MCP panel that connects in one click.
Agent integration checklist
Start every session with account_whoami — it is free and confirms the key works before credits are spent.
Cache rates inside your agent loop for a few seconds; repeated conversions in one conversation rarely need fresh rates.
Validate currency codes with currency_list before converting, so agents ask for clarification instead of burning credits on errors.
Pass date explicitly when the workflow needs an historical rate, and store rateTime as evidence with the result.
Treat 402 as a user-facing prompt to top up, and 401 as a key or host-scope problem — never retry it blindly.
Connect Your Agents to Live Currency Data
Create an API key, paste the server URL, and your agents convert currencies in their next conversation turn
Additional Resources
📚 API Documentation
Interactive Scalar reference with an MCP panel for one-click server connection.
View Documentation →💱 REST Integration Guide
Prefer plain HTTP? The conversion guide covers the REST endpoints behind each MCP tool.
Read the Guide →