Skip to content

Agent MCP server toggle is saved but not honored by agent launches #446

Description

@glowforgedan

Summary

The Settings UI exposes an Agent MCP server toggle (codingCli.mcpServer), described as controlling whether Freshell is exposed as an MCP tool to coding agents. The setting is persisted, but new coding-agent launches still inject Freshell MCP config unconditionally.

This is not about MCP being enabled by default. Default-on appears intentional. The bug is that switching the toggle off does not affect subsequent launches.

Evidence

  • codingCli.mcpServer exists in settings and defaults to true.
    • shared/settings.ts
  • The Settings UI writes the toggle through applyServerSetting({ codingCli: { mcpServer: checked } }).
    • src/components/settings/AdvancedSettings.tsx
  • Terminal launches read provider-specific defaults from cfg.settings.codingCli.providers[...], but do not pass the global codingCli.mcpServer setting into the spawn path.
    • server/ws-handler.ts
  • providerNotificationArgs(...) calls generateMcpInjection(...) unconditionally for coding CLI terminal modes.
    • server/terminal-registry.ts
  • generateMcpInjection(...) injects Freshell MCP config for Claude, Codex, Gemini, Kimi, and OpenCode.
    • server/mcp/config-writer.ts
  • The Claude SDK/fresh-agent path also currently builds mcpServers: createClaudeSdkMcpServers(...) without an obvious gate for codingCli.mcpServer.
    • server/sdk-bridge.ts

Expected behavior

When codingCli.mcpServer === false, newly launched coding-agent sessions should not receive Freshell MCP injection.

Existing running agents do not need to be mutated; a new setting should apply to new launches.

Actual behavior

The setting is persisted, but new agent launches still receive Freshell MCP injection.

Scope notes

This should only govern Freshell's own injected freshell MCP server. It should not attempt to manage unrelated external MCP servers configured globally by Claude, Codex, OpenCode, etc. For example, a third-party MCP like Railway belongs to user/global agent config and should be handled separately.

Suggested acceptance criteria

  • With the toggle on or unset, current behavior remains unchanged.
  • With the toggle off, new Claude/Codex/Gemini/Kimi/OpenCode terminal panes omit Freshell MCP config.
  • With the toggle off, Fresh Agent / SDK launch paths also omit Freshell MCP where applicable.
  • Existing turn-completion notification plumbing remains intact, such as Codex TUI notification flags and Claude stop-hook bell settings.
  • Add focused tests proving the toggle gates MCP injection while preserving notification behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions