Skip to main content
Glama
GovUK MCP Server

GovUK MCP Server

Gov.uk MCP Server

A comprehensive Model Context Protocol (MCP) server providing access to 27 UK government data sources and services. Built for Claude Desktop and other MCP-compatible clients.

Note: This is a hobby project, expect issues and use for demonstration purposes only.

๐ŸŒŸ Features

  • 33 Government APIs: Companies House, Parliament, NHS, Transport, and more

  • 15 Visual Widgets: Rich UI components via MCP Apps for data visualization

  • Production-Ready: Comprehensive input validation, error sanitization, rate limiting

  • Type-Safe: Full input validation with regex patterns

  • Secure: Sanitized errors, XSS protection, origin validation

  • Fast: Concurrent execution for bulk operations (voting records)

๐Ÿ’ฌ Example Prompts

Try asking:

  • "What are the five nearest postcodes to SW1A 1AA?"

  • "When is the next Bank Holiday?"

  • "How can I get from Brixton to St Pancras?"

  • "What's the status of the Circle Line?"

  • "Where's my nearest Hospital?"

  • "Who's my MP?"

  • "What's their voting record?"

Related MCP server: mcp-uk-ons

๐Ÿ“ฆ Installation

# Clone the repository
git clone https://github.com/brummiesteven/GovUK-MCP.git
cd GovUK-MCP

# Install dependencies
pip install -e .

# Or with dev dependencies
pip install -e ".[dev]"

๐Ÿ”‘ API Keys Setup

Create a .env file in the project root:

# Required for Companies House tools
COMPANIES_HOUSE_API_KEY=your_companies_house_key

# Required for EPC tools
EPC_API_KEY=your_email:your_epc_key

# Optional (works without but has lower rate limits)
TFL_API_KEY=your_tfl_key

API Key Requirements

Required APIs (2):

Optional APIs (1):

No Key Required (24 tools): Postcode, Food Hygiene, Bank Holidays, Gov.uk Search, Flood Warnings, Police Crime, Courts, Charity, NHS, Legislation, CQC, Parliamentary tools

๐Ÿš€ Usage

With Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "gov-uk": {
      "command": "python",
      "args": ["-m", "gov_uk_mcp.server"],
      "env": {
        "COMPANIES_HOUSE_API_KEY": "your_key_here",
        "EPC_API_KEY": "your_email:your_key_here"
      }
    }
  }
}

Standalone (For Development)

python -m gov_uk_mcp.server

๐Ÿ› ๏ธ Available Tools (33)

Transport (6)

  • get_tube_status - All Tube lines status

  • get_line_status - Specific line status

  • plan_journey - Journey planner with step-by-step directions

  • get_bike_points - Santander Cycles availability

  • get_road_status - Major road conditions

  • search_stops - Find bus stops, stations, etc.

Business & Finance (6)

  • search_companies, get_company, get_company_officers, get_company_filing_history

  • search_charities, get_charity

Location & Geographic (5)

  • lookup_postcode, nearest_postcodes

  • search_food_establishments, get_flood_warnings, get_crime_by_postcode

Healthcare (5)

  • find_gp_surgeries, find_hospitals, find_pharmacies

  • search_cqc_providers, get_cqc_provider

Parliamentary (5)

  • find_mp, search_hansard, get_voting_record

  • search_divisions, search_questions, get_questions_by_mp

Other Services (4)

  • search_epc_by_postcode, find_courts, search_govuk, get_bank_holidays, search_legislation

๐ŸŽจ MCP Apps Widgets

This server includes 15 visual widgets compatible with MCP Apps-enabled clients. Widgets provide rich, interactive visualizations of API responses.

Widget

Description

tube-status

London Underground status with line colors

postcode-lookup

Location information grid

company-info

Companies House profile card

food-hygiene

FSA ratings with score indicators

flood-warnings

Environment Agency alerts

mp-info

MP profile with photo and party colors

bank-holidays

Upcoming holidays calendar

crime-stats

Crime breakdown by category

cqc-rating

Care quality ratings display

charity-info

Charity Commission details

voting-record

Parliamentary voting history

bike-points

Santander Cycles availability

journey-planner

TfL journey with step-by-step

road-status

Major road conditions

nhs-services

GP, hospital, pharmacy finder

Widgets are automatically served when tools are called from compatible clients.

๐Ÿงช Testing

# Run all tests
pytest

