Repository navigation
Centralize single-text MCP response envelopes - #16750
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟢 Approval recommended
The shared MCP text-response refactor has no active review issues.
No open issues 🎉
What changed in this PR
Centralizes single-text MCP response construction in internal/mcpresult, addressing the duplication described in #16651 while retaining the existing compatibility helper.
Changes:
- Adds
NewTextResponseand delegatesBuildMCPTextResponseto it. - Reuses the builder for collaborator-permission and DIFC responses, preserving envelope metadata.
- Adds shape and text round-trip tests, plus DIFC normalization and re-unwrapping coverage.
| File | Description |
|---|---|
internal/mcpresult/text_response_test.go |
Tests envelope shape, normalization, and text round-trips. |
internal/mcpresult/mcpresult.go |
Adds the shared single-text response builder. |
internal/mcp/tool_result.go |
Retains the compatibility helper as a delegating wrapper. |
internal/githubhttp/collaborator.go |
Uses the shared builder for permission responses. |
internal/difc/path_collections.go |
Uses the builder to replace filtered envelope content. |
internal/difc/path_collections_test.go |
Checks normalized content and re-unwrapping of filtered responses. |
Review effort: Balanced (adaptive)
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Fixed in |
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
|
Three sites constructed the same MCP text envelope, with DIFC using a different slice representation.
mcpresult.NewTextResponse(text); retainmcp.BuildMCPTextResponseas a delegating compatibility wrapper.[]map[string]anyrepresentation while preserving envelope metadata and synchronized filtered text/structured content.