OpenPostcodes

OpenPostcodes MCP server

OpenPostcodes is also available as a Model Context Protocol (MCP) server. AI assistants such as Claude, ChatGPT, Cursor and VS Code can use it to look up UK postcodes, compare them and browse areas, districts and sectors: where a postcode is, the council, ward and constituency it is in, what is nearby, and who supplies its utilities. It only reads the data (but for sending feedback, when you agree), needs no key, account or sign-in, and serves the same data, under the same licences, as the rest of this site.

Server URL
https://openpostcodes.uk/mcp
Transport
Streamable HTTP
Authentication
None
Version
1.0.0

Connect

Every client needs only the server URL. When a client asks how to authenticate, choose no authentication.

Claude (claude.ai, Desktop and mobile)

Add OpenPostcodes to Claude opens the Add custom connector dialog with the name and URL filled in; check them and click Add.

To add it by hand, go to Customize, then Connectors, and click Add custom connector. Enter the name OpenPostcodes and the URL https://openpostcodes.uk/mcp, and if the dialog asks about authentication, choose No sign-in. The connector then works in the Claude apps on desktop and mobile too. On Team and Enterprise plans an Owner adds it for everyone under Organization settings, Connectors, Add, Custom, Web (or with the prefilled admin link).

Claude Code

claude mcp add --transport http openpostcodes https://openpostcodes.uk/mcp

Add --scope project to share it through the project's .mcp.json, which looks like this:

{
  "mcpServers": {
    "openpostcodes": {
      "type": "http",
      "url": "https://openpostcodes.uk/mcp"
    }
  }
}

Prompts appear as slash commands such as /mcp__openpostcodes__postcode_report, and resources can be attached with @openpostcodes:.

ChatGPT

Turn on developer mode under Settings, Security and login, Developer mode. Then go to chatgpt.com/plugins, select the plus button, give it a name and description, enter https://openpostcodes.uk/mcp as the connection URL with no authentication, and create it. The search and fetch tools follow OpenAI's contract, so deep research can use them and cite openpostcodes.uk pages.

Cursor

Add to Cursor, or put this in ~/.cursor/mcp.json (or .cursor/mcp.json in a project):

{
  "mcpServers": {
    "openpostcodes": {
      "url": "https://openpostcodes.uk/mcp"
    }
  }
}

VS Code

Install in VS Code, or add it to .vscode/mcp.json (the top-level key is servers):

{
  "servers": {
    "openpostcodes": {
      "type": "http",
      "url": "https://openpostcodes.uk/mcp"
    }
  }
}

From a terminal:

code --add-mcp '{"name":"openpostcodes","type":"http","url":"https://openpostcodes.uk/mcp"}'

OpenAI Codex

codex mcp add openpostcodes --url https://openpostcodes.uk/mcp

or in ~/.codex/config.toml:

[mcp_servers.openpostcodes]
url = "https://openpostcodes.uk/mcp"

Codex uses tools only, not prompts or resources.

Gemini CLI

gemini mcp add --transport http openpostcodes https://openpostcodes.uk/mcp

or in ~/.gemini/settings.json, where httpUrl (not url) selects Streamable HTTP:

{
  "mcpServers": {
    "openpostcodes": {
      "httpUrl": "https://openpostcodes.uk/mcp"
    }
  }
}

Windsurf (Devin Desktop)

Add it to mcp_config.json, which is at ~/.config/devin/mcp_config.json on macOS and Linux and %APPDATA%\devin\mcp_config.json on Windows:

{
  "mcpServers": {
    "openpostcodes": {
      "serverUrl": "https://openpostcodes.uk/mcp"
    }
  }
}

Zed

Use Settings, AI, MCP Servers, Add Server, Add Remote Server, or add it to your settings file:

{
  "context_servers": {
    "openpostcodes": {
      "url": "https://openpostcodes.uk/mcp"
    }
  }
}

Zed uses tools and prompts.

Goose

Run goose configure and add a remote extension (Streamable HTTP), or add it to ~/.config/goose/config.yaml:

extensions:
  openpostcodes:
    name: OpenPostcodes
    type: streamable_http
    uri: https://openpostcodes.uk/mcp
    enabled: true
    timeout: 300

For one session only:

goose session --with-streamable-http-extension "https://openpostcodes.uk/mcp"

MCP Inspector

To explore the server by hand, start the Inspector, choose Streamable HTTP and paste the URL:

npx @modelcontextprotocol/inspector

or use its command line (add --protocol-era modern to try the 2026-07-28 protocol):

npx @modelcontextprotocol/inspector --cli --transport http --server-url https://openpostcodes.uk/mcp --method tools/list

Clients that only run local servers

