feat(mcp): fetch_url MCP tool — G2d (closes #62, completes #56)#94
Merged
Conversation
Wraps devagentic's ``fetchUrl(url, ctx_id?) -> JSON`` mutation as an MCP tool. Last G2 sub-issue — closes the #56 G2 parent roadmap. ## Implementation - ``plugins/devagentic-mutations/client.py::fetch_url(url, ctx_id=None)`` — thin GraphQL wrapper. - ``mcp_serve.py::_register_devagentic_mutation_tools`` — registers the ``fetch_url`` MCP tool. ## Devagentic-side constraints (surfaced through the wrapper) - **localhost-only**: URL must start with ``http://localhost`` or ``http://127.0.0.1``. Resolver raises ``ValueError`` otherwise. - **16K body cap**: bodies larger than 16K are truncated; response carries ``truncated: true``. - **Mock-shape integration**: ``DEVAGENTIC_MOCK_LOOKUP=true`` (env default) consults stored mock shapes before the network call; ``DEVAGENTIC_MOCK_CAPTURE=true`` (env default) memoizes 200 responses post-fetch. Tool surface unchanged — workers see ``mocked`` + optional ``mock_source_doc`` flags in the response. ## Tests - 5 new client-level tests in tests/plugins/devagentic-mutations/ test_client.py: empty-url fail-soft, happy-path round-trip, null-ctx_id wire shape, mock-lookup round-trip, non-dict response fail-soft. - Contract test in tests/test_mcp_defensive_registrars.py extended: ``fetch_url`` added to required-G2-tools set (now 15 named tools). - 195 total green across affected suites — no regression. ## #56 G2 parent closes with this ship | Sub-issue | Tool | Status | |---|---|---| | #60 G2b | assert_output | ✅ | | #61 G2c | read_artifact + preview_patch + patch_artifact | ✅ | | #62 G2d | fetch_url | ✅ this PR |
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.
Summary
Closes #62 (G2d, last G2 sub-issue) and completes the #56 G2 parent roadmap.
Wraps devagentic's
fetchUrl(url, ctx_id?) -> JSONmutation as an MCP tool. Workers can now perform localhost HTTP fetches through the devagentic graph (audited astool_callnodes, with mock-shape lookup + auto-capture per devagentic env knobs).Devagentic-side constraints (surfaced through the wrapper)
http://localhostorhttp://127.0.0.1. Resolver raisesValueErrorotherwise.truncated: true.DEVAGENTIC_MOCK_LOOKUP(env default true) checks stored mock shapes before the network call;DEVAGENTIC_MOCK_CAPTURE(env default true) memoizes 200 responses. Tool surface unchanged — workers seemocked+ optionalmock_source_docflags.Test plan
fetch_urladded to the required-G2 set (now 15 named tools)#56 G2 parent — fully closed with this ship
assert_outputread_artifact+preview_patch+patch_artifactfetch_urlI'll close #56 after this merges.