MCP while you build, the API while it runs, one budget for both
By the end of this lesson you will have the EODHD MCP server connected to your agent in the starter folder, one question answered through it whose price the agent stated before spending it, and two readings of your account's usage counter, before and after, that differ by exactly that price.
The idea
If you have already connected the server, skip the setup: the budget is what this lesson is about.
Two roads to the same data
while you build you → agent → EODHD MCP server ─┐
(you signed in, no key in a file) ├─→ EODHD APIs → your daily calls
while it runs browser → your server-side proxy ─┘
(key in .env.local, read on the server)
The MCP server lets the agent query the real API while it writes your code, so it sees the actual shape of a response instead of remembering one. It belongs to build time. Your running app never talks to it; it goes through the proxy, with a key only the server reads.
Connecting it
The starter's .mcp.json already names the server:
{ "mcpServers": { "eodhd": { "type": "http", "url": "https://mcp.eodhd.com/v2/mcp" } } }
There is no key in that file, and there must never be one: the server signs you in with your EODHD account.
Claude Code reads .mcp.json. Start claude in the starter folder. The first time, it asks whether to trust the folder and whether to use the eodhd server from .mcp.json — a project's servers wait for your approval before they run. Then type /mcp, choose eodhd, and sign in in the browser window it opens.
Codex does not read .mcp.json; its servers live in ~/.codex/config.toml, in your home folder and outside every repository. One command from your shell adds the same server and opens the same browser sign-in straight away:
codex mcp add eodhd --url https://mcp.eodhd.com/v2/mcp
codex mcp login eodhd signs in again later, and /mcp in a session lists the server and its tools.
For Claude Code, the official plugin adds EODHD's skills and slash commands on top:
/plugin marketplace add EodHistoricalData/eodhd-claude-skills
/plugin install eodhd-api@eodhd-claude-skills
Its commands carry the plugin's name, /eodhd-api:eodhd-analyze rather than /eodhd-analyze. Codex has no build of the plugin; the same repository carries a Codex adapter, which runs on the helper scripts. Those scripts read an EODHD_API_TOKEN environment variable — visible to every command the agent runs — so with either agent, in this course stay with the sign-in.
The bill
The MCP server is not a free side door: a question answered through it is billed in API calls like your app's requests, against the same daily limit. Calls are the currency, and each endpoint charges its own price per request. Measured on a live account:
| The agent asks for | Calls |
|---|---|
| your account's usage | 0 |
| daily history, dividends, splits, an exchange's symbol list | 1 per request, however many rows |
| a live price | 1 per symbol — three symbols, three calls |
| news | 5 per ticker |
| screener, technical indicators, intraday bars | 5 |
| fundamentals, options | 10 |
| end-of-day prices for a whole exchange at once (bulk) | 100 |
The free plan gives 20 calls a day, only the past year of daily history, and a one-time bonus of 500 calls that is drawn on after the day's twenty; fundamentals, options, the screener, technical indicators, intraday bars and bulk are not on it, and asking for them is refused with 403. Read the table against a small allowance anyway, because the prices are the same on every plan that has those endpoints: one fundamentals lookup is ten calls, and "how did the whole US market do yesterday?" is a hundred in a single tool call. A request dearer than the calls you have left is refused whole, not charged in part. A misspelled ticker that comes back 404 still costs its price. When the day's calls and any extra ones are gone the API answers 402 until midnight GMT; 429 is a different limit — too many requests within one minute — and it arrives with a Retry-After header saying when to try again.
Your brake
The starter's rules already ask the agent to state the cost of any request and wait for a yes. That is advice. The enforced version makes every call to the server stop for your approval, whichever mode the session is in.
In Claude Code it is an ask rule on the server's tools, in your personal .claude/settings.local.json:
{ "permissions": { "ask": ["mcp__eodhd__*"] } }
In Codex it is an approval mode on the server. Open ~/.codex/config.toml, find the entry codex mcp add wrote, and add the last line:
[mcp_servers.eodhd]
url = "https://mcp.eodhd.com/v2/mcp"
default_tools_approval_mode = "prompt"
Your free key, and .env.local
This is the first lesson that needs a key of your own; the demo token will not do, because its counter is shared by everyone. Get yours once, and later lessons refer back here:
- Register at
eodhd.com/register(free, no card) and confirm your email. - Log in. Your dashboard shows your API token, a string of letters and digits. That is the key; the free plan gives it 20 calls a day.
- In the starter folder, copy the template:
cp .env.example .env.local(in Git Bash or on a Mac; in PowerShellcopy .env.example .env.local). The file now exists, and git ignores it. - Open
.env.localin your editor (not through the agent, which is forbidden to read it) and replaceyour_key_herewith your token on theEODHD_API_KEY=line. The template has noEODHD_MOCKline, and for this lesson there should be none: mock mode off. Lesson 4 adds it.
Restart npm run dev after any change to this file.
Measure, do not trust
Reading your account's counter costs nothing. The starter serves it at /api/usage when your own key is in .env.local. Read it, ask, wait a few seconds because the counter lags, and read it again. The difference is what the question cost.
Everything the API returns is licensed to you for personal use; showing it to other people is a licensing question, and none of it is investment advice.
Try it now
The prompt
Put your free key in .env.local as described above, turn mock mode off (no EODHD_MOCK=1 line), run npm run dev in one terminal and the agent in another. Use the address npm run dev prints on its Local: line (usually http://localhost:3000; if that port is busy it picks 3001, and the curl below must use the same one). Read the counter first. On Windows PowerShell write curl.exe where the lessons say curl, because plain curl there is a different command; in Git Bash it works as written.
curl -s http://localhost:3000/api/usage
It answers with fields like these, with your own numbers:
{ "plan": "free", "used": 3, "dailyLimit": 20, "remaining": 17, "pageLoadCalls": 5, "mock": false }
Then paste:
Using the eodhd MCP server, get the last five daily closes for AAPL.US.
Before you call anything, tell me which tool you will use and how many
API calls it will cost, and wait for my yes.
What the agent should do
- Name one tool for daily history and a price of one call, then stop and wait.
- After your yes, make exactly one call — with the brake in place you approve it a second time — and print five dates with five closes.
- Write nothing to disk. This is a question, not a change.
Then write your development budget yourself, in your editor: one line under Data in PLAN.md, such as "Development budget: 10 calls a day through the MCP server; the app gets the rest."
If you cannot finish the measurement today (no confirmation email yet, or a work browser that will not open the sign-in window), nothing later depends on it: lesson 4 onward runs in mock mode, with no key and no server. Write the budget line anyway, add "not measured yet" after it, and come back to the counter when the server connects.
Check it yourself
- The agent's estimate came before the call, in its own words, and said one call.
- Wait a few seconds after the answer, then run the same
curlagain.usedwent up by one. - Ask the same question a second time. It costs another call: nothing is cached for you.
- Type /mcp. The
eodhdserver is listed as connected. - Open the files that configure the server:
.mcp.jsonand.claude/settings.local.jsonfor Claude Code,~/.codex/config.tomlfor Codex. None of them contains a key.
Break it on purpose
Ask for something expensive and refuse it: "Using the eodhd MCP server, compare the fundamentals of Apple and Microsoft." The agent should price it before it runs anything, two requests at ten calls, twenty in all, and on the free plan it should also say that fundamentals are not included. Either way it waits. Say no.
Compare with ours
Our settings and plan note
{
"permissions": {
"ask": ["mcp__eodhd__*"]
}
}
On Codex, the three lines of [mcp_servers.eodhd] shown above under "Your brake", in ~/.codex/config.toml.
And under Data in PLAN.md, one line: "Development budget: 10 calls a day through the MCP server; the app gets the rest." The branch ref/work-with-an-agent/3 of the starter repository carries the Claude Code settings file as .claude/settings.local.example.json — a local settings file is personal and stays out of git, so copy it.
Checkpoint
git status # PLAN.md, and no .env* and no settings.local.json
git add -A
git commit -m "plan: development budget for MCP calls"
The commit carries the PLAN.md line, not the local settings file: the starter's .gitignore keeps .claude/settings.local.json out, and Codex's config lives outside the repository and never enters it. Then answer this lesson's questions.