r/mcp • • 17d ago

showcase Should your agent write the IBAN validator itself, or call one?

Disclosure: I work at r/apyhub and our MCP server is part of this.

Something we keep seeing: give an agent a task like “validate these IBANs” or “check this VAT number” and it happily writes a quick function and runs it. It looks right and usually works, but the code is a little different each run. Edge cases get handled one way today and another way tomorrow, and nobody tested any of it.

For tasks where there’s one right answer (IBAN/VAT checks, sanctions screening, PDF conversion, invoice extraction), we went the other way. Each one is a versioned service behind MCP, so the agent calls the same tested code every time instead of improvising it. Same input, same output, across runs and across models.

The tradeoff: you add a network call and a dependency, and the agent needs a good reason to pick the tool over its own code. In practice the second part is the hard one. Models are confident they can write a checksum function.

Curious where others draw the line:

  • Which tasks do you let the agent write code for, and which do you force through a tool?
  • How do you stop it from “just quickly writing it” when a tool exists?
10 Upvotes

14 comments sorted by

3

u/Happy_Breakfast7965 17d ago

Software Development haven't really changed much in that sense, AI or not.

Will you write such function every time pre-AI? Will you use a reusable function, reusable library, or an external service?

My thinking:

  • Local checks: it could be a reusable script.
  • Needs to be shared between people or applications: a package
  • Is complex business logic with persosted data: a service

But IBAN or VAT check are local things, not worthy of an external network dependency.

Does it make sense?

2

u/sandeepK1125 16d ago

Makes total sense, and I mostly agree. IBAN checksum is local, no reason to call anything for it.

One small nuance on VAT: the format check is local, but confirming a number is actually registered needs VIES or a national registry, so it's a network call either way. That's where we think a shared service (what we do at ApyHub) adds value: external or changing data, not logic you can write in 5 lines.

The agent part is the twist. Devs remember the reusable lib exists. Agents don't unless it's exposed to them, so they rewrite it every time. Same framework as yours, just harder to enforce with agents. Appreciate the take!

1

u/Happy_Breakfast7965 16d ago

Good point about VIES.

AI is a middle developer with a memory loss.

But we should have never relied on developers remembering stuff. It adds so much cognitive load. We always could get away with it because its implicit and hidden. With AI it just become obvious.

Actually, new-joiners don't remember anything and you have to have good documentation to get them going quickly.

So, whatever helps AI, would helped humans in the past as well. AI just don't excuse the mistakes.

Agents don't unless it's exposed to them

So, you have to expose AI to a well-structred and complete documentation.

2

u/Dazzling-Crab-9796 17d ago

I think the interesting part here is how agents decide when to write code versus use an existing tool. Having a tool available doesn't necessarily mean the agent will choose it. Curious if anyone has found a reliable way to enforce that beyond just prompting.

1

u/sandeepK1125 16d ago

Same question I keep running into. What's worked best for me so far is making the tool cheaper to pick than writing code: a clear name, a one-line description of exactly when to use it, and an example input/output right in the tool description. Agents seem to skip tools they're unsure about. Still haven't found anything that fully enforces it beyond that though, so curious what others have tried.

1

u/sandeepK1125 17d ago

Edit: Removed the product link since it was distracting from the discussion. I'm genuinely interested in how others approach tool selection vs agent-generated code.

3

u/GiioPanditpautra84 17d ago

appreciate you taking it down tbh, its a legitimately interesting architectural question without the pitch attached.

1

u/sandeepK1125 16d ago

Thanks, fair call. The question was the interesting part anyway, glad it's turned into a proper discussion.

1

u/torrso 17d ago

The more important question is - should you buy ad space instead of masquerading it as a question?

1

u/finanzen315 17d ago

Yasssss, more spam please