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,25 @@
1
+ """Erskine May API tools for parliamentary procedure."""
2
+
3
+ from urllib.parse import quote
4
+
5
+ from mcp.server.fastmcp import FastMCP
6
+
7
+ from uk_parliament_mcp.config import ERSKINE_MAY_API_BASE
8
+ from uk_parliament_mcp.http_client import get_result
9
+
10
+
11
+ def register_tools(mcp: FastMCP) -> None:
12
+ """Register Erskine May tools with the MCP server."""
13
+
14
+ @mcp.tool()
15
+ async def search_erskine_may(search_term: str) -> str:
16
+ """Search Erskine May parliamentary procedure manual. Use when you need to understand parliamentary rules, procedures, or precedents. Erskine May is the authoritative guide to parliamentary procedure.
17
+
18
+ Args:
19
+ search_term: Search term for parliamentary procedure rules (e.g. 'Speaker', 'amendment', 'division').
20
+
21
+ Returns:
22
+ Erskine May paragraphs matching the search term.
23
+ """
24
+ url = f"{ERSKINE_MAY_API_BASE}/Search/ParagraphSearchResults/{quote(search_term)}"
25
+ return await get_result(url)
@@ -0,0 +1,39 @@
1
+ """Hansard API tools for searching the official parliamentary record."""
2
+
3
+ from mcp.server.fastmcp import FastMCP
4
+
5
+ from uk_parliament_mcp.config import HANSARD_API_BASE
6
+ from uk_parliament_mcp.http_client import build_url, get_result
7
+
8
+
9
+ def register_tools(mcp: FastMCP) -> None:
10
+ """Register Hansard tools with the MCP server."""
11
+
12
+ @mcp.tool()
13
+ async def search_hansard(
14
+ house: int,
15
+ start_date: str,
16
+ end_date: str,
17
+ search_term: str,
18
+ ) -> str:
19
+ """Search Hansard (official parliamentary record) for speeches and debates. Use when researching what was said in Parliament on specific topics, by specific members, or in specific time periods. House: 1=Commons, 2=Lords.
20
+
21
+ Args:
22
+ house: House number: 1 for Commons, 2 for Lords.
23
+ start_date: Start date in YYYY-MM-DD format.
24
+ end_date: End date in YYYY-MM-DD format.
25
+ search_term: Search term for speeches or debates (e.g. 'climate change', 'NHS').
26
+
27
+ Returns:
28
+ Hansard records matching the search criteria.
29
+ """
30
+ url = build_url(
31
+ f"{HANSARD_API_BASE}/search.json",
32
+ {
33
+ "queryParameters.house": house,
34
+ "queryParameters.startDate": start_date,
35
+ "queryParameters.endDate": end_date,
36
+ "queryParameters.searchTerm": search_term,
37
+ },
38
+ )
39
+ return await get_result(url)
@@ -0,0 +1,43 @@
1
+ """Interests API tools for Register of Interests."""
2
+
3
+ from mcp.server.fastmcp import FastMCP
4
+
5
+ from uk_parliament_mcp.config import INTERESTS_API_BASE
6
+ from uk_parliament_mcp.http_client import get_result
7
+
8
+
9
+ def register_tools(mcp: FastMCP) -> None:
10
+ """Register interests tools with the MCP server."""
11
+
12
+ @mcp.tool()
13
+ async def search_roi(member_id: int) -> str:
14
+ """Search member's Register of Interests for financial and business declarations | register of interests, ROI, financial interests, conflicts of interest, directorships, consultancies, gifts, external roles, transparency | Use for investigating potential conflicts, researching member finances, or checking declared interests | Returns declared interests including directorships, consultancies, gifts, and other financial interests
15
+
16
+ Args:
17
+ member_id: Parliament member ID. Required: get from member search first. Returns all declared interests.
18
+
19
+ Returns:
20
+ Declared interests including directorships, consultancies, gifts, and other financial interests.
21
+ """
22
+ url = f"{INTERESTS_API_BASE}/Interests/?MemberId={member_id}"
23
+ return await get_result(url)
24
+
25
+ @mcp.tool()
26
+ async def interests_categories() -> str:
27
+ """Get categories of interests that MPs and Lords must declare in the Register of Interests. Use when you need to understand what types of financial or other interests parliamentarians must declare.
28
+
29
+ Returns:
30
+ Categories of interests that must be declared.
31
+ """
32
+ url = f"{INTERESTS_API_BASE}/Categories"
33
+ return await get_result(url)
34
+
35
+ @mcp.tool()
36
+ async def get_registers_of_interests() -> str:
37
+ """Get list of published Registers of Interests. Use when you need to see all available interest registers or understand the transparency framework for parliamentary interests.
38
+
39
+ Returns:
40
+ List of published Registers of Interests.
41
+ """
42
+ url = f"{INTERESTS_API_BASE}/Registers"
43
+ return await get_result(url)
@@ -0,0 +1,149 @@
1
+ """Lords Votes API tools for House of Lords divisions and voting records."""
2
+
3
+ from urllib.parse import quote
4
+
5
+ from mcp.server.fastmcp import FastMCP
6
+
7
+ from uk_parliament_mcp.config import LORDS_VOTES_API_BASE
8
+ from uk_parliament_mcp.http_client import build_url, get_result
9
+
10
+
11
+ def register_tools(mcp: FastMCP) -> None:
12
+ """Register Lords votes tools with the MCP server."""
13
+
14
+ @mcp.tool()
15
+ async def search_lords_divisions(search_term: str) -> str:
16
+ """Search House of Lords voting records (divisions). Use when you want to find how Lords voted on specific issues, bills, or amendments in the upper chamber.
17
+
18
+ Args:
19
+ search_term: Search term for Lords division topics (e.g. 'brexit', 'climate', 'NHS').
20
+
21
+ Returns:
22
+ Lords divisions matching the search term.
23
+ """
24
+ url = f"{LORDS_VOTES_API_BASE}/divisions/search?queryParameters.searchTerm={quote(search_term)}"
25
+ return await get_result(url)
26
+
27
+ @mcp.tool()
28
+ async def get_lords_voting_record_for_member(
29
+ member_id: int,
30
+ search_term: str | None = None,
31
+ include_when_member_was_teller: bool | None = None,
32
+ start_date: str | None = None,
33
+ end_date: str | None = None,
34
+ division_number: int | None = None,
35
+ skip: int = 0,
36
+ take: int = 25,
37
+ ) -> str:
38
+ """Get complete voting record of a Lord in House of Lords divisions. Use when analyzing how a specific Lord votes, their voting patterns, or their stance on particular issues through their voting history.
39
+
40
+ Args:
41
+ member_id: Parliament member ID to get Lords voting record for.
42
+ search_term: Optional: search term to filter divisions.
43
+ include_when_member_was_teller: Optional: include votes where member was a teller.
44
+ start_date: Optional: start date in YYYY-MM-DD format.
45
+ end_date: Optional: end date in YYYY-MM-DD format.
46
+ division_number: Optional: specific division number.
47
+ skip: Number of records to skip (for pagination).
48
+ take: Number of records to return (default 25, max 100).
49
+
50
+ Returns:
51
+ Complete Lords voting record for the member.
52
+ """
53
+ url = build_url(
54
+ f"{LORDS_VOTES_API_BASE}/Divisions/membervoting",
55
+ {
56
+ "MemberId": member_id,
57
+ "SearchTerm": search_term,
58
+ "IncludeWhenMemberWasTeller": include_when_member_was_teller,
59
+ "StartDate": start_date,
60
+ "EndDate": end_date,
61
+ "DivisionNumber": division_number,
62
+ "skip": skip,
63
+ "take": take,
64
+ },
65
+ )
66
+ return await get_result(url)
67
+
68
+ @mcp.tool()
69
+ async def get_lords_division_by_id(division_id: int) -> str:
70
+ """Get detailed information about a specific House of Lords division by ID. Use when you need complete details about a particular Lords vote including who voted content/not content, tellers, and voting totals.
71
+
72
+ Args:
73
+ division_id: Unique Lords division ID number.
74
+
75
+ Returns:
76
+ Detailed information about the Lords division.
77
+ """
78
+ url = f"{LORDS_VOTES_API_BASE}/Divisions/{division_id}"
79
+ return await get_result(url)
80
+
81
+ @mcp.tool()
82
+ async def get_lords_divisions_grouped_by_party(
83
+ search_term: str | None = None,
84
+ member_id: int | None = None,
85
+ start_date: str | None = None,
86
+ end_date: str | None = None,
87
+ division_number: int | None = None,
88
+ include_when_member_was_teller: bool | None = None,
89
+ ) -> str:
90
+ """Get House of Lords divisions grouped by party voting patterns. Use when analyzing how different parties voted on issues in the Lords or understanding party-line voting behavior. Shows vote counts by party rather than individual Lords.
91
+
92
+ Args:
93
+ search_term: Optional: search term to filter divisions.
94
+ member_id: Optional: member ID to filter divisions.
95
+ start_date: Optional: start date in YYYY-MM-DD format.
96
+ end_date: Optional: end date in YYYY-MM-DD format.
97
+ division_number: Optional: specific division number.
98
+ include_when_member_was_teller: Optional: include when member was a teller.
99
+
100
+ Returns:
101
+ Lords divisions grouped by party.
102
+ """
103
+ url = build_url(
104
+ f"{LORDS_VOTES_API_BASE}/Divisions/groupedbyparty",
105
+ {
106
+ "SearchTerm": search_term,
107
+ "MemberId": member_id,
108
+ "StartDate": start_date,
109
+ "EndDate": end_date,
110
+ "DivisionNumber": division_number,
111
+ "IncludeWhenMemberWasTeller": include_when_member_was_teller,
112
+ },
113
+ )
114
+ return await get_result(url)
115
+
116
+ @mcp.tool()
117
+ async def get_lords_divisions_search_count(
118
+ search_term: str | None = None,
119
+ member_id: int | None = None,
120
+ start_date: str | None = None,
121
+ end_date: str | None = None,
122
+ division_number: int | None = None,
123
+ include_when_member_was_teller: bool | None = None,
124
+ ) -> str:
125
+ """Get total count of House of Lords divisions matching search criteria. Use when you need to know how many Lords divisions match your search parameters before retrieving the actual results.
126
+
127
+ Args:
128
+ search_term: Optional: search term to filter divisions.
129
+ member_id: Optional: member ID to filter divisions.
130
+ start_date: Optional: start date in YYYY-MM-DD format.
131
+ end_date: Optional: end date in YYYY-MM-DD format.
132
+ division_number: Optional: specific division number.
133
+ include_when_member_was_teller: Optional: include when member was a teller.
134
+
135
+ Returns:
136
+ Total count of matching Lords divisions.
137
+ """
138
+ url = build_url(
139
+ f"{LORDS_VOTES_API_BASE}/Divisions/searchTotalResults",
140
+ {
141
+ "SearchTerm": search_term,
142
+ "MemberId": member_id,
143
+ "StartDate": start_date,
144
+ "EndDate": end_date,
145
+ "DivisionNumber": division_number,
146
+ "IncludeWhenMemberWasTeller": include_when_member_was_teller,
147
+ },
148
+ )
149
+ return await get_result(url)