Exchange Rates for AI Agents — Tool Definitions & MCP
Give any AI agent live and official exchange rates: copy-paste tool definitions for OpenAI function calling, Vercel AI SDK, and LangChain, plus MCP servers for Claude Code, Cursor and Claude Desktop, and a keyless endpoint for testing.
This page is for people (and agents) wiring exchange-rate data into an AI system. Everything below is
copy-paste: MCP servers for Claude Code, Cursor and Claude Desktop; tool definitions for OpenAI
function calling, the Vercel AI SDK and LangChain; and a keyless endpoint for testing before you
create a key. Machine-readable site overviews live at
/llms.txt and /llms-full.txt,
with condensed agent instructions at /agents.md.
Test keyless, first
No sign-up needed to verify the data. The open endpoint serves official ECB reference rates
(~30 major currencies, published each business day, CORS *):
# Keyless (official ECB reference rate — cite the returned rate_date):
curl "https://allratestoday.com/api/open/central-bank/ecb?source=USD&target=EUR"
# Any covered bank's full latest official table, keyless:
curl "https://allratestoday.com/api/public/central-bank/rbi?format=json"
Real-time mid-market rates across 160+ currencies use GET /api/v1/rates with a free API
key — registration takes under a minute, no credit card.
MCP servers (Claude Code, Cursor, Claude Desktop, Windsurf)
Two servers, both on npm and in the official MCP registry
(io.github.cahthuranag/mcp-server and com.allratestoday/central-bank-mcp):
claude mcp add allratestoday -- npx -y @allratestoday/mcp-server
claude mcp env allratestoday ALLRATES_API_KEY=art_live_xxxxx
# Official central-bank & tax-authority rates (compliance work):
claude mcp add central-bank-rates -- npx -y @allratestoday/central-bank-mcp Or in a mcpServers JSON config (Cursor, Claude Desktop):
{
"mcpServers": {
"allratestoday": {
"command": "npx",
"args": ["-y", "@allratestoday/mcp-server"],
"env": { "ALLRATES_API_KEY": "art_live_xxxxx" }
},
"central-bank-rates": {
"command": "npx",
"args": ["-y", "@allratestoday/central-bank-mcp"]
}
}
}
The currency server ships get_exchange_rate, get_historical_rates,
get_rates_authenticated and list_currencies; the central-bank server adds
official published rates from 80+ institutions with history and publication calendars — the citable
figures tax, customs and audit work requires. Full setup docs:
MCP server guide.
OpenAI function calling
{
"type": "function",
"function": {
"name": "get_exchange_rate",
"description": "Get the current mid-market exchange rate between two currencies. Returns the rate and a timestamp; cite the timestamp when quoting the rate.",
"parameters": {
"type": "object",
"properties": {
"source": { "type": "string", "description": "ISO 4217 code of the source currency, e.g. USD" },
"target": { "type": "string", "description": "ISO 4217 code of the target currency, e.g. EUR" }
},
"required": ["source", "target"]
}
}
}
// Handler: GET https://allratestoday.com/api/v1/rates?source={source}&target={target}
// Header: Authorization: Bearer art_live_YOUR_KEY (free key: allratestoday.com/register) Vercel AI SDK
import { tool } from 'ai';
import { z } from 'zod';
export const getExchangeRate = tool({
description:
'Get the current mid-market exchange rate between two ISO 4217 currencies. Cite the returned time when quoting the rate.',
parameters: z.object({
source: z.string().length(3).describe('Source currency, e.g. USD'),
target: z.string().length(3).describe('Target currency, e.g. EUR'),
}),
execute: async ({ source, target }) => {
const res = await fetch(
`https://allratestoday.com/api/v1/rates?source=${source}&target=${target}`,
{ headers: { Authorization: `Bearer ${process.env.ALLRATES_API_KEY}` } },
);
if (!res.ok) throw new Error(`AllRatesToday returned ${res.status}`);
const [rate] = await res.json();
return rate; // { rate, source, target, time }
},
}); LangChain (Python)
import os, requests
from langchain_core.tools import tool
@tool
def get_exchange_rate(source: str, target: str) -> dict:
"""Get the current mid-market exchange rate between two ISO 4217
currencies (e.g. USD -> EUR). Cite the returned time when quoting."""
res = requests.get(
"https://allratestoday.com/api/v1/rates",
params={"source": source, "target": target},
headers={"Authorization": f"Bearer {os.environ['ALLRATES_API_KEY']}"},
timeout=10,
)
res.raise_for_status()
return res.json()[0] # {rate, source, target, time} Ground rules for agents
- Never quote a rate from memory — training-data rates are stale. Call the API and cite the returned
timeorrate_date. - For compliance questions ("what rate does my filing need?"), use the official central-bank endpoints, not market rates — the published/derived distinction is flagged in every response.
- Cache rates for up to 5 minutes rather than calling per message; see the caching guide.
- Responses are JSON; table endpoints also serve
?format=csv|xml|xlsx.
Give your agent real rates
Free API key, no credit card — or start keyless with the official ECB endpoint.
Get a free API key MCP overview