Purpose
The ng-postcode MCP server provides AI assistants with access to the Nigerian National Digital Alphanumeric Postcode System (NDAPS). NDAPS is the building-level postcode system introduced by NIPOST. The server enables AI assistants to validate postcodes offline, look up postcode details, autocomplete postcodes, find postcodes by location, and resolve descriptive addresses to postcodes.
Key capabilities
- Offline validation: Validate postcode formats without an API key.
- Look up details: Look up detailed information for a postcode via the postcode.gov.ng API (this tool consumes credits).
- Autocomplete: Complete postcodes from an input fragment.
- Find by location: Find the corresponding postcode based on a geographic location.
- Address resolution: Resolve a descriptive address to a postcode; the assistant reads the address and passes landmarks and map search results to the tool, and the server itself makes no model calls.
Except for lookup_postcode_details , all tools are read-only. Errors are returned as model-actionable messages, such as a missing key or an exhausted credit balance.
Usage
The server runs over stdio and requires installing uv. API keys are available from the NIPOST developer dashboard. Most clients just add the corresponding entry in their MCP settings.
bundle/ directory contains an MCPB manifest for clients that support .mcpb files (such as Claude Desktop), using uv to run the published package and requesting an API key in the client settings. Build command:npx @anthropic-ai/mcpb pack mcp/bundle ng-postcode.mcpb(run from the repository root).bundle-python/ is the same bundle for hosts that only run Python packages (such as Smithery), using uvx to start the server, so it requires installing uv。scripts/smithery_bundle.py to build the copy accepted by Smithery, which also includes the input schema for each tool.
The Node version (with the same tools except resolve_address ) is published as the npm package ng-postcode-mcpand can be run via npx .
To validate postcodes in your own code, use the libraries: ng-postcodefor Python, ng-postcode-jsfor JavaScript, ng-postcodefor Rust, and ng-postcode-apifor Java.
HTTP and Docker
Over HTTP, callers can send their own NIPOST key in the X-NIPOST-API-Key request header, and that key is used only for that caller's requests. Callers that do not send a key use the server's key (if NG_POSTCODE_API_KEYis set).
To host the server for others, do not set NG_POSTCODE_API_KEY, so that each caller brings its own key, and the service is provided over HTTPS to encrypt request headers. Callers trust the host to keep their keys, and all callers share the host's geocoder, which responds to one search per second. Validation works without any key. If a server key is indeed set, anyone who can access the server will consume its credits, so keep it on a loopback address or behind your own authentication. Unless NG_POSTCODE_ALLOW_SHARED_KEY=1 and in NG_POSTCODE_ALLOWED_HOSTS specify the hosts it answers to, otherwise the server refuses to start with a key on a public address.NG_POSTCODE_MAX_LEVEL set caps per caller,NG_POSTCODE_MAX_PAID_CALLS limiting spending of the server's own key.
Keys are read from environment variables or the X-NIPOST-API-Key request header, never from tool parameters, and never appear in results or logs.
lookup_postcode is always level 1 and free. Paid tools lookup_postcode_details unless raising NG_POSTCODE_MAX_LEVEL, otherwise they are invisible to the model. Paid tools are not marked as read-only or safe to retry, so clients that auto-approve read-only tools will still ask before spending.
Incorrectly entered codes are not silently corrected and sent to the API. The server returns suggestions and asks the model to confirm with the user.
Level 2 and above return house addresses. Under the Nigeria Data Protection Act, they should be treated as personal data.
resolve_address sends the search string to your configured geocoder. When using a third-party geocoder, address text is shared with it.
When to use
- An AI assistant needs to validate or look up Nigerian postal codes.
- An application needs to resolve descriptive addresses into postal codes.
- A client needs to validate postal codes offline.
- A scenario needs to host a postal code service for multiple users.
Limitations
resolve_addressis a pre-release feature and works against the live API, but its accuracy on real addresses has not been measured.- Text alone can rarely identify a building; when the exact building matters, users should be asked to provide a location pin.
- Public Nominatim (https://nominatim.openstreetmap.org)仅允许轻度个人使用;主要工作为地理编码的服务必须运行自己的实例。地图数据 © OpenStreetMap contributors.
- House addresses returned at level 2 and above are personal data and are subject to the Nigeria Data Protection Act.
- Paid tools consume credits; pay attention to key management and spending limits.