Guide

How to Enrich IPs from a Log with an AI Agent

Hand Claude Code, Cursor or VS Code an access log and get back countries, ISPs and network types, through the IPWho MCP server.

An AI agent with the IPWho MCP server connected can turn a pasted access log into a table of countries, ISPs and network types in one conversation. You describe the job; the agent extracts the IPs, makes the lookups and formats the answer. Nothing to write, and the lookups cost the same as calling the API yourself.

MCP

No code needed. The steps use Claude Code; the same server works in Cursor, VS Code and Claude Desktop, with configs on the MCP server page. Every Output block is a real lookup made through the published package on 25 Nov 2026; your agent's wording will differ. Prefer code? See the bulk lookup guide or the SDKs in 10+ languages.

1Connect the IPWho MCP server to your agent.

Get a free API key here (2,000 lookups a day, no card), then register the server once. The local package runs on your machine and keeps the key in an environment variable:

Terminal
claude mcp add ipwho --env IPWHO_API_KEY=sk.xxx -- npx -y @ipwho/mcp-server

Nothing to install? Use the hosted endpoint instead. The key travels in a header, never in the URL:

Terminal
claude mcp add --transport http ipwho https://mcp.ipwho.org/mcp --header "X-API-Key: sk.xxx"

Start a new session and check the agent can see the tools:

Prompt
Which IPWho tools do you have, and what does each one do?
Output
lookup_ip    one IPv4 or IPv6 address, optional field filter (get)
lookup_bulk  1–100 addresses in one call, results in data.responseArray
lookup_me    the public IP of this machine (local package only)

lookup_me only appears with the local package. On the hosted server it would report the server's own address, so it isn't offered there.

2Ask about one IP.

Plain language is enough. The agent picks lookup_ip and gets the API's JSON back unchanged, plus a one-line attribution:

Prompt
Where is 8.8.8.8, and which network is it on?
Output
{
  "success": true,
  "data": {
    "ip": "8.8.8.8",
    "geoLocation": {
      "continent": "North America",
      "country": "United States",
      "countryCode": "US",
      "region": null,
      "city": null,
      "postal_Code": null,
      "latitude": 37.751,
      "longitude": -97.822,
      "accuracy_radius": 1000
    },
    "timezone": { "time_zone": "America/Chicago", "utc": "-06:00" },
    "currency": { "code": "USD", "symbol": "$" },
    "connection": {
      "asn_number": 15169,
      "asn_org": "Google LLC",
      "isp": "Google",
      "connection_type": "Corporate"
    },
    "security": { "isVpn": false, "isTor": false, "isThreat": "low" }
  }
}
Data source: IPWho (https://www.ipwho.org)

Read the nulls as "unknown", not as a mistake. Google's resolver is announced from many places, so IPWho gives a country and a 1,000 km accuracy radius but no region or city. connection_type is Cable/DSL, Cellular, Corporate or Satellite, or null; Corporate here means Google's own network, and the same value covers offices, universities and VPNs elsewhere.

3Hand the agent a log and ask for a table.

Paste the log lines straight into the prompt, or point the agent at the file. Say what to skip, that you want one bulk call, and which columns you need. The duplicates and the documentation-range address are deliberate:

Prompt
Here are the last few lines of my nginx access log. Pull out the unique
public IP addresses (skip private and documentation ranges), look them up
with IPWho in one bulk call, and give me a table with ip, requests, country,
city, ISP and connection type. Then group the requests by country.

203.0.113.7 - - [24/Nov/2026:09:12:01 +0000] "GET /pricing HTTP/1.1" 200
8.8.8.8 - - [24/Nov/2026:09:12:04 +0000] "GET /docs HTTP/1.1" 200
1.1.1.1 - - [24/Nov/2026:09:12:09 +0000] "GET /openapi.yaml HTTP/1.1" 200
2606:4700:4700::1111 - - [24/Nov/2026:09:12:15 +0000] "GET / HTTP/1.1" 200
27.34.67.15 - - [24/Nov/2026:09:12:20 +0000] "POST /api/auth/signup HTTP/1.1" 201
76.102.11.203 - - [24/Nov/2026:09:12:31 +0000] "GET /pricing HTTP/1.1" 200
1.1.1.1 - - [24/Nov/2026:09:12:44 +0000] "GET /llms.txt HTTP/1.1" 200
8.8.8.8 - - [24/Nov/2026:09:12:52 +0000] "GET /docs/api/mcp-server HTTP/1.1" 200

The agent deduplicates, drops 203.0.113.7, calls lookup_bulk once with the five remaining addresses and lays out the result. The values below are the real lookups; a reply reads like this:

Output
Skipped 203.0.113.7 (documentation range, not routable). 5 unique public
IPs, looked up in one lookup_bulk call:

ip                    req  country        city       ISP                       type
8.8.8.8               2    United States  —          Google                    Corporate
1.1.1.1               2    unknown        —          Cloudflare                Corporate
2606:4700:4700::1111  1    unknown        —          Cloudflare                Corporate
27.34.67.15           1    Nepal          Kathmandu  WorldLink Communications  Cable/DSL
76.102.11.203         1    United States  Los Altos  Comcast Cable             Cable/DSL

Requests by country: United States 3 · Nepal 1 · unknown 3

Notes: 1.1.1.1 and 2606:4700:4700::1111 are Cloudflare anycast resolvers,
so IPWho returns no country for them. "Corporate" covers company networks,
cloud providers and VPNs; it is not a datacenter flag on its own.
Data source: IPWho (https://www.ipwho.org)

Two things to notice. Both Cloudflare resolver addresses come back with no country at all: anycast ranges have no single location, and the API says so rather than guessing. And lookup_bulk takes at most 100 addresses per call, so for a long log the agent batches and the lookups count once per unique IP, not once per line. For thousands of IPs on a schedule, the bulk lookup guide is the better tool.

4Set standing rules and export the result.

Put the rules you'd otherwise repeat into your agent's project instructions (CLAUDE.md in Claude Code, a rules file in Cursor, .github/copilot-instructions.md in VS Code). These keep the quota down and the answers honest:

Rules
When I ask you to enrich IP addresses with IPWho:
- Deduplicate first and skip private, loopback and documentation ranges.
- Use lookup_bulk in batches of at most 100; use lookup_ip only for one-offs.
- Show null fields as "unknown". Country is the reliable level; region and
  city are approximate and often missing.
- connection_type "Corporate" also covers offices, universities and VPNs.
  Never present it as datacenter detection or as a reason to block.
- security.isVpn, isTor and isThreat are basic signals, not a risk score.
- Keep the API's field names (postal_Code, asn_number) and name IPWho as
  the data source.

Then ask for the file you actually need. The agent writes it from the lookups it already made, so this costs nothing extra:

Prompt
Save that table as enriched-ips.csv with the same columns, and tell me
how many lookups you used.
Output
ip,requests,country,countryCode,region,city,isp,asn_number,connection_type
8.8.8.8,2,United States,US,,,Google,15169,Corporate
1.1.1.1,2,,,,,Cloudflare,13335,Corporate
2606:4700:4700::1111,1,,,,,Cloudflare,13335,Corporate
27.34.67.15,1,Nepal,NP,Bagmati Province,Kathmandu,WorldLink Communications,17501,Cable/DSL
76.102.11.203,1,United States,US,California,Los Altos,Comcast Cable,7922,Cable/DSL

Written to enriched-ips.csv. Lookups used: 5 (one bulk call).

Empty cells are nulls carried through as-is, which is what you want in a file that other tools will read. The security fields (isVpn, isTor, isThreat) are available too; they are basic signals, useful as context in a review and not a fraud score, so keep them out of any automatic decision.

Start with a free API key

Free tier: 2,000 lookups/day, no card. Paid plans from $2.50/month. Per-client setup, hosted endpoint and limits here.