Skip to content

feat(mcp): let agents manage AndCode settings and MCP servers - #444

Open
yuga-hashimoto wants to merge 1 commit into
mainfrom
feat/agent-settings-mcp
Open

yuga-hashimoto wants to merge 1 commit into
mainfrom
feat/agent-settings-mcp

Conversation

@yuga-hashimoto

Copy link
Copy Markdown
Owner

Summary

Adds a built-in and-code-settings MCP server provisioned by default for all guest agents (OpenCode, Claude Code, Antigravity) so users can ask any agent to inspect/change AndCode app settings or manage MCP servers across agents.

What's included

  • Guest MCP server (app/src/main/assets/scripts/andcode-settings-mcp.py, stdlib-only Python):
    • App settings tools: settings_list, settings_get, settings_set, settings_set_many, settings_reset, settings_update_list
    • Cross-agent MCP management tools: mcp_servers_list, mcp_server_add, mcp_server_remove
  • Settings catalog & validation (AgentSettingsCatalog.kt):
    • Declarative schema covering model, appearance, chat, sessions, runtime, voice, and security categories with types, options, ranges, defaults, and coercion.
    • Security-sensitive toggles (autoAcceptPermissions, guestBrowserAgentControlEnabled, analyticsEnabled) and wakeWordEnabled (requires Android mic permission/service flow) are exposed as read-only (writable: false) with an explanatory reason.
    • API keys (ttsOpenAiApiKey, ttsElevenLabsApiKey) are write-only and redacted on read (isSet only).
  • App-side file bridge (AgentSettingsBridge.kt, wired in AndCodeApplication.kt):
    • Uses the same /workspace/.and-code/settings-bridge file-bridge pattern, foreground/runtimeWork polling gate, atomic writes, and 95s request expiry as ScheduleBridge.
    • Writes through AppPreferencesRepository so UI flows update live. settings_set_many validates all entries before applying any.
  • Cross-agent MCP config store (AgentMcpConfig.kt):
    • Reads/writes OpenCode (opencode.json), Claude Code (.claude.json), and Antigravity (mcp_config.json) across all guest rootfs directories with each agent's expected schema.
    • Protects built-in and-code-* servers from replacement/removal, pre-validates target JSON files to avoid partial writes, and never echoes env values or headers.
  • Provisioning (LocalRuntimeInstaller.kt):
    • Installs andcode-settings-mcp.py into /usr/local/bin and registers and-code-settings for fresh and existing installs; deduplicates built-in MCP provisioning helper.
  • Tests & Docs:
    • Unit tests in AgentSettingsCatalogTest, AgentSettingsBridgeTest, and AgentMcpConfigTest (32 tests).
    • Updated docs/LOCAL_RUNTIME.md and README.md.

Pre-PR Review Report

  • Reviewer: repo-reviewer (research subagent)
  • Initial Verdict: REQUEST_CHANGES (2 blocking findings in AgentMcpConfig: command = []/[""] combined with url, and missing agents validation in remove).
  • Fixes Applied: Fixed both blocking issues, added all-or-nothing JSON pre-validation in AgentMcpConfig.add, trimmed remove entries in AgentSettingsBridge.updateList, wrapped line 154 in andcode-settings-mcp.py, and added unit test coverage for all cases.
  • Final Verdict: APPROVE

Verification

  • ktlint (1.2.1 with repo .editorconfig): pass
  • detekt (1.23.6 with repo detekt.yml on all new files): 0 issues
  • Kotlin unit tests (AgentSettingsCatalogTest, AgentSettingsBridgeTest, AgentMcpConfigTest): 32/32 pass
  • Python MCP server protocol integration test (initialize, tools/list, tools/call across settings/MCP/error paths): pass

@yuga-hashimoto yuga-hashimoto added the build-apk Build and comment the Android debug APK label Nov 25, 2026
@yuga-hashimoto
yuga-hashimoto force-pushed the feat/agent-settings-mcp branch from 96c7ec9 to 5d745ea Compare November 25, 2026 11:35
@yuga-hashimoto yuga-hashimoto added build-apk Build and comment the Android debug APK and removed build-apk Build and comment the Android debug APK labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Debug APK built successfully

Download APK artifact
View workflow run

Commit: eb5340d59802 | Artifact expires in 14 days.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-apk Build and comment the Android debug APK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant