---
title: "Add AllRatesToday to an OpenAI Agents SDK Agent with MCP"
description: "Wire the AllRatesToday MCP server into an OpenAI Agents SDK agent in Python. 150+ fiat currencies, mid-market rates, and historical data in ~10 lines of code."
canonical: https://allratestoday.com/blog/openai-agents-sdk-allratestoday-mcp/
source: AllRatesToday (https://allratestoday.com/) — Markdown mirror of the page above; index of all pages at https://allratestoday.com/llms.txt
generated: 2026-10-12T10:29:05.957Z
---

![OpenAI agent connected to currency tools](https://images.pexels.com/photos/8439094/pexels-photo-8439094.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940)

The [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) ships with first-class MCP support — you don't need an adapter, a custom function tool, or a wrapper. Point the SDK at any MCP server, and the agent's tool catalog grows automatically.

This post walks through wiring the [`@allratestoday/mcp-server`](https://www.npmjs.com/package/@allratestoday/mcp-server) into an OpenAI Agents SDK agent in Python. By the end you'll have an agent that answers *"what is 1,250 GBP in Singapore dollars right now?"* with a live mid-market rate, and *"chart USD/JPY over the last 30 days"* with a time series — both via the same SDK call.

## Why MCP and not a function tool?

You could write four `@function_tool`-decorated Python functions that wrap the AllRatesToday REST endpoints. It works. But MCP gives you a few wins:

- **One install, many runtimes.** The same npm package works in Claude Code, Cursor, Claude Desktop, Google ADK, and the OpenAI Agents SDK. Write nothing; just point and connect.
- **Tool schemas come from the server.** No need to redeclare parameter types or descriptions in Python — the MCP server publishes them.
- **Version safety.** When we ship a new tool or change a schema, you upgrade the package version. Your agent code doesn't move.

## Prerequisites

- **Python 3.10+**
- **Node.js 18+** (so `npx` can run the MCP server)
- **An OpenAI API key** set as `OPENAI_API_KEY`
- **A free AllRatesToday API key.** [Register here](https://allratestoday.com/register/) — no credit card. The key looks like `art_live_xxxxx`.

## Step 1: Install the SDK

```
pip install openai-agents
```

That's it. MCP support is built in — `MCPServerStdio` ships with the SDK.

## Step 2: Export both API keys

```
export OPENAI_API_KEY="sk-..."
export ALLRATES_API_KEY="art_live_..."
```

The OpenAI key authenticates the LLM. The AllRatesToday key authenticates the MCP server's calls to our backend.

## Step 3: Wire the MCP server into your agent

Create `agent.py`:

```
import asyncio
import os

from agents import Agent, Runner
from agents.mcp import MCPServerStdio

async def main():
    # Spawn the AllRatesToday MCP server as a subprocess
    async with MCPServerStdio(
        params={
            "command": "npx",
            "args": ["-y", "@allratestoday/mcp-server"],
            "env": {
                "ALLRATES_API_KEY": os.environ["ALLRATES_API_KEY"],
            },
        },
        cache_tools_list=True,  # cache the tool catalog across runs
    ) as allratestoday_mcp:

        agent = Agent(
            name="currency_agent",
            instructions=(
                "You answer currency questions using the AllRatesToday tools. "
                "Always cite the exact rate value you used. "
                "When a user gives a typo'd currency code, call list_currencies first "
                "to suggest a valid alternative."
            ),
            mcp_servers=[allratestoday_mcp],
            model="gpt-4.1-mini",
        )

        result = await Runner.run(
            agent,
            "What is 1,250 GBP in Singapore dollars right now?",
        )
        print(result.final_output)

if __name__ == "__main__":
    asyncio.run(main())
```

Two things worth noting:

- `cache_tools_list=True` avoids re-listing tools on every run. Safe because the MCP server's tool catalog is static within a session.
- The `env` dict is passed explicitly. The SDK doesn't forward your shell environment to the MCP subprocess by default — you have to opt in.

## Step 4: Run it

```
python agent.py
```

On first run, `npx` downloads `@allratestoday/mcp-server`. Then the agent calls `get_exchange_rate` with `source=GBP` and `target=SGD`, multiplies by 1,250, and prints the answer with the rate cited. Subsequent runs skip the download.

## Example prompts

| Prompt | Tool the agent picks |
| --- | --- |
| *"What's the USD/EUR rate?"* | `get_exchange_rate` |
| *"Show me USD/JPY over the last 30 days."* | `get_historical_rates` with `period=30d` |
| *"What was EUR/USD on 2025-03-14?"* | `get_rates_authenticated` with `time` |
| *"Give me EUR rates today against USD, GBP, CHF."* | `get_rates_authenticated` with comma-separated targets |
| *"Is BTL a supported currency?"* | `list_currencies` first |

## Composing multiple MCP servers

The `mcp_servers` parameter takes a list. You can stack the AllRatesToday MCP with anything else — a database server, a calendar server, a search server. The SDK merges the tool catalogs and lets the model route across all of them:

```
async with (
    MCPServerStdio(...) as allratestoday_mcp,
    MCPServerStdio(...) as postgres_mcp,
):
    agent = Agent(
        name="finance_ops_agent",
        mcp_servers=[allratestoday_mcp, postgres_mcp],
        instructions=(
            "Use the AllRatesToday tools for live FX. "
            "Use the Postgres tools to query our transactions table. "
            "Combine them to answer questions like 'what is yesterday's "
            "revenue in USD?'."
        ),
    )
```

This is where MCP starts to pay off — the SDK doesn't care which server a tool came from. Add capabilities by adding servers.

## Streaming the run

For interactive UIs, swap `Runner.run` for `Runner.run_streamed` and iterate the events. Tool calls and final tokens both surface as events you can render in real time:

```
result = Runner.run_streamed(agent, "What is the USD to EUR rate?")
async for event in result.stream_events():
    if event.type == "tool_call":
        print(f"[tool] {event.name}({event.arguments})")
    elif event.type == "text_delta":
        print(event.delta, end="", flush=True)
```

## Production considerations

### 1. Rate limits

The free tier is enough for testing. Production agents often make 2–5 tool calls per user turn, so plan capacity accordingly. Check the [pricing page](https://allratestoday.com/#pricing) for production tiers.

### 2. Cold start

The first `npx` invocation downloads the package (~50KB plus deps). On hot reload, subprocess startup is <500ms. If you're deploying behind a long-lived server, keep the `async with` block open for the lifetime of the process — don't tear it down between requests.

### 3. Tool routing

The SDK passes tool descriptions to the model verbatim. The MCP server descriptions are already optimized for agent selection — each tool tells the model exactly when to use it and what NOT to use it for — so you don't need to add extra prompt engineering on top.

### 4. Tracing

The Agents SDK has built-in tracing. View it at [platform.openai.com/traces](https://platform.openai.com/traces). Filter by your agent name to see exactly which tool the model picked, with arguments and return values. The single best debug tool.

## Common errors

### `FileNotFoundError: [Errno 2] No such file or directory: 'npx'`

Node.js isn't on PATH. Run `which npx`; if empty, install Node 18+ from [nodejs.org](https://nodejs.org/).

### Agent says it can't help with currency

The MCP server didn't start. Re-export your `ALLRATES_API_KEY` — the server exits with code 1 if the key is missing. Run `npx -y @allratestoday/mcp-server` directly in a terminal to see the error message.

### Agent invents a rate instead of calling the tool

Sharpen the `instructions` on the `Agent`: explicitly tell it to use the tools (e.g. *"You MUST use the AllRatesToday tools for any currency question. Never guess a rate."*). GPT-4 family models follow this kind of directive well.

## Next steps

1. [Get your free API key](https://allratestoday.com/register/) — 30 seconds.
2. Paste the agent code above. Change the prompt. Run.
3. Compose with a second MCP server — postgres, slack, github, whatever your stack needs.
4. Open an issue on [the MCP repo](https://github.com/cahthuranag/mcp-server) if you hit anything unexpected.

## Ship a GPT-powered agent with real FX data

150+ currencies, mid-market rates updated every 60 seconds. Free tier, no credit card.

 [Get your free API key](https://allratestoday.com/register/)

## Related Articles

- [Add AllRatesToday to a Google ADK Agent with MCP](https://allratestoday.com/blog/google-adk-allratestoday-mcp-agent/)
- [AllRatesToday MCP in Claude Code & Cursor](https://allratestoday.com/blog/allratestoday-mcp-server-claude-cursor/)
- [Introducing the AllRatesToday MCP Server](https://allratestoday.com/blog/new-allratestoday-mcp-server-for-ai/)
- [Exchange Rate APIs for AI Agents and LLMs](https://allratestoday.com/blog/exchange-rate-api-ai-agents-llm-2026/)
