feat: agent abstraction & MCP config generation#2
Conversation
Introduce first-class agent support so dotagents can generate tool-specific MCP config files and skills symlinks for Claude Code, Cursor, Codex, VS Code Copilot, and OpenCode. New `agents` and `[[mcp]]` fields in agents.toml let users declare which AI tools they use and which MCP servers to configure. During install/sync, dotagents translates universal MCP declarations into each tool's expected format and writes the config files automatically.
mergeWrite was doing `existing[rootKey] = servers` which would wipe any user-configured servers in shared config files (codex, opencode). Now spreads existing servers first so user additions are preserved. Adds regression test with a pre-populated opencode.json.
- Deduplicate serializeCodex (was copy-paste of serializeClaude, now alias) - Extract toMcpDeclarations() helper to eliminate duplicate mapping in install.ts and sync.ts - Fix early return in runInstall that skipped agent symlinks and MCP config generation when no skills were declared — agents + MCP should work independently of skills - Add regression test for MCP-only install (no skills)
Agents like claude and opencode share `.claude` as their skillsParentDir. Track processed dirs in a Set to avoid duplicate symlink operations and inflated repair counts. Also extract envRecord results into locals to avoid redundant double invocations in serializers.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| if (s.url) { | ||
| return [s.name, { type: "sse", url: s.url, ...(s.headers && { headers: s.headers }) }]; | ||
| } | ||
| const env = envRecord(s.env, (k) => `\${input:${k}}`); |
There was a problem hiding this comment.
VS Code env vars use wrong substitution syntax
High Severity
The VS Code serializer generates ${input:KEY} references for environment variables, but this pattern requires a corresponding inputs array in the mcp.json file that is never generated. The freshWrite function only outputs { "servers": {...} } with no inputs section, and since VS Code's config is shared: false, the file is overwritten entirely on each run. VS Code cannot resolve ${input:...} references without the inputs definitions, so MCP servers with env vars will fail to start. The intent here is to reference system environment variables, for which VS Code uses ${env:KEY} syntax (no inputs section needed).


Summary
agents = ["claude", "cursor"]in agents.toml) so dotagents knows which AI tools consume skills[[mcp]]declarations in agents.toml for universal MCP server configinstallandsync, generates tool-specific MCP config files (.mcp.json,.cursor/mcp.json,.codex/config.toml,.vscode/mcp.json,opencode.json) with each tool's expected format.claude/skills/ → .agents/skills/)init --agents claude,cursorscaffolds the config with agents pre-populatedagents/mcpfields still parseSupported agents
claude.mcp.jsoncursor.cursor/mcp.jsoncodex.codex/config.tomlvscode.vscode/mcp.jsonopencodeopencode.jsonExample agents.toml
New files
src/agents/types.ts— interfacessrc/agents/registry.ts— agent registry with per-tool serializerssrc/agents/mcp-writer.ts— config file generation (JSON/TOML, shared/dedicated)src/agents/index.ts— re-exportsTest plan
--agentsflag, symlink creation, unknown ID rejection — 3 testspnpm checkpasses (lint + typecheck + 185 tests)