Fix OpenCode MCP server integration - Enable safe-outputs and GitHub tools #2167
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.
Problem
The smoke-opencode workflow was experiencing a 100% failure rate because OpenCode agents couldn't access configured MCP tools (safe-outputs, github, etc.). The root cause was a configuration format mismatch:
/tmp/gh-aw/mcp-config/mcp-servers.json~/.config/opencode/opencode.jsonin its own formatEvidence from audit logs showed:
The agent was instructed to "use the create-issue tool from the safe-outputs MCP" but had no access to it.
Solution
This PR adds automatic MCP configuration transformation for OpenCode workflows by modifying
.github/workflows/shared/opencode.md:$GH_AW_MCP_CONFIG~/.config/opencode/opencode.jsonFormat Transformation
Local (stdio) MCP servers:
Remote (HTTP) MCP servers:
Benefits
Testing
make test-unitmake lintmake agent-finishgh aw compile smoke-opencodeSecurity
${{ secrets.* }}) preserved during transformationFixes #2143
Original prompt
This section details on the original issue you should resolve
<issue_title>[q] Fix OpenCode MCP server integration - Enable safe-outputs tools</issue_title>
<issue_description># Q Workflow Optimization Report
Issues Found (from live data)
smoke-opencode Workflow
Log Analysis: Analyzed 4 consecutive failed runs of the smoke-opencode workflow
Run IDs Analyzed: 18722224746, 18715612738, 18725510532, 18706992084
Pattern: 100% failure rate - all runs completed successfully but failed to create expected outputs
Issues Identified:
opencode.jsonfile created despite MCP servers being configured in workflowcreate_issuetool from safe-outputs MCPEvidence from logs (Run githubnext/gh-aw#18722224746):
The agent was instructed in the prompt: "To create an issue, use the create-issue tool from the safe-outputs MCP" but had no access to this tool.
Root Cause Analysis
Technical Problem
OpenCode requires MCP servers to be configured in
~/.config/opencode/opencode.json:{ "$schema": "(redacted)", "mcp": { "server-name": { "type": "local", "command": ["npx", "mcp-server"], "enabled": true } } }Current Implementation (Broken):
Comparison with GenAIScript (Working):
--mcp-configCLI parameterChanges Made
.github/workflows/shared/opencode.md1. Added jq Installation (Step renamed to "Install OpenCode and jq"):
Required for JSON transformation between Copilot and OpenCode MCP config formats.
2. Added MCP Configuration Step (New step before "Run OpenCode"):
Key Features:
3. Updated Documentation (HTML comment section):
Expected Improvements
Immediate Benefits
create_issuetool will be available to OpenCode agentFixes #2164
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.