Give your AI agent a radius search tool with MCP
Your AI agent can draft the campaign, write the email, and update the CRM. Ask it which ZIP codes are within 30 miles of the warehouse and it guesses. Here's how to fix that in one minute.
The problem: radius questions are data questions
Language models are trained on text, not on a live index of 1.8 million postal codes with coordinates. When an agent answers "which towns are within 50 km of Lyon?" from memory, it produces a believable list with no guarantee of completeness and no real distances. For a chat answer, that's a curiosity. For an agent that's about to spend an ad budget or assign a sales territory, it's a bug.
The fix: a tool call
The Model Context Protocol (MCP) lets an agent call external tools. RingFence runs a remote MCP server with two of them:
radius_search: give it a location or coordinates, a radius, and a unit. It returns the resolved center, counts, a unique postal code list nearest first, and rows with town, region, county, country, and distance.resolve_location: give it "Portland" and it returns the candidates, so the agent can ask which one you mean.
Connect it
Sign in to RingFence, create your API key on the Account page, and add the server. In Claude Code:
claude mcp add --transport http ringfence https://ringfencegeo.com/mcp \
--header "Authorization: Bearer rf_live_YOUR_KEY"
For other MCP clients, use the endpoint https://ringfencegeo.com/mcp with the same Authorization header.
What changes
Ask "build me the ZIP list for a 25-mile campaign around 02139" and instead of a sample, the agent returns all 264 ZIP codes, nearest first, ready to paste. Ask "which towns are within 40 km of Utrecht?" and it gets every town, with distances, from real data. When the place is ambiguous, the tool says so, and the agent asks instead of guessing.
Tips for agent builders
- Use
fields: "postal_codes_only"when the agent just needs the code list. Large radii can return thousands of rows; the compact form keeps the context window small. - Pass
countrywhen you know it. Postal code 02139 exists in six countries. - Keep the key private. Your account has one active API key. If it's ever exposed, rotate it on the Account page and the old key stops working immediately.
Radius search is one of those tasks where the right answer is a database lookup. Let your agent do the reasoning, and let RingFence be the database.
Frequently asked questions
What is RingFence's MCP endpoint?
https://ringfencegeo.com/mcp, authenticated with a RingFence API key sent as Authorization: Bearer rf_live_...
Which AI clients work with RingFence?
Any client that supports remote MCP servers over HTTP with a Bearer header, including Claude Code and other MCP-compatible agents. Agents that call REST APIs can use the /api/v1/search endpoint instead.
What tools does the RingFence MCP server provide?
radius_search, which returns every postal code and town within a radius, and resolve_location, which turns a postal code or town name into candidate coordinates.