uk-parliament-mcp 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ """Parameter validation helpers."""
2
+
3
+ import re
4
+ from typing import Literal
5
+
6
+ HouseId = Literal[1, 2]
7
+
8
+
9
+ def validate_house_id(house: int) -> HouseId:
10
+ """Validate house ID is 1 (Commons) or 2 (Lords).
11
+
12
+ Args:
13
+ house: House identifier to validate
14
+
15
+ Returns:
16
+ Validated house ID
17
+
18
+ Raises:
19
+ ValueError: If house is not 1 or 2
20
+ """
21
+ if house not in (1, 2):
22
+ raise ValueError(f"House must be 1 (Commons) or 2 (Lords), got {house}")
23
+ return house # type: ignore[return-value]
24
+
25
+
26
+ def validate_date(date_str: str) -> str:
27
+ """Validate date is YYYY-MM-DD format.
28
+
29
+ Args:
30
+ date_str: Date string to validate
31
+
32
+ Returns:
33
+ Validated date string
34
+
35
+ Raises:
36
+ ValueError: If date format is invalid
37
+ """
38
+ if not re.match(r"^\d{4}-\d{2}-\d{2}$", date_str):
39
+ raise ValueError(f"Date must be YYYY-MM-DD format, got {date_str}")
40
+ return date_str
41
+
42
+
43
+ def validate_positive_int(value: int, name: str) -> int:
44
+ """Validate integer is positive.
45
+
46
+ Args:
47
+ value: Integer to validate
48
+ name: Parameter name for error message
49
+
50
+ Returns:
51
+ Validated integer
52
+
53
+ Raises:
54
+ ValueError: If value is not positive
55
+ """
56
+ if value < 1:
57
+ raise ValueError(f"{name} must be positive, got {value}")
58
+ return value
@@ -0,0 +1,408 @@
1
+ Metadata-Version: 2.4
2
+ Name: uk-parliament-mcp
3
+ Version: 1.1.0
4
+ Summary: UK Parliament MCP Server - bridges AI assistants with UK Parliament APIs
5
+ Author: Chris Brooksbank
6
+ License: MIT
7
+ Keywords: ai,api,claude,mcp,parliament,uk
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Python: >=3.11
14
+ Requires-Dist: httpx>=0.27.0
15
+ Requires-Dist: mcp>=1.0.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: mypy>=1.8.0; extra == 'dev'
18
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
19
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
20
+ Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
21
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
22
+ Requires-Dist: ruff>=0.3.0; extra == 'dev'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # UK Parliament AI Assistant
26
+
27
+ [![PyPI version](https://badge.fury.io/py/uk-parliament-mcp.svg)](https://badge.fury.io/py/uk-parliament-mcp)
28
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
29
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
30
+ [![CI](https://github.com/ChrisBrooksbank/uk-parliament-mcp-lab/actions/workflows/ci.yml/badge.svg)](https://github.com/ChrisBrooksbank/uk-parliament-mcp-lab/actions/workflows/ci.yml)
31
+
32
+ Access official UK Parliament data through AI assistants. Query MPs, Lords, bills, votes, committees, debates, and more.
33
+
34
+ ## Table of Contents
35
+
36
+ - [Getting Started](#getting-started)
37
+ - [Claude Desktop Setup](#claude-desktop-setup)
38
+ - [VS Code Setup](#vs-code-setup)
39
+ - [What Can I Ask?](#what-can-i-ask)
40
+ - [Power Tools](#power-tools)
41
+ - [Prompting Tips](#prompting-tips)
42
+ - [Example Prompts](#example-prompts)
43
+ - [Alternative Installation Methods](#alternative-installation-methods)
44
+ - [Final Thoughts](#final-thoughts)
45
+
46
+ ## Getting Started
47
+
48
+ **Step 1:** Configure your AI assistant (see [Claude Desktop](#claude-desktop-setup) or [VS Code](#vs-code-setup) below)
49
+
50
+ **Step 2:** Start a parliamentary research session:
51
+ - Use the `/parliament` slash command (in Claude Desktop or compatible MCP clients)
52
+ - Or say "Hello Parliament" to initialize the session
53
+
54
+ This gives your AI assistant the context it needs to effectively use the 92 available tools.
55
+
56
+ ## Claude Desktop Setup
57
+
58
+ 1. Open Claude Desktop
59
+ 2. Click **Settings** → **Developer** → **Edit Config**
60
+ 3. Add the following configuration and save with UTF-8 encoding:
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "uk-parliament": {
66
+ "command": "uvx",
67
+ "args": ["uk-parliament-mcp"]
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ 4. Restart Claude Desktop
74
+ 5. Open the Developer tab to verify the server is running
75
+
76
+ > **Note:** This uses `uvx` which runs the package directly without installation. It automatically uses the latest version from PyPI.
77
+ >
78
+ > Don't have uvx? Install it with: `pip install uv` or see [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/)
79
+
80
+ ## VS Code Setup
81
+
82
+ 1. Press `Ctrl+Shift+P` to open the Command Palette
83
+ 2. Select **MCP: Add Server**
84
+ 3. Choose **Command: Stdio**
85
+ 4. Enter: `uvx uk-parliament-mcp`
86
+ 5. Press **Enter**
87
+
88
+ ### Start the Server
89
+
90
+ 1. Press `Ctrl+Shift+P` again
91
+ 2. Select **MCP: List Servers**
92
+ 3. Click the server you just added and choose **Start server**
93
+
94
+ ### First Interaction
95
+
96
+ 1. Open **Copilot Chat** in VS Code
97
+ 2. Set **Agent mode** using the dropdown in the bottom-left
98
+ 3. Select your preferred model (e.g., Claude Sonnet 4)
99
+ 4. Click **Configure Tools**, and select all tools from the newly added MCP server
100
+ 5. Try a prompt such as: "What is happening now in the House of Commons?"
101
+ 6. Accept any permission request to allow the MCP call
102
+
103
+ ## What Can I Ask?
104
+
105
+ You can ask questions about virtually all aspects of UK Parliament data. Here are some key areas:
106
+
107
+ * **Live Parliamentary Activity:** "What's happening in the House of Commons right now?" or "What's currently being debated in the Lords?"
108
+ * **Members of Parliament:** "Tell me everything you know about Boris Johnson," "What are Sir Keir Starmer's registered interests?" or "Show me the voting record of member 4129"
109
+ * **Bills & Legislation:** "Show me details of bill 425," "What amendments were proposed for bill 425?" or "What publications exist for the Environment Bill?"
110
+ * **Voting Records:** "How did MPs vote on the climate change motion?" or "Show me Lords divisions on healthcare policy"
111
+ * **Committees & Inquiries:** "Which committees are investigating economic issues?" or "Show me evidence submitted to the Treasury Committee"
112
+ * **Parliamentary Procedures:** "Search Erskine May for references to Speaker's rulings" or "What are the oral question times this week?"
113
+ * **Constituencies & Elections:** "Show me election results for Birmingham constituencies" or "List all constituencies in Scotland"
114
+ * **Official Documents:** "Are there any statutory instruments about housing?" or "What treaties involve trade agreements?"
115
+ * **Transparency Data:** "Show register of interests for Treasury ministers" or "What are the declared interests categories?"
116
+
117
+ ## Power Tools
118
+
119
+ These high-level tools combine multiple API calls for common research tasks:
120
+
121
+ | Tool | What it does |
122
+ |------|--------------|
123
+ | `get_mp_profile(name)` | Complete MP/Lord profile: bio, interests, voting record |
124
+ | `check_mp_vote(mp_name, topic)` | How an MP voted on a specific topic |
125
+ | `get_bill_overview(search_term)` | Full bill info: details, stages, publications |
126
+ | `get_committee_summary(topic)` | Committee overview: evidence, publications |
127
+
128
+ **Example:**
129
+ ```
130
+ Tell me everything about Keir Starmer
131
+ ```
132
+ The AI will use `get_mp_profile` to fetch biography, registered interests, and voting history in a single efficient call.
133
+
134
+ ## Disconnecting from Parliament
135
+
136
+ Start a new chat session, or say "Goodbye Parliament" to end the parliamentary session while keeping context.
137
+
138
+ ---
139
+
140
+ ## Prompting Tips
141
+
142
+ > **Note**: Since AI is involved, some responses may be inaccurate. These tips help improve reliability.
143
+
144
+ ### ✅ Initialize Your Session
145
+
146
+ Always begin your session with `/parliament` or "Hello Parliament". This ensures the AI assistant uses the correct tools and cites its sources properly.
147
+
148
+ ### 🔄 Clear Context
149
+
150
+ Use the `+` icon (new chat) if:
151
+ - The AI seems stuck in a loop
152
+ - You want to reset the conversation context
153
+
154
+ ### 🔗 Re-Display the API URL
155
+
156
+ While the AI is instructed to list source URLs automatically, you can ask for them again at any time. This is useful for troubleshooting or if you simply want to re-confirm the source for the last response.
157
+
158
+ You can ask:
159
+
160
+ ```plaintext
161
+ Show me the API URL you just used.
162
+ ```
163
+
164
+ Example response:
165
+ > The API URL just used to retrieve information about Boris Johnson is:
166
+ > `https://members-api.parliament.uk/api/Members/Search?Name=Boris%20Johnson`
167
+
168
+ ### 🧠 Combine Data from Multiple Sources
169
+
170
+ Example:
171
+ ```plaintext
172
+ Has Chelmsford been mentioned in either the Commons or Lords?
173
+ ```
174
+
175
+ The AI may:
176
+ - Query both Commons and Lords Hansard
177
+ - Combine the results
178
+ - Offer more detail if requested
179
+
180
+ ### 🧾 See the Raw JSON
181
+
182
+ For debugging or to inspect the raw data structure, you can ask the assistant to show you the full JSON response from its last API call. This is particularly useful for developers who want to understand exactly what information the AI is working with before it is summarized.
183
+
184
+ Example prompt:
185
+ ```plaintext
186
+ Show me the JSON returned from the last MCP call.
187
+ ```
188
+
189
+ ## Example Prompts
190
+
191
+ <details>
192
+ <summary><strong>Live Parliamentary Activity</strong> (3 examples)</summary>
193
+
194
+ - What is happening now in both Houses?
195
+ - What's currently happening in the House of Commons?
196
+ - What's currently happening in the House of Lords?
197
+
198
+ </details>
199
+
200
+ <details>
201
+ <summary><strong>Members of Parliament</strong> (14 examples)</summary>
202
+
203
+ - Show me the interests of Sir Keir Starmer
204
+ - Who is Boris Johnson?
205
+ - Who is the member with ID 1471?
206
+ - Get the biography of member 172
207
+ - Show me contact details for member 4129
208
+ - What are the registered interests of member 3743?
209
+ - Show recent contributions from member 172
210
+ - What is the Commons voting record for member 4129?
211
+ - What is the Lords voting record for member 3743?
212
+ - Show the professional experience of member 1471
213
+ - What policy areas does member 172 focus on?
214
+ - Show early day motions submitted by member 1471
215
+ - Get the constituency election results for member 4129
216
+ - Show me the portrait and thumbnail images for member 172
217
+
218
+ </details>
219
+
220
+ <details>
221
+ <summary><strong>Bills and Legislation</strong> (14 examples)</summary>
222
+
223
+ - What recent bills are about fishing?
224
+ - What bills were updated recently?
225
+ - Show me details of bill 425
226
+ - What stages has bill 425 been through?
227
+ - What amendments were proposed for bill 425 at stage 15?
228
+ - Show me amendment 1234 for bill 425 stage 15
229
+ - What publications exist for bill 425?
230
+ - What news articles are there about bill 425?
231
+ - Show me all bill types available
232
+ - What are the different stages a bill can go through?
233
+ - Search for bills containing the word "environment"
234
+ - Get the RSS feed for all bills
235
+ - Get the RSS feed for public bills only
236
+ - Get the RSS feed for bill 425
237
+
238
+ </details>
239
+
240
+ <details>
241
+ <summary><strong>Voting and Divisions</strong> (6 examples)</summary>
242
+
243
+ - Search Commons Divisions for the keyword "refugee"
244
+ - Show details of Commons division 1234
245
+ - Show details of Lords division 5678
246
+ - Get Commons divisions grouped by party for keyword "climate"
247
+ - Get Lords divisions grouped by party for member 3743
248
+ - How many divisions match the search term "brexit"?
249
+
250
+ </details>
251
+
252
+ <details>
253
+ <summary><strong>Committees and Inquiries</strong> (9 examples)</summary>
254
+
255
+ - Which committees are focused on women's issues?
256
+ - List committee meetings scheduled for November 2024
257
+ - Show me details of committee 789
258
+ - What events has committee 789 held?
259
+ - Who are the members of committee 789?
260
+ - Search for committee publications about healthcare
261
+ - Show me written evidence submitted to committee 789
262
+ - Show me oral evidence from committee 789 hearings
263
+ - What are all the committee types?
264
+
265
+ </details>
266
+
267
+ <details>
268
+ <summary><strong>Parliamentary Procedures</strong> (9 examples)</summary>
269
+
270
+ - Search Erskine May for references to the Mace
271
+ - Show oral question times for questions tabled in November 2024
272
+ - Search Hansard for contributions on Brexit from November 2024
273
+ - What government departments exist?
274
+ - What are the answering bodies in Parliament?
275
+ - What parties are represented in the House of Commons?
276
+ - What parties are represented in the House of Lords?
277
+ - Show parliamentary calendar events for Commons in December 2024
278
+ - When is Parliament not sitting in January 2025?
279
+
280
+ </details>
281
+
282
+ <details>
283
+ <summary><strong>Constituencies and Elections</strong> (3 examples)</summary>
284
+
285
+ - List all UK constituencies
286
+ - Show the election results for constituency 4359
287
+ - Search for constituencies containing "london"
288
+
289
+ </details>
290
+
291
+ <details>
292
+ <summary><strong>Transparency and Interests</strong> (4 examples)</summary>
293
+
294
+ - List all categories of members' interests
295
+ - Get published registers of interests
296
+ - Show staff interests for Lords members
297
+ - Search the register of interests for member 1471
298
+
299
+ </details>
300
+
301
+ <details>
302
+ <summary><strong>Official Documents and Publications</strong> (5 examples)</summary>
303
+
304
+ - Are there any statutory instruments about harbours?
305
+ - Search Acts of Parliament that mention roads
306
+ - What treaties involve Spain?
307
+ - What publication types are available for bills?
308
+ - Show me document 123 from publication 456
309
+
310
+ </details>
311
+
312
+ <details>
313
+ <summary><strong>Advanced Queries</strong> (5 examples)</summary>
314
+
315
+ - Show the full data from this pasted API result: {PasteApiResultHere}
316
+ - Show me the JSON returned from the last MCP call
317
+ - Show me the API URL you just used
318
+ - Search for bills sponsored by member 172 from the Environment department
319
+ - Find all committee meetings about climate change between November and December 2024
320
+
321
+ </details>
322
+
323
+ ---
324
+
325
+ ## Alternative Installation Methods
326
+
327
+ The `uvx` method shown above is recommended for most users. For specific use cases, here are alternative approaches:
328
+
329
+ ### Which Method Should I Use?
330
+
331
+ | Method | Best For | Pros | Cons |
332
+ |--------|----------|------|------|
333
+ | `uvx uk-parliament-mcp` | Most users | No install needed, always latest version | Requires uvx installed |
334
+ | `pip install uk-parliament-mcp` | Production use | Stable, version locked | Requires pip, manual updates |
335
+ | Local development install | Contributors | Full source access, can modify | More complex setup |
336
+
337
+ ### Using pip install
338
+
339
+ Install the package globally:
340
+
341
+ ```bash
342
+ pip install uk-parliament-mcp
343
+ ```
344
+
345
+ Then configure your AI client:
346
+
347
+ **Claude Desktop:**
348
+ ```json
349
+ {
350
+ "mcpServers": {
351
+ "uk-parliament": {
352
+ "command": "uk-parliament-mcp"
353
+ }
354
+ }
355
+ }
356
+ ```
357
+
358
+ **VS Code:** Use `uk-parliament-mcp` as the command when adding the MCP server.
359
+
360
+ ### Installation from Source
361
+
362
+ For development or to get the latest unreleased changes:
363
+
364
+ #### Prerequisites
365
+
366
+ - [Python](https://www.python.org/downloads/) (v3.11 or later)
367
+ - [Git](https://git-scm.com/downloads)
368
+
369
+ #### Clone and Install
370
+
371
+ ```bash
372
+ git clone https://github.com/ChrisBrooksbank/uk-parliament-mcp-lab.git
373
+ cd uk-parliament-mcp-lab
374
+
375
+ # Create and activate virtual environment
376
+ python -m venv .venv
377
+ source .venv/bin/activate # Linux/Mac
378
+ # .venv\Scripts\activate # Windows
379
+
380
+ # Install the package
381
+ pip install -e .
382
+ ```
383
+
384
+ #### Configure for Local Development
385
+
386
+ **Claude Desktop:**
387
+ ```json
388
+ {
389
+ "mcpServers": {
390
+ "uk-parliament": {
391
+ "command": "C:\\code\\uk-parliament-mcp-lab\\.venv\\Scripts\\python.exe",
392
+ "args": ["-m", "uk_parliament_mcp"],
393
+ "cwd": "C:\\code\\uk-parliament-mcp-lab"
394
+ }
395
+ }
396
+ }
397
+ ```
398
+
399
+ **VS Code:** Use the full path to the virtual environment Python:
400
+ ```bash
401
+ C:\code\uk-parliament-mcp-lab\.venv\Scripts\python.exe -m uk_parliament_mcp
402
+ ```
403
+
404
+ ---
405
+
406
+ ## Final Thoughts
407
+
408
+ The project is under active development, with plans to increase data coverage and improve interaction quality. Contributions and feedback are welcome.
@@ -0,0 +1,26 @@
1
+ uk_parliament_mcp/__init__.py,sha256=LLbj8236Pn0ZBQhfanKj7zDZNHMPMH4x-cHGP7Y3Gjs,106
2
+ uk_parliament_mcp/__main__.py,sha256=BnSPIX1Nap5YjESCRVujsE6UyKOAGq_KmQ0bj45jS-o,551
3
+ uk_parliament_mcp/config.py,sha256=vhP4I8Kr6rUfkXxAUa74SqLlqtOHqhgYtyMWFlgZNcM,989
4
+ uk_parliament_mcp/http_client.py,sha256=-lVsEzL9PYm0ORqzSuHhjUz_02j0gVEX677wAR-mRCU,7545
5
+ uk_parliament_mcp/server.py,sha256=wYp0WP00swRKDsU5YBecNWs3lk_skbGDJH0L9dA6SXg,1284
6
+ uk_parliament_mcp/validators.py,sha256=j1oWKQ6KKrAV3TdSDEJ0rZGIVB9M2wLbLCC7GPK4xZg,1314
7
+ uk_parliament_mcp/tools/__init__.py,sha256=eWxH_qVslDmAhrayJEaaTHBaVYUQbmmcxBZXTMjCarY,47
8
+ uk_parliament_mcp/tools/bills.py,sha256=k8S0Qltah3wpjQ4xeIqmQaCsjY-ntPCxaruZAIba-1Y,15336
9
+ uk_parliament_mcp/tools/committees.py,sha256=wHFWOFLFA2eifyYQNFShBIEf_BFf-6P0VJYuiYrLa4Q,17532
10
+ uk_parliament_mcp/tools/commons_votes.py,sha256=MqijsbunRZqMGinOPXkYP_68rsdOGl2P6KYrhFIZIl4,6286
11
+ uk_parliament_mcp/tools/composite.py,sha256=oGowRSG2FsWmYvWgvLi4QECgN71eweopfqms8yuoH3g,12025
12
+ uk_parliament_mcp/tools/core.py,sha256=uHli5AJVqO7apuWTLe45X8tqytFmXl89iRyXhbu0taA,37651
13
+ uk_parliament_mcp/tools/erskine_may.py,sha256=okYdBfWqwZ5bB-VutG-FF6MKCS3nP0XHCd1jTs8m-K8,1001
14
+ uk_parliament_mcp/tools/hansard.py,sha256=KWPydXeXGUTKlFf_-LgBYCD7eKbNUovWuA5J3y1jNWs,1486
15
+ uk_parliament_mcp/tools/interests.py,sha256=m3jJFIpQYikNPNOq6d38F9R9U8bjt8U7tTeVJxL1_RI,2096
16
+ uk_parliament_mcp/tools/lords_votes.py,sha256=FwRTPfbJAN7OPGXrteyhE1LY3-qxsXVQ5ARFX-8IPOM,6489
17
+ uk_parliament_mcp/tools/members.py,sha256=zAYbdjmUpG0C98gjb3a4DOVPwt35Iw_SCQHSEi_xKRE,20069
18
+ uk_parliament_mcp/tools/now.py,sha256=hc-diR2x0-ZYd0C8l7GBC_DgM59Td6sNsN26lPo-KM4,1235
19
+ uk_parliament_mcp/tools/oral_questions.py,sha256=Q69zTCws-Czm75jNOewmfJKwHDLGDUPvPVuQzrJRnrA,2771
20
+ uk_parliament_mcp/tools/statutory_instruments.py,sha256=xGXcS94QNDWdls7Ncn3rkBdstYUFLcuPKdcTVJvVQRg,1631
21
+ uk_parliament_mcp/tools/treaties.py,sha256=m7cv638f7JoH1JfmqDr9h2W6X7ly_QvNaOjN_UjnqNc,1205
22
+ uk_parliament_mcp/tools/whatson.py,sha256=7gOXe_YHEmmIoNBVBkfQn4dXKELn9K7MjlxMV-8k34Y,2608
23
+ uk_parliament_mcp-1.1.0.dist-info/METADATA,sha256=PQYNc-yOPeuiYlWX6jm_CisFK5M9KgwVIPkI7Vz5oPo,13987
24
+ uk_parliament_mcp-1.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
25
+ uk_parliament_mcp-1.1.0.dist-info/entry_points.txt,sha256=KMWbvQHZnZ7b18mlcCpTQ-k9XciquJ7_TeULFOmUZis,70
26
+ uk_parliament_mcp-1.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ uk-parliament-mcp = uk_parliament_mcp.__main__:main