Description
[BUG] MCP tools connected but not exposed to agent
Description
MCP server pdfrag connects successfully and exposes 6 tools via tools/list, but the tools do not appear in the agent's available tool list. The server is working correctly (responds to MCP protocol, tools are valid), but something in the opencode pipeline isn't passing those tools to the agent.
Steps to Reproduce
- Create a custom MCP server (Python, stdio transport)
- Register in
~/.config/opencode/opencode.json:
"mcp": {
"pdfrag": {
"type": "local",
"command": "/Library/Frameworks/Python.framework/Versions/3.14/bin/pdfrag-mcp"
}
}
- Run
opencode mcp list → shows "connected" with green checkmark
- Start opencode session → tools NOT available to agent
Expected Behavior
MCP tools should be available as first-class tools in the agent session after successful connection.
Actual Behavior
- Server connects successfully
opencode mcp list shows "connected"
- MCP protocol handshake works (initialize, tools/list returns 6 valid tools)
- Tools do NOT appear in agent's available tool list
- Agent cannot call MCP tools
Investigation
- Server works correctly: Verified with Python MCP client - server responds to
initialize, tools/list, and tool calls
- Server format matches working servers: Compared with
token-optimizer and lean-ctx servers - same structure, capabilities, and tool definitions
- No error logs: opencode logs show no errors related to pdfrag
- opencode binary is compiled: Cannot inspect source directly, but binary analysis shows MCP tool registration code exists
Similar Issue
Found similar issue on hermes-agent: #41625 - "MCP tools discovered but not exposed to agent in TUI mode"
The suspected cause there is a race condition in the TUI startup path with a timeout that's too short for MCP discovery.
Environment
- OpenCode version: 1.17.8
- OS: macOS (darwin)
- Python: 3.14
- MCP transport: stdio (local subprocess)
Workaround
Use CLI or Python direct calls:
python3 pdf_rag.py query "question"
Request
Please investigate why MCP tools are not being exposed to the agent despite successful connection. This may be related to:
- Race condition in tool discovery (similar to hermes-agent #41625)
- Tool filtering logic
- Agent tool context initialization
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
[BUG] MCP tools connected but not exposed to agent
Description
MCP server
pdfragconnects successfully and exposes 6 tools viatools/list, but the tools do not appear in the agent's available tool list. The server is working correctly (responds to MCP protocol, tools are valid), but something in the opencode pipeline isn't passing those tools to the agent.Steps to Reproduce
~/.config/opencode/opencode.json:opencode mcp list→ shows "connected" with green checkmarkExpected Behavior
MCP tools should be available as first-class tools in the agent session after successful connection.
Actual Behavior
opencode mcp listshows "connected"Investigation
initialize,tools/list, and tool callstoken-optimizerandlean-ctxservers - same structure, capabilities, and tool definitionsSimilar Issue
Found similar issue on hermes-agent: #41625 - "MCP tools discovered but not exposed to agent in TUI mode"
The suspected cause there is a race condition in the TUI startup path with a timeout that's too short for MCP discovery.
Environment
Workaround
Use CLI or Python direct calls:
python3 pdf_rag.py query "question"Request
Please investigate why MCP tools are not being exposed to the agent despite successful connection. This may be related to:
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response