@hpsilab4
Haiyun HuFounder▲16
Builder & AI engineer, hpsilab
Oct 20 · Agents · Tokyo

Tell your agent which MCP tools cost money before it calls them twice

When we published HPSILab's MCP server, writing the tools was the easy part. The part that mattered more was telling an agent what each call does to the world.

Seven of our ten tools only read market data, so calling them twice is harmless. Two create hosted charts and reports; they can use up a quota or settle a payment, and a retry creates (and may charge for) a second one. One registers an account and sends an email. Agents retry a lot: timeouts, a second opinion, a re-plan.

What we ended up doing:

  • Every tool carries all four MCP annotations, never left unset: readOnlyHint and idempotentHint are true for the seven read tools and false for the three that change something.
  • The server instructions repeat this in one sentence, because not every client reads annotations.
  • A test fails if any tool's annotations drift from that split.
  • One tool, analyze_stock, is named as the starting point, so a model doesn't fan out across every tool for a simple question.

Annotations are hints, not enforcement; the payment checks still happen on the server. But they give a careful client a reason to ask before a second paid call.

How do you mark side effects on your tools?

hpsilab.com/?utm_source=lounge&utm_medium=community&utm_campaign=post-mcp-annotations

AgentsMCPAI Engineering

Comments2

  • @ryanallis
    Ryan Allis
    Founder of AI Lounge and SaasRise, helping founders reach $100M+ exits
    Oct 20

    Getting billed twice for one report because an agent retried is exactly how a happy customer becomes a refund request.

  • @hpsilab
    Haiyun Hu
    Building AI-native financial intelligence and risk analysis tools for developers and autonomous trading agents.
    Oct 20

    Exactly. On our side each paid call settles exactly one way: if the payment result is unclear, the server stops and charges nothing rather than risk charging twice. But a second call is a second charge, and only the client knows it's a retry, which is why the hint has to reach the agent before it calls. hpsilab.com/?utm_source=lounge&utm_medium=community&utm_campaign=reply-ryan-mcp — Haiyun

Log in to join the thread.