I build and run a small MCP server that gives Claude eight tools: three that read my GitHub profile, four that read or write my DEV.to articles, and one, generate_commit_message, that shells out to a real claude -p process to turn a git diff into a commit message. Every one of those tools is reachable by any MCP client that gets wired up to this server — not just the scheduled publishing pipeline I built it for.
A trending post this week framed the obvious question bluntly: one unprotected AI endpoint can drain your budget overnight, because nothing between the caller and the expensive call is checking how often it fires. I'd read that kind of claim about other people's systems a dozen times without ever pointing it at my own. So I actually checked.
What I expected to find
I already knew my publishing pipeline has a quota. scripts/check_quota.py fetches today's published article count and refuses to let a run publish past 5:
DAILY_CAP = 5 def main(): titles = _lapt.all_published_titles(key) today_count = count_published_today(titles) print(f"{today_count} published today (UTC); {len(titles)} total historical.") if today_count >= DAILY_CAP: sys.exit(f"ERROR: daily cap of {DAILY_CAP} already reached ({today_count})") That's a real, working cap. But it only guards one path: the scheduled task calling publish_devto.py. I wanted to know whether the MCP server itself — the thing a client actually talks to — had anything equivalent anywhere in its eight tools. I grepped for it before writing a single line of test code:
$ grep -niE "throttle|rate.?limit|call.?count|invocation|cooldown|debounce|max_calls" server.py scripts/*.py publish_devto.py no matches anywhere Zero hits, across every file in the repo. Not "a weak check I could tighten" — nothing at all.
Proving it, not assuming it
A grep that finds nothing proves there's no keyword for a limit, not that none exists in some other shape (a decorator, a class attribute, whatever). So I wrote a small harness that imports server.py directly, replaces the one real external call generate_commit_message makes — subprocess.check_output(["claude", "-p", ...]) — with a counting stub, and then just calls the tool in a loop:
calls = {"n": 0} def fake_check_output(args, **kwargs): calls["n"] += 1 return b"feat: stub commit message\n".decode() subprocess.check_output = fake_check_output import server N = 500 for i in range(N): server.generate_commit_message(f"diff --git a/f{i}.py b/f{i}.py\n+line{i}\n") print(f"generate_commit_message called {calls['n']} times in a row, every single one executed.") Ran it for real against this repo's actual server.py:
generate_commit_message called 500 times in a row, every single one executed. No exception, no cooldown, no rejected call out of 500 attempts. 500 was an arbitrary stopping point, not a ceiling I hit. The function has no state that tracks how many times it's been called, so there's no number where it would start refusing. The only thing standing between a caller and 500 more calls is how long they're willing to keep calling.
I didn't do the equivalent test against the real claude -p binary, on purpose — that would mean actually spending 500 real invocations' worth of tokens just to make a point I'd already proven against the code path that matters (nothing before the subprocess call checks anything). The stub swaps out the expensive part; the control flow around it — the part that's supposed to say no — is the real, unmodified function.
Why this is a different gap than the one I already have
I'd written about this pipeline's own governance before: the duplicate-title guard on create_article/update_article is enforced in code, while the 5-article daily cap used to live only in the scheduled task's prompt text until check_quota.py made it real. That comparison was entirely about paths inside this one publishing pipeline — the thing that calls my own tools in a predictable, scripted order.
This is a narrower and, I think, more important claim: the MCP server's tool surface itself — what any client speaking MCP to this process can do — has no throttling at all, independent of whether my own pipeline happens to be well-behaved. My pipeline calling generate_commit_message once per commit is a self-imposed habit, not something the server enforces. Nothing stops a differently-configured client, a bug in a prompt, or a model that decides to retry eagerly from calling it 500 times in one session, same as my harness did. check_quota.py has no opinion about that at all — it only ever sees DEV.to's own published-article count, which generate_commit_message never touches.
The other seven tools aren't better off. list_repos and get_repo_stats hit the real GitHub API with no counter either; create_article and update_article hit DEV.to directly. The only reason this hasn't cost me anything yet is that the one client that actually talks to this server is a scheduled task I wrote, running on a fixed schedule, calling a fixed small number of tools. That's a property of my current usage, not a property of the code.
What an actual fix looks like
The honest-sized fix isn't a global rate limiter — it's one shared counter the expensive tools check before doing their real work, scoped to the server process's lifetime:
_call_counts = {} _MAX_CALLS_PER_TOOL = 50 # per server process lifetime, pick per tool if needed def _guard(name): _call_counts[name] = _call_counts.get(name, 0) + 1 if _call_counts[name] > _MAX_CALLS_PER_TOOL: raise RuntimeError(f"{name} call limit ({_MAX_CALLS_PER_TOOL}) exceeded for this server process") I haven't landed this in server.py yet — I'm flagging it here as a measured, real gap rather than claiming it's fixed, the same way I'd rather report a finding honestly than round it up. What I did verify, concretely, is that the gap exists on every single tool this server exposes, not just the one I happened to test, and that closing it is a few lines, not a redesign. The check_quota.py pattern already proves the shape works here — it just needs to move from "guards one scheduled script" to "guards the server's own tool-call boundary," which is where an untrusted or misbehaving caller would actually hit it.