Skip to content

Commit e6a228e

Browse files
committed
Align tool schemas with remote server implementation
- Update pia_search tool schema to match remote server exactly - Add missing filter parameter to pia_search_facets tool - Update filter descriptions with actual field names and comprehensive examples - Align documentation examples to use actual field names: - SourceDocumentDataSource instead of data_source - SourceDocumentPublishDate instead of published_date - RecStatus, RecPriorityFlag, IsIntegrityRelated field names - Update prompt examples to match remote implementation - Ensure parameter descriptions match remote server's function signatures This ensures the local proxy server's tool schemas exactly match the remote server implementation at https://mcp.programintegrity.org/
1 parent cf65b8f commit e6a228e

File tree

4 files changed

+36
-24
lines changed

4 files changed

+36
-24
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,5 @@ dmypy.json
151151

152152
# Cython debug symbols
153153
cython_debug/
154+
155+
examples

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ Comprehensive search with OData filtering and faceting. The `filter` parameter u
140140
- `include_facets` (optional): Include facets in results (default: false)
141141

142142
**Example Filter Expressions:**
143-
- Basic filter: `"data_source eq 'OIG'"`
144-
- Multiple conditions: `"data_source in ('OIG', 'GAO') and published_date ge '2023-01-01'"`
145-
- Complex grouping: `"(agency ne 'Department of Defense') and (severity in ('High', 'Critical'))"`
146-
- Date ranges: `"published_date ge '2023-01-01' and published_date le '2023-12-31'"`
147-
- String functions: `"contains(title, 'Medicare') and startswith(agency, 'Department')"`
143+
- Basic filter: `"SourceDocumentDataSource eq 'GAO'"`
144+
- Multiple conditions: `"SourceDocumentDataSource eq 'GAO' or SourceDocumentDataSource eq 'OIG'"`
145+
- Complex grouping: `"SourceDocumentDataSource eq 'GAO' and RecStatus ne 'Closed'"`
146+
- Negation: `"SourceDocumentDataSource ne 'Department of Justice' and not (RecStatus eq 'Closed')"`
147+
- List membership: `"IsIntegrityRelated eq 'Yes' and RecPriorityFlag in ('High', 'Critical')"`
148+
- Date ranges: `"SourceDocumentPublishDate ge '2020-01-01' and SourceDocumentPublishDate le '2024-12-31'"`
149+
- Boolean grouping: `"(SourceDocumentDataSource eq 'GAO' or SourceDocumentDataSource eq 'OIG') and RecStatus eq 'Open'"`
148150

149151
**OData Filter Operators:**
150152
- `eq` - equals: `field eq 'value'`
@@ -194,10 +196,11 @@ Use the `pia_search_facets` tool to explore what fields are available for filter
194196
The facets response will show available fields and their possible values:
195197
```json
196198
{
197-
"data_source": ["OIG", "GAO", "CMS", "FBI"],
198-
"document_type": ["audit_report", "investigation", "enforcement_action"],
199-
"agency": ["Department of Health", "Department of Defense"],
200-
"published_date": "2020-01-01 to 2024-12-31"
199+
"SourceDocumentDataSource": ["OIG", "GAO", "CMS", "FBI"],
200+
"RecStatus": ["Open", "Closed", "In Progress"],
201+
"RecPriorityFlag": ["High", "Medium", "Low", "Critical"],
202+
"IsIntegrityRelated": ["Yes", "No"],
203+
"SourceDocumentPublishDate": "2020-01-01 to 2024-12-31"
201204
}
202205
```
203206

@@ -207,13 +210,13 @@ Use the `pia_search` tool with discovered fields to create precise OData filters
207210
**Basic Example:**
208211
```
209212
Query: "Medicare fraud"
210-
Filter: "data_source in ('OIG', 'CMS') and published_date ge '2023-01-01' and document_type eq 'audit_report'"
213+
Filter: "SourceDocumentDataSource eq 'GAO' and SourceDocumentPublishDate ge '2023-01-01' and IsIntegrityRelated eq 'Yes'"
211214
```
212215

213216
**Complex Example:**
214217
```
215218
Query: "healthcare violations"
216-
Filter: "(data_source eq 'OIG' or data_source eq 'CMS') and (severity eq 'High' or amount gt 1000000) and published_date ge '2023-01-01'"
219+
Filter: "(SourceDocumentDataSource eq 'OIG' or SourceDocumentDataSource eq 'CMS') and RecPriorityFlag in ('High', 'Critical') and SourceDocumentPublishDate ge '2023-01-01'"
217220
```
218221

219222
## 📝 AI Instruction Prompts

