Ordnance Survey Geographic Data
STDIOPython-based MCP server providing access to Ordnance Survey APIs with STDIO and HTTP support.
Python-based MCP server providing access to Ordnance Survey APIs with STDIO and HTTP support.
VERSION: 0.1.3
A Python-based MCP server that provides access to the Ordnance Survey APIs, supporting both STDIO and HTTP (streamable) modes.
This service creates a bridge between MCP clients and OS DataHub APIs - making it easy to query national geographic data through a standardised protocol.
It can run in two modes:
STDIO mode: Ideal for Claude Desktop and local tool integration such as Cursor
HTTP (streamable) mode:
api_service - Asynchronous HTTP client implementation for the OS APIs
mcp_service - Exposes OS APIs functionality as MCP tools
middleware - Middleware for the MCP server
stdio_middleware.py
: Handles authentication for STDIO transporthttp_middleware.py
: Handles authentication for HTTP transportprompt_templates - Prompt templates for common operations
config_docs - Documentation for OS APIs
utils - Utility functions for the MCP server
OS_API_KEY
)The easiest way to run the server with Claude Desktop is using Docker:
docker build -t os-mcp-server .
{ "mcpServers": { "os-mcp-server": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "STDIO_KEY=your-key-here", "-e", "OS_API_KEY=ADD_KEY", "os-mcp-server" ] } } }
Note: Leave
STDIO_KEY
as"STDIO_KEY=your-key-here"
for now. ReplaceADD_KEY
with your actual OS API key.
This is the default mode, ideal for integration with Claude Desktop or other MCP hosts that use STDIO.
{ "mcpServers": { "os-ngd-api": { "command": "/Users/username/.local/bin/uv", "args": ["--directory", "src/", "run", "server.py"], "env": { "OS_API_KEY": "your_api_key_here", "STDIO_KEY": "your_api_key_here" } } } }
export OS_API_KEY=your_api_key_here export STDIO_KEY=your_stdio_key_here python server.py --transport stdio # or just python server.py
This mode is ideal for web clients or when you need to stream large datasets.
You will need to set the OS_API_KEY
and BEARER_TOKEN
environment variables.
Each request to the MCP server will need to be authenticated with a bearer token - it's currently set to dev-token
in the client test script.
python server.py --transport streamable-http --host 0.0.0.0 --port 8000
python src/client_test.py
Note: The client test script (
client_test.py
) is a great way to verify your server setup and see example code for programmatic interaction with the API. It uses themcp.client.streamable_http
library to demonstrate proper connection handling and tool calling.
The client script demonstrates:
hello_world
tool)All tools are available in both STDIO and HTTP modes:
hello_world
- Test connectivitycheck_api_key
- Verify API key configurationlist_collections
- List available feature collectionsget_collection_info
- Get details about a specific collectionget_collection_queryables
- Get filterable properties for a collectionsearch_features
- Search features by various criteriaget_feature
- Retrieve a specific feature by IDget_linked_identifiers
- Find related identifiersget_bulk_features
- Retrieve multiple features in a single callget_bulk_linked_features
- Get linked features in bulkget_prompt_templates
- Get standard prompt templates for common operationssearch_by_uprn
- Search for addresses by UPRNsearch_by_post_code
- Search for addresses by POSTCODEget_map_tile
- Get a map tile in EPSG:27700 projection - THIS DOES NOT WORK - NEED TO FIXThis service provides comprehensive pre-configured prompt templates to help you get started with complex geospatial analysis workflows.
To access these templates, ask Claude: "show me available prompt templates"
usrn_breakdown
- Break down USRN into component road links for routing analysisusrn_network_connections
- Find all USRNs directly connected through the road networkusrn_named_road_analysis
- Analyze which named roads include the USRN and routing implicationsroute_between_usrns
- Build topological route between two USRNsusrn_to_address_routing
- Route from USRN to specific address using UPRN or postcodeusrn_junction_analysis
- Analyze all junctions involving USRN for routing complexityusrn_accessibility_analysis
- Analyze accessibility routing options including pedestrian accessusrn_path_integration
- Find pedestrian/cycle path integration pointscycling_routing_usrn
- Plan cycling routes involving USRNusrn_multimodal_access
- Find all transport access points (roads, paths, rail, ferry)usrn_rail_connections
- Find railway connections near USRNusrn_tram_analysis
- Analyze tram connections and presencebuild_usrn_network_graph
- Build complete routing network graph centered on USRNusrn_road_link_analysis
- Detailed analysis of individual Road Links within USRNemergency_services_routing
- Plan emergency services routing with multiple access pointsfreight_routing_usrn
- Plan freight/HGV routingusrn_traffic_optimization
- Plan traffic-optimized routesusrn_spatial_analysis
- Comprehensive spatial analysis within specified radiususrn_compound_structure_analysis
- Find compound structures affecting USRN routingroute_compound_structures_analysis
- Find all compound structures along route between USRNsroute_bridge_tunnel_analysis
- Analyze bridges and tunnels along routeroute_infrastructure_obstacles
- Identify infrastructure obstacles and restrictions along routeroute_multimodal_crossings
- Find multimodal transport crossings along routefreight_route_structure_clearances
- Analyze structure clearances for freight routinguprn_to_road_infrastructure
- Connect property addresses to road infrastructureAsk Claude to use specific templates:
Each template provides step-by-step instructions using the OS NGD API collections and your available MCP tools.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.
This project does not have the endorsement of Ordnance Survey.