A client that can only start local (stdio) servers can reach OpenPostcodes through mcp-remote:

{
  "mcpServers": {
    "openpostcodes": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://openpostcodes.uk/mcp",
        "--transport",
        "http-only"
      ]
    }
  }
}

Things to ask

Tools

10 tools, all read-only except send_feedback, which sends a note to the people who run OpenPostcodes (see feedback). Each returns structured data, repeated as JSON text, with openpostcodes.uk links to cite.

ToolWhat it does
Look up a postcode
get_postcode
Everything held for one UK postcode, in any spelling ("EX11 1RE", "ex111re"): its centroid and grid references, the geographies it is in (country, region, local authority, ward, constituency, county, parish, census, NHS and police areas), its deprivation rank and rural or urban class, today's sun times, the nearest station, hospital, GP, school, airport, bus stop, food bank, defibrillator, pharmacy, post office and library with their distances, its electricity, water and sewerage companies, broadband coverage and bordering postcodes.
Look up several postcodes
lookup_postcodes
Look up to 100 UK postcodes in one call, each with its centroid, grid reference, country, region, county, local authority, ward and constituency.
Compare two postcodes
compare_postcodes
Compare two UK postcodes: the straight-line distance in metres between their centroids, the compass bearing from the first to the second, and, geography by geography (postcode area, district and sector, country, region, county, local authority, ward and constituency), whether they share it.
Postcode area
get_postcode_area
A postcode area, the letters a postcode starts with ("EX", "SW", "B"), with its postcode districts, the number of live postcodes in each and the local authority covering most of it, and every local authority in the area, commonest first.
Postcode district
get_postcode_district
A postcode district, the first half of a postcode ("EX11", "SW1A"), with its sectors, the number of live postcodes in each and the local authority covering most of it.
Postcode sector
get_postcode_sector
A postcode sector, a district and the first digit after its space ("EX11 1"), with every live postcode in it (up to about 400) and the local authorities it spans.
Get data status
get_dataset_status
Report how current and complete the data is: the number of live postcodes, the edition of each source and how often it changes, what is not held, and the coverage caveats.
Search (connector)
search
Search OpenPostcodes by postcode, sector, district or area, in any spelling.
Fetch record (connector)
fetch
Fetch the full record for an id from search or other results: postcode:{postcode} (e.g. postcode:EX11 1RE), sector:{sector}, district:{district} or area:{area} (e.g. area:EX).
Send feedback
send_feedback
Ask the user first: show them the note as you will send it, and send it only once they agree, with user_agreed true.

Prompts

Prompts are ready-made research tasks that your client may offer as commands. Each one asks the assistant to use the tools above, cite its sources and list what it could not check.

PromptWhat it doesArguments
Report on a postcode
postcode_report
Everything about one postcode: where it is, what it is in, what kind of place it is, what is nearby and its utilities.postcode
Overview of a sector, district or area
area_overview
How many postcodes a sector, district or area holds, how they divide, and the local authorities covering it.place
Compare two postcodes
compare_two_postcodes
Two postcodes side by side: the distance between them, the geographies they share and how they differ.postcode_a
postcode_b
Nearest services to a postcode
nearest_services
The nearest station, hospital, GP, school, pharmacy and other services to a postcode, with distances.postcode
service (optional)

Resources

Resources are documents a client can attach to a conversation. Their addresses are the same https URLs a browser opens, and reading one returns what the site serves.

Reference documents

ResourceWhat it holds
OpenPostcodes data guide
https://openpostcodes.uk/mcp/guide.md
What the data holds, how postcodes and the levels above them are identified, where to start, the caveats, the licence, and feedback.
Data status
https://openpostcodes.uk/mcp/status.json
The number of live postcodes, each source's edition and cadence, and the coverage caveats, as get_dataset_status returns them.

Records by identifier

TemplateWhat it holds
Postcode
https://openpostcodes.uk/{postcode}.json
Every field for one postcode, as the site's JSON API serves it, e.g. "EX11 1RE". Any spelling works; a space in the URI is %20, as a URI template's expansion writes it.
Postcode as Markdown
https://openpostcodes.uk/{postcode}.md
The same record as Markdown, grouped under headings. Any spelling works; a space in the URI is %20, as a URI template's expansion writes it.
Postcode sector
https://openpostcodes.uk/{sector}.json
Every live postcode in a sector, e.g. "EX11 1". Any spelling works; a space in the URI is %20, as a URI template's expansion writes it.
Postcode district
https://openpostcodes.uk/{district}.json
The sectors in a district, with their counts, e.g. "EX11". Any spelling works; a space in the URI is %20, as a URI template's expansion writes it.
Postcode area
https://openpostcodes.uk/{area}.json
The districts in an area, with their counts, e.g. "EX". Any spelling works; a space in the URI is %20, as a URI template's expansion writes it.