# With coverage
pytest --cov=gov_uk_mcp --cov-report=html

# Specific test
pytest tests/test_validation.py -v

๐Ÿ“ License

MIT - see LICENSE

๐Ÿ™ Credits

  • MCP by Anthropic

  • UK Government Open Data APIs

  • Python ecosystem


Built for the UK developer community ๐Ÿ‡ฌ๐Ÿ‡ง

Available Tools

33 tools
find_courtsA

Find courts by postcode or name.

Args: postcode: UK postcode name: Court name to search for

Returns court details, types, and contact information.

Inputs: postcode, name. Returns: object

find_gp_surgeriesB

Find GP surgeries near a postcode.

Args: postcode: UK postcode

Inputs: postcode (required). Returns: object

find_hospitalsB

Find hospitals near a postcode.

Args: postcode: UK postcode

Inputs: postcode (required). Returns: object

find_mpA

Find MP by name, constituency, or postcode.

Args: query: MP name, constituency name, or UK postcode

Returns MP details including party and constituency.

Inputs: query (required). Returns: object

find_pharmaciesB

Find pharmacies near a postcode.

Args: postcode: UK postcode

Inputs: postcode (required). Returns: object

get_bank_holidaysB

Get UK bank holidays.

Args: country: Country to get holidays for (england-and-wales, scotland, northern-ireland)

Inputs: country. Returns: object

get_bike_pointsA

Get Santander Cycles docking stations in London.

Args: lat: Latitude for location search (optional) lon: Longitude for location search (required if lat provided) radius: Search radius in meters (default: 500)

Inputs: lat, lon, radius. Returns: object

get_charityB

Get detailed charity information by registration number.

Args: charity_number: Charity registration number

Inputs: charity_number (required). Returns: object

get_companyB

Get detailed company information by company number from Companies House.

Args: company_number: Company number (e.g., 12345678)

Inputs: company_number (required). Returns: object

get_company_filing_historyB

Get company filing history by company number from Companies House.

Args: company_number: Company number (e.g., 12345678) items_per_page: Number of results to return (default: 20)

Inputs: company_number (required), items_per_page. Returns: object

get_company_officersB

Get list of company officers (directors, secretaries) by company number.

Args: company_number: Company number (e.g., 12345678)

Inputs: company_number (required). Returns: object

get_cqc_providerB

Get detailed CQC ratings and information for a care provider.

Args: location_id: CQC location ID

Inputs: location_id (required). Returns: object

get_crime_by_postcodeA

Get street-level crime data for a postcode area.

Args: postcode: UK postcode

Inputs: postcode (required). Returns: object

get_flood_warningsA

Get active flood warnings for England. Can filter by postcode or area.

Args: postcode: Postcode to search for (optional) area: Area name to search for (optional)

Inputs: postcode, area. Returns: object

get_line_statusB

Get status for a specific London Underground line.

Args: line_id: Line ID (e.g., 'central', 'northern', 'piccadilly')

Inputs: line_id (required). Returns: object

get_questions_by_mpC

Get all parliamentary questions asked by a specific MP.

Args: mp_name: MP name limit: Number of results (default: 20)

Inputs: mp_name (required), limit. Returns: object

get_road_statusA

Get current status of major roads in London.

Args: road_ids: Comma-separated road IDs (e.g., 'A2,A40,M25')

Inputs: road_ids (required). Returns: object

get_tube_statusA

Get current status of all London Underground lines.

Returns status, delays, and disruption info for all tube lines.

Inputs: no named parameters. Returns: object

get_voting_recordA

Get voting record for an MP.

Args: mp_name_or_id: MP name or member ID division_id: Specific division ID (optional) limit: Number of recent votes to return (default: 20)

Shows how they voted on specific bills or recent voting history.

Inputs: mp_name_or_id (required), division_id, limit. Returns: object

lookup_postcodeA

Look up details for a UK postcode.

Args: postcode: UK postcode (e.g., SW1A 1AA)

Returns location, council, constituency, and coordinates.

Inputs: postcode (required). Returns: object

nearest_postcodesB

Find nearest postcodes to a given postcode.

Args: postcode: UK postcode (e.g., SW1A 1AA) limit: Number of nearest postcodes to return (default: 10)

Inputs: postcode (required), limit. Returns: object

plan_journeyA

Plan a journey between two locations in London using public transport.

