fix(mcp): flag a partial available_authorities list in list_alerts (closes #24) - #25
Open
dchaudhari7177 wants to merge 1 commit into
Open
Conversation
/alerts has reported available_authorities_partial since jamiusaliu#9, so a caller cannot read a short authority list as proof an authority is invalid. The MCP tool built the same list from the same data and shipped no such flag, leaving the original false negative intact over MCP. That matters more here than over HTTP, as D14 argues: an HTTP caller reads the JSON and can see a partial: true beside a short list, while an MCP caller is a model that paraphrases -- and the paraphrase of an unqualified short list is 'there are no alerts for that authority', which is a stronger claim than the data supports. Populated from response.partial next to the list it qualifies, so the two surfaces cannot drift apart again. Left as None rather than False when there is no list, since a bare false would assert completeness about a list that was never built. Also names the field in the tool description=, which is the text a model reads when deciding how to interpret the result.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirrors #9's fix onto the MCP surface, as the issue describes.
What changed
ListAlertsResultgainsavailable_authorities_partial, populated from the sameresponse.partial/alertsuses, set on the line right after the list it qualifies so the two surfaces cannot drift apart again.Two decisions worth flagging
None, notFalse, when there is no list.available_authoritiesis only built for an unknown authority, so most responses have nothing to qualify. A barefalsethere would read as "the authority list is complete" — a claim about a list that was never built. The field isbool | Noneand tracks the list's own presence. Third test covers this.The description too. As the issue says, that text is what a model reads when deciding how to interpret the result, so it now names the field and says what to do with it:
The last sentence is deliberately imperative about the paraphrase rather than the JSON, since the paraphrase is where the false negative actually lands.
Tests
Four, using the
FakeAdapterpartial-fetch pattern fromtests/test_mcp_server.py:us-nwsasked for, its source timed out, so it cannot appear inavailable_authorities— the response now says the list is partial rather than implying the authority does not exist.Red before green — stashing only
src/alertmux/mcp_server.pyand re-running:Exactly the four new tests, nothing else.
Full suite:
435 passed, 2 failed. Both failures —test_gdacs.py::test_geometry_falls_back_to_bbox_polygon_when_no_pointandtest_tsunami.py::test_naive_updated_is_quarantined_rather_than_assuming_utc— reproduce on pristinemainat1ef609bwith this branch's two files stashed, so they are the local baseline and not from this change.One setup note: the tests need the
mcpextra, andmcp>=2,<3— themcp.server.mcpserver.MCPServerimport fails against 1.x withModuleNotFoundError: No module named 'mcp.server.mcpserver', which is easy to misread as a path problem.pip install -e ".[dev,mcp]"in a clean venv is what makestests/test_mcp_server.pycollect at all.