Try it with curl

The server is stateless, so every request stands on its own. A modern (2026-07-28) request carries its protocol version and client capabilities in params._meta and repeats the version, method and tool name in headers. A legacy client starts with initialize; later requests name the agreed version in the MCP-Protocol-Version header and need no session id, because none is ever issued.

Modern (2026-07-28): ask the server what it supports

curl -s https://openpostcodes.uk/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -H 'MCP-Protocol-Version: 2026-07-28' \
  -H 'Mcp-Method: server/discover' \
  -d '{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{},"io.modelcontextprotocol/clientInfo":{"name":"curl","version":"1.0.0"}}}}'

Modern (2026-07-28): call get_postcode for EX11 1RE

curl -s https://openpostcodes.uk/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -H 'MCP-Protocol-Version: 2026-07-28' \
  -H 'Mcp-Method: tools/call' \
  -H 'Mcp-Name: get_postcode' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_postcode","arguments":{"postcode":"EX11 1RE"},"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{},"io.modelcontextprotocol/clientInfo":{"name":"curl","version":"1.0.0"}}}}'

Legacy (2025-11-25): the initialize handshake

curl -s https://openpostcodes.uk/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl","version":"1.0.0"}}}'

Legacy (2025-11-25): list the tools (no session to carry over)

curl -s https://openpostcodes.uk/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -H 'MCP-Protocol-Version: 2025-11-25' \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

Each of these answers is a single JSON response.

Limits and fair use

Data caveats

The data guide explains them in full, with how postcodes and the levels above them are identified, and status.json says how current each part is.

Feedback

send_feedback lets an assistant send the people who run OpenPostcodes a short note about these tools: something no tool could answer, an answer that was wrong or confusing, or an error that did not say what would work. Its description tells the assistant to show you the note and send it only once you agree.

What is kept: the note, its kind, the tool it names, the client's name and version, the protocol and server versions, and the time. Never your IP address: only a keyed hash of it, to limit each address to 10 notes a day. A note holding an email address, an IP address or a web address with a query string is refused. Notes are read only by the people who run OpenPostcodes, and deleted after 365 days.

Protocol

Instructions the server gives the assistant
OpenPostcodes is an open, read-only lookup of every live UK postcode, with the Channel Islands and the Isle of Man, from the ONS Postcode Directory (Open Government Licence v3.0). A postcode is identified by itself, in any spelling ("EX11 1RE", "ex111re"); above it are its sector ("EX11 1"), district ("EX11") and area ("EX").

For each it holds the centroid and grid references, the geographies it is in (local authority, ward, constituency, census and NHS areas), deprivation, the nearest station, GP, school and other services, utility companies, broadband, bordering postcodes and a boundary.

Coverage: terminated postcodes are not held. Coordinates are centroids. Deprivation ranks do not compare across countries. Nearest places, boundaries and utilities vary by country and are approximate. No addresses, and no search from a point to its postcode.

Lists are capped and paged; pass next_cursor back as cursor for more.

Start with get_postcode, lookup_postcodes for up to 100 at once, or compare_postcodes; browse with get_postcode_sector, get_postcode_district and get_postcode_area. The guide (https://openpostcodes.uk/mcp/guide.md) explains the fields and the limits.

Cite the openpostcodes.uk links in results, and give the attribution each result carries (ONS, Ordnance Survey and Royal Mail, and OpenStreetMap for nearest places).

If no tool can answer what the user asked, or an answer looks wrong, offer to tell OpenPostcodes with send_feedback, and send it only once the user agrees.

Licence and attribution

The postcodes, their coordinates and their geographies come from the ONS Postcode Directory and are reused under the Open Government Licence v3.0. When you publish something built from it, include this attribution: Contains OS data © Crown copyright and database right 2026. Contains Royal Mail data © Royal Mail copyright and database right 2026. Source: Office for National Statistics licensed under the Open Government Licence v3.0. Nearest pharmacies, post offices and libraries are © OpenStreetMap contributors (ODbL), and every other source and its licence is on the sources page. Tool results carry the attribution that applies in every answer.

OpenPostcodes is an independent project and is not affiliated with the Office for National Statistics, Ordnance Survey or Royal Mail. The ONS Postcode Directory is the authoritative source: where anything here differs from it, the ONS's own release takes precedence.

OpenCommons

OpenPostcodes is one of the OpenCommons sites. Their MCP servers keep one contract (identity, paging, results, errors and feedback), so an assistant connected to more than one finds the same conventions in each. Where a record has a counterpart on another of the sites, its result links to it under external_links.