fix(proxy): methods not conforming to schemas#48
fix(proxy): methods not conforming to schemas#48romanr wants to merge 5 commits intolynnswap:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR ensures tools/call responses actually conform to the schemas advertised via tools/list, preventing MCP clients from rejecting successful tool calls (notably XcodeListWindows, DocumentationSearch, and GetBuildLog).
Changes:
- Add response rewriting for
tools/callto populateresult.structuredContentby parsing JSON-stringcontent[].textwhen the tool advertises anoutputSchema. - Normalize
GetBuildLogstructuredContentsoemittedIssues[].lineis always present (filled with0when missing). - Add regression tests covering the schema rewrite in
tools/listand the structured-content fixes intools/call.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Tests/ProxyHTTPTransportTests/HTTPHandlerTests.swift | Adds tests validating outputSchema rewriting and structuredContent normalization behavior. |
| Sources/ProxyHTTPTransport/MCPForwardingService.swift | Implements tools/call response normalization to match advertised outputSchema, including GetBuildLog fixes. |
| Sources/ProxyFeatureXcode/RefreshCodeIssuesToolsListRewriter.swift | Adds a proxy-mode outputSchema for XcodeRefreshCodeIssuesInFile to match proxy-produced outputs. |
| Sources/ProxyCore/RequestInspector.swift | Captures toolName for tools/call to enable targeted response rewriting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot open a new pull request to apply changes based on the comments in this thread |
There was a problem hiding this comment.
Pull request overview
This PR fixes proxy tools/call responses to better conform to advertised tool outputSchemas, preventing MCP clients from rejecting otherwise successful upstream Xcode tool calls.
Changes:
- Populate
result.structuredContentfor schema-backed tools by parsing JSON embedded inresult.content[].text(when missing). - Normalize
GetBuildLogstructured results by filling missingemittedIssues[].linevalues. - Extend tools/list rewriting to advertise a proxy
outputSchemafor refresh-code-issues, and add regression tests for the new behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Tests/ProxyHTTPTransportTests/HTTPHandlerTests.swift | Adds/updates tests covering tools/list schema rewriting and tools/call structuredContent normalization. |
| Sources/ProxyHTTPTransport/MCPForwardingService.swift | Rewrites successful tools/call responses for schema-backed tools to ensure structuredContent exists and normalizes GetBuildLog entries. |
| Sources/ProxyFeatureXcode/RefreshCodeIssuesToolsListRewriter.swift | Adds a proxy-mode outputSchema for the refresh-code-issues tool in tools/list responses. |
| Sources/ProxyCore/RequestInspector.swift | Captures toolName for tools/call requests so response rewriting can be tool-specific. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| for issue in emittedIssues { | ||
| guard issue["line"] == nil else { | ||
| normalizedIssues.append(issue) | ||
| continue | ||
| } | ||
|
|
||
| var normalizedIssue = issue | ||
| normalizedIssue["line"] = 0 | ||
| normalizedIssues.append(normalizedIssue) |
| if structuredContent is [String: Any] || structuredContent is [Any] { | ||
| return structuredContent | ||
| } |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
The proxy exposed valid tool schemas via
tools/list, but some upstream tool responses did not actually conform to those schemas. This caused MCP clients to reject otherwise successful Xcode tool calls, includingXcodeListWindows,DocumentationSearch, andGetBuildLog.tools/callresponses so tools that advertised anoutputSchemareturn validresult.structuredContentinstead of only JSON wrapped incontent[].text.GetBuildLogresponses by filling missingemittedIssues[].linevalues so the returned structured content matches the advertised schema.GetBuildLogschema fix.