---
title: "How do I give an OpenAI Agents SDK agent access to fund data?"
description: "Add a function tool that calls the fund API by ISIN, or attach the hosted MCP server, so an OpenAI Agents SDK agent answers fund questions with current figures. Code for both."
canonical: https://fundfactsapi.com/answers/fund-data-for-openai-agents-sdk
published: 2026-09-12
updated: 2026-10-13
publisher: FundFacts API
---

# How do I give an OpenAI Agents SDK agent access to fund data?

**Short answer:** Either wrap one API call in a @function_tool (Python) or tool() (TypeScript) that returns the fields you want the agent to see, or attach the FundFacts MCP server (https://fundfactsapi.com/api/mcp) as a hosted MCP tool with an Authorization header. The agent then calls get_fund, search_funds, compare_funds, analyze_portfolio or fund_overlap as needed and answers with the current published figures and their as-of date.

## Function tool (Python)

```python
# pip install git+https://github.com/fundfactsapi/fundfactsapi-python openai-agents
from agents import Agent, Runner, function_tool
from fundfacts import FundFacts

ff = FundFacts()  # reads FUNDFACTS_API_KEY

@function_tool
def fund_facts(isin: str) -> dict:
    """Current factsheet for a fund or ETF ISIN: name, TER, 1-7 risk, category, top holdings, sector/country split, returns, as-of date."""
    f = ff.get_fund(isin)
    d = f["data"]
    return {"name": f["name"], "ter": d["headlineMetrics"]["ter"], "risk": d["riskRating"], "category": d["profile"]["category"],
            "top_holdings": d["topHoldings"][:10], "sectors": d["sector"][:8], "countries": d["geography"][:8],
            "calendar_returns": d["calendarReturns"], "as_of": d["dataAsOf"]}

agent = Agent(name="Fund analyst", instructions="Answer with figures from the tool and always state as_of. Empty fields are 'not disclosed'.", tools=[fund_facts])
print(Runner.run_sync(agent, "Compare the cost and sector mix of IE00B4L5Y983 and IE00B3RBWM25").final_output)
```

## Hosted MCP tool

The Agents SDK and the Responses API can call a remote MCP server on your behalf; no wrapper code:

```python
from agents import Agent, HostedMCPTool

agent = Agent(
    name="Fund analyst",
    tools=[HostedMCPTool(tool_config={
        "type": "mcp",
        "server_label": "fundfacts",
        "server_url": "https://fundfactsapi.com/api/mcp",
        "headers": {"Authorization": "Bearer ffk_..."},
        "require_approval": "never",
    })],
)
```

```typescript
// npm install @openai/agents
import { Agent, hostedMcpTool, run } from "@openai/agents";

const agent = new Agent({
  name: "Fund analyst",
  instructions: "Quote dataAsOf with every figure.",
  tools: [hostedMcpTool({ serverLabel: "fundfacts", serverUrl: "https://fundfactsapi.com/api/mcp", headers: { Authorization: `Bearer ${process.env.FUNDFACTS_API_KEY}` } })],
});
const result = await run(agent, "How much do IE00B4L5Y983 and IE00B3RBWM25 overlap?");
console.log(result.finalOutput);
```

The MCP server exposes seven tools, each counted like the REST endpoint it wraps: `get_fund` (ISIN → the full factsheet payload), `search_funds` (name → ISINs, free), `compare_funds` (side-by-side table for several ISINs), `analyze_portfolio` (weighted look-through of a list of positions, Starter and above), `fund_overlap` (shared holdings between funds, Starter and above), `get_scpi` (French SCPI data by name or ISIN) and `search_scpi` (SCPI name → matches, free), plus a `tour` prompt that explains the service on the example fund IE00B4L5Y983, which is not counted. Every tool only reads data. Authentication is either your FundFacts account (OAuth 2.1 with PKCE, the sign-in the claude.ai, Claude Desktop and ChatGPT connectors run) or the same bearer API key as the REST API, sent as an `Authorization` header by editors, CLIs and frameworks. The [MCP server guide](https://fundfactsapi.com/docs/mcp) has the full tool reference, setup for every client and troubleshooting.

## Production notes

Give function tools a 300-second timeout for cold ISINs, cache by ISIN until `expiresAt`, and tell the agent that a 404 means "not a covered fund". Tool calls cost one request per fund found, the same as REST; misses are free.

## FAQ

### Do I need a credit card to try it?

No. The Free plan is 5 lookups per month with no card; sign up with an e-mail address or Google and the key is shown in the dashboard.

### Which ISINs work?

Any share class of a UCITS fund, ETF, money-market fund or open-end fund whose management company publishes a product page, factsheet and KID. Each share class has its own ISIN and is looked up on its own. Stocks, bonds and indices are not funds and return 404 fund_not_found.

## About FundFacts API

FundFacts turns any fund or ETF ISIN into one dated factsheet (fees and KID costs, the 1–7 risk indicator, holdings, sector and country exposure, returns) read from the fund house's own documents: as a client-ready PDF under your firm's name for advisers and wealth managers, as JSON through its API for developers, or inside ChatGPT and Claude through its MCP server.

FundFacts works inside ChatGPT and Claude as a connector (a remote MCP server): ask about any fund or ETF by ISIN, ticker or name and the assistant answers from FundFacts' dated figures, fees, risk, holdings, exposure and returns, with fund cards, side-by-side comparisons, holdings overlap and portfolio look-through.

- Free API key, no card: https://fundfactsapi.com/signup
- Documentation: https://fundfactsapi.com/docs (OpenAPI: https://fundfactsapi.com/openapi.json)
- MCP server: https://fundfactsapi.com/api/mcp (set-up for every client: https://fundfactsapi.com/mcp-server)
- Pricing: https://fundfactsapi.com/pricing
- Site index for AI assistants: https://fundfactsapi.com/llms.txt
- Informational data, not investment advice.