Args: from_location: Starting point (postcode, station name, or address) to_location: Destination (postcode, station name, or address) via: Optional intermediate stop time: Optional time for journey (ISO format or HH:MM) time_is_arrival: If True, time is arrival time; if False, departure time

Inputs: from_location (required), to_location (required), via, time, +1 more. Returns: object

search_charitiesB

Search for registered charities by name.

Args: name: Charity name to search for

Inputs: name (required). Returns: object

search_companiesA

Search for UK companies by name using Companies House API.

Args: query: Company name to search for items_per_page: Number of results to return (default: 20)

Inputs: query (required), items_per_page. Returns: object

search_cqc_providersC

Search for CQC registered care providers by name or postcode.

Args: name: Provider name postcode: UK postcode

Inputs: name, postcode. Returns: object

search_divisionsB

Search parliamentary divisions (votes) by keyword.

Args: query: Search term limit: Number of results (default: 20)

Inputs: query (required), limit. Returns: object

search_epc_by_postcodeB

Search for Energy Performance Certificates by postcode.

Args: postcode: UK postcode

Returns energy ratings (A-G) and property details.

Inputs: postcode (required). Returns: object

search_food_establishmentsB

Search for food establishments and their hygiene ratings.

Args: name: Business name to search for postcode: Postcode to search in local_authority: Local authority ID

Inputs: name, postcode, local_authority. Returns: object

search_govukC

Search gov.uk content for guidance, policy documents, and other government information.

Args: query: Search query count: Number of results to return (default: 10)

Inputs: query (required), count. Returns: object

search_hansardA

Search parliamentary debates in Hansard (2015-present).

Args: query: Search term date_from: Start date (YYYY-MM-DD format, optional) date_to: End date (YYYY-MM-DD format, optional) speaker: Filter by speaker name (optional)

Returns debate transcripts and speeches.

Inputs: query (required), date_from, date_to, speaker. Returns: object

search_legislationA

Search UK legislation by keyword.

Args: query: Search query limit: Number of results (default: 20)

Inputs: query (required), limit. Returns: object

search_questionsB

Search parliamentary written questions and answers.

Args: query: Search term mp_name: Filter by MP name (optional) department: Filter by government department (optional) limit: Number of results (default: 20)

Inputs: query (required), mp_name, department, limit. Returns: object

search_stopsA

Search for bus stops, tube stations, and other transit stops in London.

Args: query: Search term (station name, postcode, etc.) modes: Optional comma-separated transport modes (tube,bus,dlr,overground,elizabeth-line,tram)

Inputs: query (required), modes. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    B3.4/5.0

    Scored across 33 tools

    Disambiguation4/5

    Most tools have distinct purposes (e.g., find_gp_surgeries vs find_hospitals vs find_pharmacies are all healthcare but different venues). However, some pairs like get_company vs search_companies or get_line_status vs get_tube_status could cause minor confusion, but descriptions clarify the differences.

    Naming Consistency4/5

    Naming follows a consistent verb_noun pattern with underscores (find_, get_, search_, lookup_, nearest_, plan_). Verbs vary by action type but are used predictably: 'find' for location-based lookups, 'get' for specific entities, 'search' for queries. No mixing of camelCase or other styles.

    Tool Count3/5

    With 33 tools, the server covers a wide breadth of UK government services (postcodes, health, transport, parliament, etc.). While it's above the typical 15-tool threshold, the scope justifies many tools, but some could potentially be merged (e.g., get_line_status into get_tube_status).

    Completeness4/5

    The tool set covers many important government areas: location/postcodes, healthcare facilities, company/charity info, parliamentary data, transport, crime, flooding, and more. Minor gaps exist (e.g., no tools for benefits, taxes, or residency), but the coverage for the intended domain is solid.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables access to official UK Office for National Statistics data including demographics, economics, and social statistics through the ONS Beta API. Supports browsing, searching, and querying datasets with built-in shortcuts for popular statistics like inflation, regional GDP, and wellbeing data.
      5
      19 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables querying UK Office for National Statistics datasets and their editions through natural language, with no authentication required.
      72 npm
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to query NHS public health datasets, including prescribing data, dataset exploration, and organisation lookup via the NHSBSA Open Data Portal.
      9
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables natural language queries about UK postcodes and vehicles, including flood risk, crime rate, broadband coverage, property prices, MOT history, and ULEZ compliance.
      4
      38 npm
      MIT