src/pia_mcp_server/prompts/handlers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ def _generate_search_prompt(arguments: Dict[str, str]) -> str:
179179
3. **Build the filter expression**:
180180
- Use **only field names and values** returned by `pia_search_facets`.
181181
- Construct the filter in **OData syntax**:
182-
- `data_source eq 'GAO'`
183-
- `(data_source eq 'GAO' or data_source eq 'CIGIE') and year ge 2020`
182+
- `SourceDocumentDataSource eq 'GAO'`
183+
- `(SourceDocumentDataSource eq 'GAO' or SourceDocumentDataSource eq 'OIG') and SourceDocumentPublishDate ge '2020-01-01'`
184184
- Use correct operators: `eq`, `ne`, `gt`, `ge`, `lt`, `le`, `and`, `or`.
185185
- Wrap string values in single quotes `'value'`.
186186
@@ -190,7 +190,7 @@ def _generate_search_prompt(arguments: Dict[str, str]) -> str:
190190
```
191191
{{
192192
"query": "fraud detection",
193-
"filter": "data_source eq 'GAO' and year ge 2021"
193+
"filter": "SourceDocumentDataSource eq 'GAO' and SourceDocumentPublishDate ge '2021-01-01'"
194194
}}
195195
```
196196

src/pia_mcp_server/tools/search_tools.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,37 @@
1313
# Tool definitions based on the API response
1414
pia_search_tool = types.Tool(
1515
name="pia_search",
16-
description="Search the Program Integrity Alliance (PIA) database for documents and recommendations. Returns comprehensive results with full citation information and clickable links for proper attribution. Each result includes corresponding citations with data source attribution (GAO, OIG, etc.). Supports OData filter expressions using operators like eq, ne, gt, ge, lt, le, and, or, etc.",
16+
description="Search the Program Integrity Alliance (PIA) database for documents and recommendations. Returns comprehensive results with full citation information and clickable links for proper attribution. Each result includes corresponding citations with data source attribution (GAO, OIG, etc.). Supports complex OData filtering with boolean logic, operators, and grouping.",
1717
inputSchema={
1818
"type": "object",
1919
"properties": {
2020
"query": {"type": "string", "description": "Search query text"},
2121
"filter": {
2222
"type": "string",
23-
"description": "Optional OData filter expression for narrowing results (e.g., \"data_source eq 'GAO'\")",
23+
"description": "OData filter expression supporting complex boolean logic. Examples: \"SourceDocumentDataSource eq 'GAO'\", \"SourceDocumentDataSource eq 'GAO' or SourceDocumentDataSource eq 'OIG'\", \"SourceDocumentDataSource eq 'GAO' and RecStatus ne 'Closed'\", \"SourceDocumentDataSource ne 'Department of Justice' and not (RecStatus eq 'Closed')\", \"IsIntegrityRelated eq 'Yes' and RecPriorityFlag in ('High', 'Critical')\", \"SourceDocumentPublishDate ge '2020-01-01' and SourceDocumentPublishDate le '2024-12-31'\", \"(SourceDocumentDataSource eq 'GAO' or SourceDocumentDataSource eq 'OIG') and RecStatus eq 'Open'\"",
2424
},
2525
"page": {
2626
"type": "integer",
27-
"description": "Page number (default: 1)",
27+
"description": "Page number (1-based)",
2828
"default": 1,
2929
},
3030
"page_size": {
3131
"type": "integer",
32-
"description": "Results per page (default: 10)",
32+
"description": "Number of results per page (max 50)",
3333
"default": 10,
3434
},
3535
"search_mode": {
3636
"type": "string",
37-
"description": "Search mode (default: content)",
37+
"description": 'Search mode - "content" for full-text search or "titles" for title-only search',
3838
"default": "content",
3939
},
40-
"limit": {"type": "integer", "description": "Maximum results limit"},
40+
"limit": {
41+
"type": "integer",
42+
"description": "Alternative name for page_size (for compatibility)",
43+
},
4144
"include_facets": {
4245
"type": "boolean",
43-
"description": "Include facets in results",
46+
"description": "Whether to include facets in response (default False to reduce token usage)",
4447
"default": False,
4548
},
4649
},
@@ -50,15 +53,19 @@
5053

5154
pia_search_facets_tool = types.Tool(
5255
name="pia_search_facets",
53-
description="Get available facets (filter values) for the PIA database. This can help understand what filter values are available before performing searches.",
56+
description="Get available facets (filter values) for the PIA database. This can help understand what filter values are available before performing searches. Supports complex OData filtering with boolean logic, operators, and grouping.",
5457
inputSchema={
5558
"type": "object",
5659
"properties": {
5760
"query": {
5861
"type": "string",
59-
"description": "Optional query to get facets for",
62+
"description": "Optional query to get facets for (if empty, gets all facets)",
6063
"default": "",
61-
}
64+
},
65+
"filter": {
66+
"type": "string",
67+
"description": "Optional OData filter expression. Examples: \"SourceDocumentDataSource eq 'GAO'\", \"SourceDocumentDataSource eq 'GAO' and RecStatus ne 'Closed'\", \"IsIntegrityRelated eq 'Yes' and RecPriorityFlag in ('High', 'Critical')\", \"SourceDocumentPublishDate ge '2020-01-01' and SourceDocumentPublishDate le '2024-12-31'\"",
68+
},
6269
},
6370
},
6471
)

0 commit comments

Comments
 (0)