MCP / LangChain
Using this with LangChain
MCP tool adapter, or a thin wrapper over the REST API.
Setup
- Create a key on the free tier.
- Load the MCP tools through the framework adapter.
- Bind them to your agent alongside your other tools.
- Set a per-run request budget so a retry loop cannot exhaust your quota.
Budget from reformulations, not from users
Framework agents reformulate aggressively when a first result looks unsatisfying, so one user question routinely becomes three to five requests. This is the single biggest cause of surprise cost on this integration, and it is invisible in testing because you naturally test one query at a time and watch it succeed. Estimate from expected reformulations per question, and set a per-run request budget so a loop that fails to converge cannot consume a month of quota in an evening.
Order and describe your tools deliberately
Given both an article search tool and a story grouping tool with similar descriptions, an agent will usually take the first plausible one. If that is article search, it will fill its own context with syndicated duplicates and then reason over them. Put story grouping first and describe it as the default for event questions, reserving article search explicitly for coverage analysis. This costs one line and is the difference between a working integration and one that is quietly wasting most of its context window.
Retries interact badly with rate limits
Treat rate-limit responses as a distinct case from network errors, and then distinguish the two kinds. The per-minute bucket refills continuously, so the retry-after of one second is accurate and exponential backoff there simply idles on an allowance you already paid for. An exhausted monthly quota returns the same status and will not clear for days; retrying it is pure waste. The x-quota-remaining header is zero for the second case and not for the first. This bites harder here than elsewhere because the agent loop can be several layers away from wherever you configured the client.
Notes and the usual pitfall
- Framework agents reformulate queries aggressively under uncertainty, so the request multiplier per user question is often three to five rather than one. Budget from that, not from user count.
- Prefer the story-grouping tool in the tool list and describe it as the default; otherwise the agent will reach for article search and fill its own context.
Watch for: The default retry behaviour treats every rate-limit response the same way. Two different conditions return 429 here, and only one is worth waiting for: the per-minute limit refills continuously and wants a one-second retry, while an exhausted monthly quota will not clear until the period resets. Tell them apart with the x-quota-remaining header.