DEV Community

Cover image for Tariffiq: Teaching an AI Agent to Calculate Your Import Tariffs (via WebMCP)
Timothy Chimbiv
Timothy Chimbiv

Posted on

Tariffiq: Teaching an AI Agent to Calculate Your Import Tariffs (via WebMCP)

Small business owners importing goods often don't find out the real cost of a shipment tariffs, duties, and the hit to their margins until after they've already placed the order. I built Tariffiq to answer that instantly, and for the OpenAI WebMCP Challenge, I gave it something extra: the ability for an AI agent to run that same analysis directly, without touching my UI at all.

What Tariffiq does

Enter a product, its origin country, quantity, and unit price, and Tariffiq calculates:

  • The full landed cost after import tariffs
  • The impact on your profit margins
  • Cheaper sourcing alternatives from other countries, with potential savings

Why WebMCP

WebMCP lets a web app expose real, callable tools to an agent not just a page it has to guess its way through. That's exactly the kind of task tariff analysis is: check a cost, compare a few countries, decide on a supplier. An agent should be able to do that on someone's behalf.

How it works

I used document.modelContext.registerTool to expose two tools:

  • analyze_tariff — runs a full analysis for a product, origin country, quantity, and unit price
  • switch_origin_country — re-runs the last analysis with a different origin country, so an agent can compare sourcing options without re-entering everything else

Both call the app's existing analysis logic directly, so when an agent invokes a tool, the result renders live on the same page a human would be looking at.

The debugging journey

The trickiest part wasn't writing the tools it was proving they worked. ChatGPT wasn't reliably discovering my registered tools, which initially had me worried the implementation itself was broken. Re-reading the rules closely, I realized judges could test via either ChatGPT's in-app browser or Chrome with WebMCP enabled so I shifted to verifying everything through Chrome's own WebMCP DevTools panel instead, invoking analyze_tariff directly and watching the live production site update in real time.

Along the way I also hit a React StrictMode quirk that was silently double-registering each tool in development fixed with a simple guard.

Try it

Built for the OpenAI WebMCP Challenge feedback welcome!

Top comments (0)