Skip to content

Conversation

@policyengine
Copy link

@policyengine policyengine bot commented Dec 18, 2025

Summary

Fixed multiple workflow issues that prevented completing a full policy analysis through the MCP interface. Now Claude can successfully analyze reforms like "lowering UK basic income tax rate to 16p" using only the MCP tools.

Problems Identified

  1. No parameter search - Had to paginate through 100s of parameters to find the right one
  2. Policy creation incomplete - PolicyCreate schema didn't support parameter_values, making it impossible to create a usable policy
  3. No workflow guidance - Unclear how to connect parameters → policies → analysis
  4. Missing examples - No clear examples of the complete workflow

Changes Made

1. Parameter Search (parameters.py)

  • Added search query parameter to filter by name, label, or description
  • Example: /parameters?search=basic_rate finds UK income tax parameters instantly

2. Policy Creation with Values (policies.py, policy.py)

  • Extended PolicyCreate schema to include parameter_values list
  • Updated /policies POST endpoint to create parameter values atomically with policy
  • Added detailed example showing exact format needed

3. Workflow Documentation

  • Added step-by-step workflow guidance to policies.py module docstring
  • Enhanced analysis.py with clear workflow steps
  • Added usage notes to datasets.py for finding UK/US datasets

4. Complete Example Flow

Now Claude can execute this workflow:

1. Search: GET /parameters?search=basic_rate
2. Create policy: POST /policies
   {
     "name": "Lower basic rate to 16p",
     "parameter_values": [{
       "parameter_id": "<from-search>",
       "value_json": 0.16,
       "start_date": "2026-01-01T00:00:00Z"
     }]
   }
3. Test household: POST /household/impact with policy_id
4. Get dataset: GET /datasets (find UK dataset)
5. Run analysis: POST /analysis/economic-impact
6. Poll: GET /analysis/economic-impact/{report_id}

Testing

Manually traced through the workflow to verify all steps are now discoverable and executable through the MCP interface. The guidance in docstrings is exposed via FastAPI's OpenAPI schema, which FastApiMCP converts to tool descriptions.

Impact

With these changes, Claude can now:

  • ✅ Find parameters by searching keywords
  • ✅ Create policies with parameter changes in one request
  • ✅ Follow clear workflow without guessing
  • ✅ Complete full economic analysis from start to finish

Fixes #11

🤖 Generated with Claude Code

Added comprehensive workflow guidance and missing features to enable
full policy reform analysis through the MCP interface.

Changes:
- Add search parameter to /parameters endpoint (filter by name/label/description)
- Add parameter_values support to policy creation
- Enhance PolicyCreate schema with detailed examples
- Add workflow documentation to policies, analysis, and datasets endpoints
- Include end-to-end workflow examples for policy reform analysis

These changes enable Claude to successfully:
1. Search for parameters (e.g., "basic_rate")
2. Create policies with parameter values in a single request
3. Run household impacts and economic analysis
4. Follow clear workflow guidance without trial and error

Fixes #11

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@nikhilwoodruff nikhilwoodruff merged commit 6baf48f into main Dec 18, 2025
1 check passed
@nikhilwoodruff nikhilwoodruff deleted the bot/issue-11 branch December 18, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve flow of the MCP and API

3 participants