Repository navigation
fix(mcp): preserve empty HTTP resource queries - #299
Conversation
## Problem The resource URI normalizer removes an empty HTTP or HTTPS query. That can change the address selected by resources/read from /report? to /report. A server can return different content for those addresses. ## Solution Preserve empty HTTP and HTTPS queries in the canonical policy input and forwarded resource frame. Keep the file URI delimiter handling from #229. Correct the resource-address explanation in docs/design/mcp.md. Exact URI literals distinguish the two forms; patterns can cover both. ## Tests an_empty_http_query_is_preserved and an_empty_http_query_reaches_the_decision_and_forwarded_frame fail against unchanged production code and pass with this fix. They check normalized values, both request classifiers, and forwarded frames. file_delimiters_fold_without_merging_http_queries retains file controls and checks HTTP query identity. Restoring the old filter makes it fail. On Amazon Linux 2023 ARM64, just check passed with 4,886 tests passed and 17 ignored. Workspace Clippy used the repository's vendored-code lint allowances. All 244 gateway tests passed, as did both feature builds, strict gateway Clippy, formatting, and the gateway documentation build. The deterministic suite passed 131 cases with nine declared macOS-only skips and no failures or errors. The example command built binaries; no scripted examples remain. No live MCP server, manual SDK tutorial, or macOS run was performed locally. The prose checker reports 15 existing em-dash lines identical to the base. Independent documentation review found no new prose issue.
|
Assessment: Comment The change works for MCP servers that resolve the URI themselves. Policy input, the forwarded frame, and the canonical form stay consistent with each other. But the gateway's HTTP egress still folds an empty query, so the identity this PR keeps separate gets merged again when an in-box server fetches the resource (see the inline comment). Checked and held
The regression coverage across both classification paths and the forwarded frame is thorough. |
|
The empty-query handling has now changed twice: the launch version kept The HTTP part reopens the issue #229 closed. With Can the MCP layer and the gateway agree on what an empty query means before this merges? One option is to keep the fold from #229. The other is to merge this together with a gateway change that keeps the AI-assisted comment |
Preserve an explicitly empty query through plain HTTP and intercepted HTTPS without changing public request types. Add policy-to-origin regression tests for exact URI forbids and retain complete MCP frames. Merge main and resolve the MCP normalization documentation conflict.
|
Assessment: Approve (re-review at f56ffe3) The MCP layer and the gateway now agree: an empty HTTP/HTTPS query is kept as its own identity at every stage. That covers policy input, the forwarded frame, and the origin request target. This answers both the earlier gateway finding and @abhisheksp's request for an admission test of Checked and held
The end-to-end test builds the fetch target from the frame the MCP server actually received, which is the right thing to anchor on. |
|
. |
|
Addressed in f56ffe3. This PR now includes the gateway correction: a permitted read of Four integration tests cover forbidding Could you take another look? AI-assisted comment |
|
With this PR,
The PR's own tests confirm this. The read of |
|
You’re right that the rule no longer blocks That’s why this PR keeps the AI-assisted comment |
Human readable section
Problem. Strands Box removes a final
?from an HTTP or HTTPS resource address. For example,https://example.com/report?becomeshttps://example.com/report. The two addresses can return different content. This changes the address that policy checks and that the Model Context Protocol (MCP) server receives. Box's HTTP gateway also removes an empty query when the resource server fetches that address.Solution. Preserve an empty HTTP or HTTPS query through both operations: the MCP resource read and the server's later fetch through the gateway. Policy and the MCP server receive the same resource address. The destination HTTP server (web origin) receives the corresponding path and query, called the request target.
Trade-off. Exact resource rules distinguish addresses with and without
?. Each operation still requires its applicable policy checks. Empty queries onfile:addresses remain removed, preserving the repair in #229.Description
An address ending in
?has an empty query. An address without?has no query. RFC 3986 section 6.2.3 says these forms cannot be assumed equivalent.For an application requesting
https://example.com/report?through an MCP server that fetches the same address:https://example.com/reporthttps://example.com/report?https://example.com/reporthttps://example.com/report?/report/report?Figure 1: Box preserves an empty query through the resource-read message and the later HTTP fetch. Each operation requires a separate policy permit. The MCP labels abbreviate the full resource address to its path and query.
Download the editable draw.io source.
Gateway correction
The gateway now remembers whether the original request had an empty query before splitting its path and query. Both plain HTTP and intercepted HTTPS retain that distinction when constructing the forwarded request. This uses private state; public request types and policy attributes are unchanged.
A configured credential can modify query parameters before the gateway forwards a request. These edits retain their existing behavior. Adding a query parameter produces the usual
?name=value; removing the last parameter from an originally nonempty query removes its delimiter. A rewritten path that already contains a query does not receive another?.This addresses Abhishek's review. With a broad server permit and an exact forbid for
https://example.com/report, that address is denied before server delivery. A permittedhttps://example.com/report?reaches the origin as/report?. The inverse forbid is also tested.Related Issues
Follow-up to #229 and its empty-query review comment.
Type of Change
Bug fix
Testing
Local validation covers the final source tree, including the merge of
mainat4268891.GREEN: 131 cases pass, 10 declared macOS cases are skipped on Linux, and all 141 expected records are present. The runner reportscoverage_gate=full.Local Box tests used a private mount view because the unchanged mount parser rejects this host's Docker network-namespace handle. Tests ran as the original unprivileged user with no effective capabilities. The host mount table remained unchanged.
The first containment attempt exhausted disk space while creating fixtures. The successful rerun used copies of the same binaries with debug symbols removed. All loaded code and data sections and entry points were verified unchanged.
Coverage limits: the workspace run skipped an unavailable credential-daemon check and a Linux check that cannot independently deny reading an executable grant. Existing ignored tests remain ignored. The example build passed, but no scripted examples are present; the manual SDK tutorial was not run. GitHub checks for the updated commit are tracked separately below.
Updated commit:
f56ffe3. GitHub checks passed, including Linux ARM64 and macOS unit tests and deterministic containment. The automated re-review completed on this commit with no new findings. Its assessment is "Approve," but its formal GitHub review isCOMMENTED; human approval remains pending. Hosted results are separate from the local pass counts above.The diagram passed structural checks and visual inspection.
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.