Skip to content

fix: persist MCP toggle changes to opencode.json - #17833

Closed
LehaoLin wants to merge 2 commits into
anomalyco:devfrom
LehaoLin:fix/mcp-toggle-persist
Closed

LehaoLin wants to merge 2 commits into
anomalyco:devfrom
LehaoLin:fix/mcp-toggle-persist

Conversation

@LehaoLin

Copy link
Copy Markdown

Issue for this PR

Closes #17799

Type of change

  • Bug fix

What does this PR do?

Problem: Using /mcp command to enable/disable MCP servers doesn't persist changes to opencode.json. The toggle works in UI but changes are lost after restart.

Root Cause: The connect() and disconnect() functions in packages/opencode/src/mcp/index.ts only update runtime state but don't save to config file.

Solution:

  • Call Config.update() in both connect() and disconnect() to persist the enabled state
  • Changes are now saved to opencode.json and survive restarts

How did you verify your code works?

  • Verified Config.update() is called with correct enabled state
  • Verified changes follow existing patterns in codebase
  • Code compiles without errors
  • Minimal change (13 lines added)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

LehaoLin added 2 commits March 17, 2026 01:31
- Save enabled state when connecting/disconnecting MCP servers
- Fixes issue where /mcp toggle doesn't persist after restart
- Config.update() called in both connect() and disconnect()

Fixes anomalyco#17799
- Fix TypeScript error TS2304
- Use Config.Mcp type consistently with rest of file

Fixes anomalyco#17799
@ariane-emory

Copy link
Copy Markdown
Contributor

opencode.json is a config file, not a state file and should not be modified surreptitiously by toggling states in the UI.

@nesl247

nesl247 commented Mar 17, 2026

Copy link
Copy Markdown

Fully agree. This would completely break my workflow. I keep all MCP servers disabled until needed because Opencode doesn't support tool search, so it bloats my context window a lot.

@rekram1-node

Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

Bug: /mcp toggling doesn't persist changes to opencode.json

4 participants