PA

Parliament MCP Server — Query UK Parliamentary Data

Query UK parliamentary data with the MCP server to access votes, debates, members, constituencies and bills via a fast, structured API.

Quick Install
npx -y @i-dot-ai/parliament-mcp

Overview

The Parliament MCP Server implements the Model Context Protocol (MCP) to provide fast, structured access to UK parliamentary data. It centralises commonly‑requested information — votes, debates (Hansard snippets), MP records, constituencies and bills — and exposes that information over a lightweight HTTP API so tools and LLMs can fetch authoritative context on demand.

This server is useful for developers building legislative research tools, parliamentary chatbots, summarisation pipelines, or any integration that needs programmatic access to parliamentary facts. Because it follows MCP principles, it is designed to be used as a context provider for AI models (returning compact, machine‑friendly documents) while also serving conventional REST queries for integration with other services.

Features

  • Exposes structured endpoints for votes, debates, members (MPs), constituencies and bills
  • Fast, cacheable responses suitable for LLM context injection
  • Local or containerised deployment with configurable data sources
  • OpenAPI/Swagger documentation (typical FastAPI / ASGI stack)
  • Simple query parameters for searching by id, date range, member name or keyword
  • Option to load prebuilt data bundles (JSON/CSV) or connect to a database
  • CORS and cache configuration for safe use in web apps

Installation / Configuration

Clone the repository and run in a virtual environment, or run via Docker. Adjust environment variables to point at your dataset or database.

  1. Install locally (Python 3.9+)
git clone https://github.com/i-dot-ai/parliament-mcp.git
cd parliament-mcp
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
  1. Environment variables (example)
export PARLIAMENT_DATA_DIR="/path/to/data"   # directory with JSON/CSV bundles
export MCP_SERVER_PORT=8080
export MCP_CACHE_TTL=300                     # cache TTL in seconds
export LOG_LEVEL=info
  1. Run the server (typical ASGI command)
uvicorn app.main:app --host 0.0.0.0 --port ${MCP_SERVER_PORT} --reload
  1. Docker (quick start)
docker build -t parliament-mcp .
docker run -p 8080:8080 \
  -e PARLIAMENT_DATA_DIR=/data \
  -v /local/data:/data \
  parliament-mcp

If you use a database, set DATABASE_URL or the appropriate connection string per the repository README.

Available Resources

The server exposes the following resource endpoints (typical paths — consult /docs for exact routes and parameter names):

PathMethodPurpose
/billsGETSearch bills; filter by year, status, keyword
/bills/{id}GETFetch a single bill record and metadata
/votesGETSearch votes (division results); filter by date, bill
/votes/{id}GETGet full division record and vote breakdown
/debatesGETSearch Hansard debates by keyword, date, speaker
/debates/{id}GETFetch a debate segment or speech
/membersGETSearch MPs / peers by name, party, constituency
/members/{id}GETFull member profile and recent contributions
/constituenciesGETList/search constituencies and current MP
/mcp/contextPOSTMCP-style context provider for models (batch requests)
/docsGETOpenAPI / Swagger UI

The server typically includes an OpenAPI UI at /docs and a JSON schema at /openapi.json for automated integration.

Use Cases

  • Fetch vote context for fact checking

    • Example: retrieve the division record for a given vote ID, then show counts and named MPs who voted for/against.
    • Curl example:
      curl "http://localhost:8080/votes/2023-07-14-division-32"
      
  • Provide LLMs with reliable legislative context

    • Use the /mcp/context endpoint to request a compact context bundle for a bill or debate passage, then include that bundle as model context or a retrieval step before generation.
  • Build a parliamentary search UI

    • Query /debates?query=immigration&from=2024-01-01 to power search results, highlight matching speech snippets, and link to member profiles.
  • Assemble MP dossiers for journalism or civic tech

    • Combine /members/{id}, recent /debates entries and recent /votes results to present a consolidated timeline of activity.

Tips for Developers

  • Use the cache TTL to balance freshness vs performance when serving many LLM requests.
  • If you plan to serve as an LLM context provider, prefer the /mcp/context endpoint (or the OpenAPI tool schema) to return tightly summarised documents rather than raw full-text to reduce token cost.
  • Keep your data bundles updated from source feeds (Hansard, official votes, electoral registers). The repository often includes scripts for ingestion; check the data subfolder.

Resources

  • Source code and installation details: https://github.com/i-dot-ai/parliament-mcp
  • Common data sources: UK Parliament Hansard, official division lists, public member registers (check their licensing before reuse)

If you need examples for integrating the server with a specific LLM client or for custom data ingestion scripts, consult the repository README and the OpenAPI docs available on your running instance at /docs.