Home Documentation Playground Pricing API Status Blog About FAQ Support

Add AllRatesToday to an OpenAI Agents SDK Agent with MCP

Reviewed by Madhushan, Fintech Developer — May 2026
OpenAI agent connected to currency tools

The OpenAI Agents SDK 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 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:

Prerequisites

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:

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

PromptTool 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 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. 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.

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 — 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 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

Related Articles