feat: ability to toggle MCP Servers in TUI#4509
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an MCP (Model Context Protocol) management UI accessible via the /mcp command, allowing users to enable/disable MCP servers on a session level rather than having all configured MCPs enabled by default.
- Adds new API endpoints for connecting and disconnecting MCP servers dynamically
- Implements a new TUI dialog component for managing MCP server states
- Updates the MCP status logic to distinguish between disabled, connected, and failed states
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/js/src/gen/types.gen.ts | Adds TypeScript type definitions for new MCP connect/disconnect API endpoints |
| packages/sdk/js/src/gen/sdk.gen.ts | Adds SDK client methods for MCP connect and disconnect operations |
| packages/opencode/src/server/server.ts | Implements POST endpoints for /mcp/:name/connect and /mcp/:name/disconnect |
| packages/opencode/src/mcp/index.ts | Adds connect/disconnect functions and updates status/tools logic to handle disabled MCPs |
| packages/opencode/src/cli/cmd/tui/routes/home.tsx | Updates MCP server count display to only show connected servers |
| packages/opencode/src/cli/cmd/tui/context/local.tsx | Adds MCP toggle functionality and model list helper to local context |
| packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx | Separates /mcp command from /status command aliases |
| packages/opencode/src/cli/cmd/tui/component/dialog-mcp.tsx | New dialog component for managing MCP server connections with toggle functionality |
| packages/opencode/src/cli/cmd/tui/app.tsx | Registers the new MCP dialog command handler |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This is beautiful, really needed. Another thing, sometimes the agent is not familiar with the mcp servers it has available, I created a |
|
This is awesome! I was actually planning to request this feature too. It will really help to manage MCPs from the UI for each session. Nice to see someone already raised a PR for it. I’m interested in this feature and hope it gets merged soon. @rekram1-node is this feature going to be added in the next release? |
f1dc981 to
3e15a39
Compare
df8bdf9 to
0dd5039
Compare
|
Yeah this one looked pretty good, can we resolve the conflicts please? |
|
@rekram1-node fixed 👍 |
Looks like there are conflicts again. Can you please resolve them when you get a chance? |
|
conflicts fixed |
Thanks, One question the toggle works on Space right now. Would it be better to use Enter to enable or disable an MCP instead of Space? |
Space is mostly considered as an operation to "toggle" things. IMO, space is better. |
|
@rekram1-node Would really appreciate getting this merged! Managing multiple MCPs gets messy, and this toggle feature would be super helpful for reducing context bloat and improve startup time. Would be great to have this in the next release. Thanks! 🙏 |
|
yeah we will merge dw |
f8ee907 to
6a9856d
Compare
|
That's awesome, I was just looking for this. |
|
Alright @dbpolito can you resolve the conflicts and then ill merge? |
|
I can't believe I commented two weeks ago, I thought I did that just a few days ago oof |
- Merged upstream/dev into mcp_tui branch - Resolved conflicts in: - packages/opencode/src/cli/cmd/tui/app.tsx: Combined useConnected import with DialogMcp - packages/opencode/src/server/server.ts: Kept both MCP connect/disconnect endpoints and new OAuth auth endpoints - packages/sdk/js/src/gen/sdk.gen.ts: Added all MCP SDK methods (connect, disconnect, and OAuth auth) - packages/sdk/js/src/gen/types.gen.ts: Added all MCP TypeScript type definitions - All merge conflicts resolved successfully
|
@rekram1-node hey, updated the PR... it seems format and sdk actions are conflicting with each other... i ran their scripts locally but or one or another fails... |
|
Don't worry about them they suck, Dax will fix it |
|
/review |
|
lgtm |
|
Wow this is good work |
Related to #514
This introduces a new command
/mcpwhich you can manage MCPs on session level, makes it possible to have MCPs disabled by default and only enabling it when you want, for example my default i have github disabled and playwright enabled