Skip to content

fix(proxy): methods not conforming to schemas#48

Open
romanr wants to merge 5 commits intolynnswap:mainfrom
romanr:main
Open

fix(proxy): methods not conforming to schemas#48
romanr wants to merge 5 commits intolynnswap:mainfrom
romanr:main

Conversation

@romanr
Copy link
Copy Markdown

@romanr romanr commented Mar 19, 2026

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, including XcodeListWindows, DocumentationSearch, and GetBuildLog.

  • Fixed schema-backed tools/call responses so tools that advertised an outputSchema return valid result.structuredContent instead of only JSON wrapped in content[].text.
  • Fixed GetBuildLog responses by filling missing emittedIssues[].line values so the returned structured content matches the advertised schema.
  • Added regression coverage for text-only output and GetBuildLog schema fix.

Copilot AI review requested due to automatic review settings March 19, 2026 17:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/call to populate result.structuredContent by parsing JSON-string content[].text when the tool advertises an outputSchema.
  • Normalize GetBuildLog structuredContent so emittedIssues[].line is always present (filled with 0 when missing).
  • Add regression tests covering the schema rewrite in tools/list and the structured-content fixes in tools/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>
@romanr
Copy link
Copy Markdown
Author

romanr commented Mar 19, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.structuredContent for schema-backed tools by parsing JSON embedded in result.content[].text (when missing).
  • Normalize GetBuildLog structured results by filling missing emittedIssues[].line values.
  • Extend tools/list rewriting to advertise a proxy outputSchema for 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.

Comment on lines +591 to +599
for issue in emittedIssues {
guard issue["line"] == nil else {
normalizedIssues.append(issue)
continue
}

var normalizedIssue = issue
normalizedIssue["line"] = 0
normalizedIssues.append(normalizedIssue)
Comment on lines +521 to +523
if structuredContent is [String: Any] || structuredContent is [Any] {
return structuredContent
}
@romanr
Copy link
Copy Markdown
Author

romanr commented Mar 22, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants