Skip to content

feat: render MCP servers declared once in the source - #268

Merged
furedea merged 20 commits into
mainfrom
feat/render-mcp-servers
Nov 29, 2026
Merged

furedea merged 20 commits into
mainfrom
feat/render-mcp-servers

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

MCP サーバーをソースの mcp_servers.json(と Home Manager の mcpServers)に 1 回だけ宣言し,MCP クライアントを持つすべてのプロバイダ(Claude Code,Codex,Devin,Hermes,Antigravity)のネイティブな場所へ生成する.
Claude Code は ~/.claude.json ではなく,Claude Code 自身が書き換えない skills-directory plugin に生成するので,activation 時の書き込み競合がなくなる.ほかのプロバイダでは,ユーザーや各 CLI が追加したサーバーを sidecar で区別して残す.
判断点:Pi と dsh には生成しないこと(理由は下記),Devin と Antigravity の同期で mcp_config.json がない場合は作ること.

flowchart LR
  SRC["source: mcp_servers.json"] --> MERGE{"名前単位で上書き"}
  HM["HM: programs.agent-harness.mcpServers"] --> MERGE
  MERGE --> CC["~/.claude/skills/agent-harness/.claude-plugin/plugin.json<br/>(Claude Code は読むだけ)"]
  MERGE --> CX["~/.codex/config.toml の [mcp_servers.*]"]
  MERGE --> HE["~/.hermes/config.yaml の mcp_servers"]
  MERGE --> DV["~/.config/devin/mcp_config.json の mcpServers"]
  MERGE --> AG["~/.gemini/config/mcp_config.json の mcpServers"]
  USER["claude / codex / devin mcp add,Antigravity の MCP マネージャー"] -.残る.-> KEEP["同じファイルの他のエントリ"]
Loading

使い方

ソース(agent-config など)の mcp_servers.json:

{
  "servers": {
    "github": {
      "command": "github-mcp-server",
      "args": ["stdio"],
      "env": { "GITHUB_TOOLSETS": "repos,issues" }
    },
    "docs": { "url": "https://docs.example.com/mcp" }
  }
}
  • サーバーは command(任意で args,env)か url(streamable HTTP)のどちらか一方.未知のフィールド,両方/どちらもなし,http(s):// 以外の URL,[A-Za-z0-9_-] 以外の名前はファイル名とサーバー名付きのエラー.
  • ホスト固有の値(Nix ストアのパスなど)は Home Manager で上書き・追加する.同名のエントリはソース側を丸ごと置き換える:
programs.agent-harness.mcpServers.github = {
  command = "${pkgs.github-mcp-server}/bin/github-mcp-server";
  args = [ "stdio" ];
};
  • 認証情報は書かない.サーバー自身が環境変数から読むか,command をキーチェーンなどから取り出して exec するラッパーにする.
  • Home Manager を使わない場合は,ホームへの agent-harness install が Codex,Devin,Antigravity のファイルへ直接マージし,記録用の .agent-harness-managed.json も配置する.Home Manager では activation が sync-config --provider <id> --file mcp-servers を実行する.

プロバイダごとの生成先

プロバイダ 生成先 リモートサーバーの書き方 自分で追加したサーバー
Claude Code ~/.claude/skills/agent-harness/.claude-plugin/plugin.json type: "http",url ~/.claude.json に残る(harness は触れない)
Codex ~/.codex/config.toml の [mcp_servers.<name>] url 残る(sidecar で追跡)
Devin ~/.config/devin/mcp_config.json の mcpServers url,transport: "http" 残る(sidecar で追跡)
Hermes ~/.hermes/config.yaml の mcp_servers url 残る(sidecar で追跡)
Antigravity ~/.gemini/config/mcp_config.json の mcpServers serverUrl 残る(sidecar で追跡)
Pi 生成しない - -
dsh 生成しない - -
  • Pi:MCP クライアントを持たない.pi-mcp-adapter などの拡張はあるが,agent-harness がインストールするものには含まれない.
  • dsh:MCP は別パッケージの @deepseek-ai/dsh-mcp-client プラグイン経由のみ.各プロファイルが dsh のバージョンに合わせて自分でインストールするもので,agent-harness は入れない.入っていないプラグインを参照する行を harness のバンドルに書くとプロファイルが壊れ得る.書式も公式ドキュメントでは確認できなかった.

変更前後

項目 変更前 変更後
Claude Code 生成なし(利用側が ~/.claude.json へ jq マージ) skills-directory plugin を生成
Codex / Hermes 生成なし(同期対象外) 既存の同期対象ファイルの中で sidecar で追跡して同期
Devin / Antigravity 生成なし 専用ファイルを 2 つ目の ConfigSpec(McpSpec::ConfigFile)として生成・同期
sync-config プロバイダごとに 1 ファイル --file mcp-servers で専用ファイルを同期(既定は従来どおり config)
nix/providers.json sync のみ mcp_sync を追加し,HM が agentHarness{Devin,Antigravity}McpServers を実行
generate-skills --provider claude / codex(描画形式) プロバイダ ID(claude,codex,pi,dsh,antigravity).従来の 2 値はそのまま動く
MCP の宣言 - ProviderSpec::mcp: Option<McpSpec>(hook と同じ形)に 1 回だけ書く.config の同期は InConfig から追跡とキー所有からの除外を導出する
nix/providers.json のリンク skills_provider(描画形式) skills_directory: true(HM はそのプロバイダ自身の ID で generate-skills を呼ぶ)
TOML 同期で作る中間テーブル 空の [parent] ヘッダーが出る implicit(子テーブルだけ出る)

宣言の形

hook と同じく,すべてのプロバイダが 1 つの mcp フィールドで MCP を宣言する.None はサーバーを生成しない(Pi,dsh).config と別ファイルの両方に書く宣言は型として作れない.

pub(crate) struct McpSpec {
    pub(crate) registration: McpRegistration,
    pub(crate) entry: McpEntry, // リモートサーバーの書き方
}

pub(crate) enum McpRegistration {
    InConfig { servers: &'static [&'static str] },                 // Codex,Hermes
    File { path: &'static str, servers: &'static [&'static str] }, // Devin,Antigravity
    SkillsDirectoryPlugin { directory: &'static str },             // Claude Code
}

Claude Code の場所の選定

候補 結果
~/.claude.json の mcpServers Claude Code が常時書き換えるため競合(今回の問題そのもの)
managed-mcp.json 管理者権限が必要で排他制御.ユーザー追加のサーバーとプラグインのサーバーが全部読み込まれなくなる
managedMcpServers managed settings からしか読まれず,リモートサーバーのみ
--mcp-config ラッパー経由で起動したセッションだけ
skills-directory plugin(採用) ~/.claude/skills/<dir>/.claude-plugin/plugin.json をインストール不要でその場読み込み.stdio と HTTP の両方に対応し,Claude Code は書き込まない

検証

  • cargo test:367 passed,0 failed(パーサ,プロバイダ別のリモートサーバー形式,Claude プラグインと Devin/Antigravity/Hermes/Codex の golden,Devin/Antigravity/Hermes の同期でユーザー追加分が残りソースから消したものが消えること,MCP ファイルを持たないプロバイダの同期エラー,レジストリ不変条件)
  • cargo clippy --all-targets -- -D warnings,cargo fmt --check,lefthook(nixfmt,statix,deadnix,ls-lint,file-length)
  • nix flake check --option allow-import-from-derivation false(aarch64-darwin):all checks passed.HM のチェックで Devin と Antigravity の MCP ファイルが symlink ではなく activation で sync-config --provider <id> --file mcp-servers されることを確認
  • ホームへの install を 2 回実行し,ソースから消したサーバーが削除され,ユーザーのサーバーが残ることをテストで確認(install も sidecar を読み,配置する)
  • 変異確認:エンジンが MCP マッピングをキー所有から除外しないようにすると,エンジンのテストと Hermes の同期テストが失敗することを確認
  • CLI の手動確認:sync-config --provider devin --file mcp-servers が既存のユーザーサーバーを残して書き込み sidecar に記録すること,--provider pi --file mcp-servers が「MCP server file of its own がない」エラーになること
  • 実機:Claude Code 2.1.331 で生成したプラグインを読み込み,claude mcp list に plugin:agent-harness:docs(HTTP)と plugin:agent-harness:github(stdio)が出ることを確認(前回)
  • Devin,Hermes,Antigravity の実機での読み込みは未確認(各ドキュメントの書式に基づく)
  • x86_64-linux の flake check は CI に任せる
範囲・出典・前提
  • Devin:~/.config/devin/mcp_config.json の mcpServers.リモートは url と transport(http が Streamable HTTP).devin mcp add -s user もこのファイルに書く.v3000.3 以降,config.json の mcpServers は専用ファイルへ移行される.
  • Antigravity:~/.gemini/config/mcp_config.json の mcpServers.リモートは serverUrl(url は版によって受け付けないため serverUrl を使う).エディタ,アプリ,agy が同じファイルを読む.公式ページは取得できず,複数の解説と GitHub MCP server のインストールガイドで確認した.
  • Hermes:~/.hermes/config.yaml の mcp_servers.リモートは url.managed-config.yaml が mcp_servers を持ち,同期は plugins と mcp_servers 以外のキーを置き換え,mcp_servers は sidecar で追跡する.
  • 影響:Claude のツール名が mcp__plugin_agent-harness_<server>__<tool> になる(受け入れ済み).サーバー宣言時は agent-harness という名前のスキルを置けない.Devin と Antigravity の同期は,サーバーを宣言していなくても mcp_config.json({})と sidecar を作る.Hermes の managed-config.yaml はサーバー宣言時に YAML として書き直すため,インデントが変わる.
  • ホームへの install も sidecar を読むので,Codex の shell_environment_policy.set も sync-config と同じく追跡される(sidecar がなければ,以前 harness が管理していた GH_CONFIG_DIR だけを削除する).
  • sidecar(.agent-harness-managed.json)には常に空のリストも記録する.記録を省くと,後でユーザーが同名サーバーを追加したときに削除し得るため.同じディレクトリで 2 つの同期が sidecar を共有しないことをテストで保証する.
  • 出典:Claude Code MCP,managed MCP,plugin loading,manifest reference,Codex MCP,Devin MCP configuration,Antigravity MCP,GitHub MCP server: Antigravity,Hermes MCP,dsh MCP discussion.
  • ADR:ADR-0033.

Closes #267

🤖 Generated with Claude Code

furedea and others added 2 commits November 28, 2026 00:11
Read MCP servers from the optional source file mcp_servers.json, which
the Home Manager option mcpServers can override by name, and render
them for Claude Code as a skills-directory plugin and for Codex as the
mcp_servers table of config.toml.

Claude Code loads the plugin in place and never writes to it, so no
sync races the running agent for ~/.claude.json. Codex tracks the
servers in its existing sidecar, so servers the user or `codex mcp add`
wrote stay. generate-skills now renders a provider's own skills
directory, so the plugin reaches Claude only.

Refs #267

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add ADR-0033 for where each provider's servers are rendered and why
servers the user added survive, and document the source file shape,
the Home Manager option, and how to supply a credential.

Refs #267

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-29T04:21:27.827778Z
We couldn’t complete this review. Comment @codex review to try again.
c3c52ae Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

No blocking findings (P0/P1: 0). No P2/P3 findings either.

What I checked:

  • mcp_servers.json parsing: deny_unknown_fields, the command-or-url-but-not-both rule, rejecting args/env on url servers, the name charset, and the http(s) scheme check. The parse tests cover these.
  • Claude plugin: it is added only for McpSpec::SkillsDirectoryPlugin (Claude). Providers that use CopyRendered (Pi, Antigravity) go through render_declared_skill and never pick it up. A skill named agent-harness is rejected. Because the skills directory is a ReplaceTree, a stale plugin is removed once the source declares no servers.
  • reuse_rendered_skills: it now renders at a relative origin and relocates. That is consistent because relocated only rewrites targets, and copy sources stay absolute.
  • Codex: duplicate names between codex/config.toml and mcp_servers.json fail. The new TrackedKeys claim shares the sidecar with shell_environment_policy.set under a different key (mcp_servers). Older sidecars that lack the key resolve to an empty set, so servers added by users are not deleted when someone upgrades.
  • codec.rs implicit parent tables: toml_edit still prints a header for an implicit table once it holds key/values, so this does not change behavior for existing synced paths beyond dropping empty headers.
  • CLI: --provider now takes ProviderId. claude and codex keep working, and nix/providers.json was updated to match.

Not verified here: the x86_64-linux flake check (left to CI) and the runtime behavior of Claude Code's skills-directory plugins (the PR reports a manual test).

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70c29a00fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread nix/home_manager_module.nix Resolved
The Home Manager merge rebuilt the file from its `servers` key, so a
misspelled root key silently became an empty server map instead of
failing as it does outside Home Manager. Merge into `servers` and keep
every other root key, so the harness parser still rejects it.

Refs #267

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

Review summary (read-only): no findings.

Checked:

  • mcp_servers.json parsing and validation (src/generation/mcp_servers.rs): it rejects unknown fields, setting both or neither of command/url, args/env on a url server, non-http(s) URLs, and bad names.
  • Claude plugin generation (src/provider/renderer.rs): the plugin is added only to the top-level provider's skills directory and not to skills that Pi/dsh/Antigravity copy from it. It is skipped when there are no servers. The name-collision guard also covers --extra-skill, because external skills are part of the rendered tree.
  • Codex: source servers are merged into [mcp_servers], and a name declared in both codex/config.toml and mcp_servers.json is an error. The sync tracks mcp_servers with TrackedKeys against the existing sidecar, and mcp_servers does not overlap CODEX_MANAGED_KEYS, so servers the user added stay.
  • generate-skills --provider now takes a ProviderId, and nix/providers.json matches. The Home Manager by-name override keeps the source file's other root keys, so a malformed file is still rejected.
  • Tests cover the parser, the golden output, collision errors, keeping or dropping servers on Codex sync with and without a sidecar, and the Home Manager override.

Blocking findings (P0/P1): 0.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: ca8e91290c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Prefix the MCP server parse, Codex table, and skills plugin errors with
the operation that failed, and match the ownership and MCP variants
exhaustively in the registry tests.

Refs #267

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

No P0–P3 findings. I didn't post any inline comments.

What I checked:

  • Parsing (mcp_servers.rs): A server must have exactly one of command or url. Unknown fields are rejected, names are restricted, and only http/https URLs are accepted. Each case has a test.
  • Claude plugin: It is only added through SkillsDirectory::render for specs with McpSpec::SkillsDirectoryPlugin. Pi and Antigravity render RenderFrontmatter directly with mcp: None, and dsh copies the Codex skills through render_declared_skill, so none of them get the plugin. The HM check covers Pi. The name-collision guard covers source skills, and it also covers --extra-skill, because CopyTree targets go through writes_under.
  • generate-skills --provider: It now takes ProviderId. Its value names match the new skills_provider values in providers.json, and the old claude/codex values still work.
  • Codex sync: TrackedKeys on mcp_servers only removes names recorded in the sidecar. An old sidecar with no mcp_servers key, or no sidecar at all, removes nothing, so servers added by the user or by codex mcp add stay. Both cases have tests.
  • Codex generation: Names declared in both codex/config.toml and mcp_servers.json are rejected, and the error names the server.
  • implicit_table in toml_parent_mut: It only drops empty intermediate headers. A parent that later gets direct keys still prints its header, so existing TOML syncs mean the same thing.
  • HM merge: Servers are replaced whole by name. Other root keys from the source pass through to the Rust validator.

Note: Codex sync replaces each harness-owned [mcp_servers.<name>] entry whole. Anything added by hand under a server the harness owns is overwritten on activation. That matches how the other tracked keys behave.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: c3b2686fff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

furedea and others added 2 commits November 28, 2026 23:16
Devin and Antigravity keep servers in a file of their own that their CLIs
also write, so the file is a second synced config of the provider, synced
by `sync-config --provider <id> --file mcp-servers` and on Home Manager
activation; its tracked `mcpServers` mapping keeps servers added there.
Hermes tracks `mcp_servers` in the config it already syncs. Each provider
declares the form it reads a remote server in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 28, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

Blocking findings (P0/P1): none. No inline comments either: nothing reached the bar for a finding.

What I checked:

  • Parsing (mcp_servers.rs): unknown fields are rejected (deny_unknown_fields), a server must set command or url but not both, server names are checked, and url must start with http(s)://. A url server with args/env is rejected.
  • Codex: add_mcp_servers rejects a server name declared in both mcp_servers.json and codex/config.toml. The new TrackedKeys on mcp_servers shares .agent-harness-managed.json with shell_environment_policy.set; the two are recorded under separate keys, and the updated sidecar test covers this. The TOML codec now creates parent tables as implicit, which only drops empty headers. A parent that also holds key/value pairs still gets its header.
  • Claude plugin: it is added only when the provider's spec is SkillsDirectoryPlugin. Providers that copy Claude's skills (CopyRendered) don't get it, and the HM check plus the generate-skills test confirm this. The writes_under guard also catches an external skill named agent-harness. Changing reuse_rendered_skills to a relative origin is safe, because relocated strips that same prefix.
  • Sidecar collisions: the Devin and Antigravity MCP files sit in directories where no other config uses TrackedKeys (Devin's config.json has no sidecar, and the Antigravity config lives in antigravity-cli/). Hermes's sidecar likewise has only the one claim. So sidecars don't clobber each other.
  • Home Manager: an option entry replaces the source entry of the same name, other root keys of the source are kept, mcp_sync activations are added only for providers that have one, and the MCP files are not linked as home files. providers.json is generated from the registry by tests/nix_provider_registry.rs.

Non-blocking notes:

  • The PR description says Devin and Antigravity are left to a separate PR. The code, README, ADR, goldens and providers.json all generate and sync them (agentHarnessDevinMcpServers / agentHarnessAntigravityMcpServers). The description is out of date and should be updated before merge so reviewers aren't misled.
  • As the ADR notes, the Devin and Antigravity syncs create mcp_config.json with {"mcpServers": {}} plus a sidecar even when no servers are declared. That's acceptable as documented.
  • The first sync with no sidecar replaces a server the user added under the same name, including any credentials in its env, and then tracks it. This is the intended "replaced whole" behaviour, but it may be worth a sentence in the README.

@furedea

furedea commented Nov 28, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Automated review: no findings at P0–P3.

What I checked:

  • mcp_servers.json parsing and validation. Unknown fields are rejected, a server needs exactly one of command or url, a url server can't take args/env, only http(s) URLs are accepted, and names are checked.
  • Claude Code: the skills-directory plugin is added only for the provider that declares one. Moving Pi, dsh and Antigravity to their own skills_provider keeps the plugin out of their skills trees. A skill that uses the plugin's directory name is rejected.
  • Codex: mcp_servers sits in no Keys claim, so the new TrackedKeys claim is the only owner. The two tracked claims share one sidecar but get separate entries (they are keyed by path), and a server in both codex/config.toml and mcp_servers.json is rejected.
  • Hermes: mcp_servers is excluded from the EveryExcept claim and tracked instead. Removing a server from the source drops it, even when the rendered config has no mcp_servers at all.
  • Devin and Antigravity: their own mcp_config.json files sync with TrackedKeys on mcpServers. No other synced file in those directories uses a sidecar, and synced_files and the HM mcp_sync activations cover both files.
  • HM merge of mcpServers over the source, the new --file flag on sync-config, and moving the relative origin in reuse_rendered_skills to relocated.

Tests cover parsing, the form each provider gets, keeping user-added servers and dropping stale ones (with and without a sidecar), the sidecar-uniqueness invariant, and the golden output.

@furedea

furedea commented Nov 28, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary (read-only): no findings.

What I checked:

  • Sync engine: Codex and Hermes each track their mcp_servers with a separate tracked-keys claim. Each claim is recorded under its own name in the shared sidecar, so a Codex upgrade with an existing sidecar removes nothing unexpected. Without a sidecar, formerly_managed: &[] means user-added servers stay.
  • Devin and Antigravity: mcp_config.json is created when missing, and servers the user added are kept. A test guarantees that no two synced files in one directory share a sidecar.
  • Claude Code plugin: it is added only through SkillsDirectory::render for the destination provider. Pi and Antigravity reuse Claude's rendered skills through CopyRendered, so they don't get the plugin. The Home Manager change to skills_provider (pi, dsh, antigravity) keeps that correct for Nix-built skills. A skill that already uses the plugin directory is rejected.
  • Codex: the source servers are merged into codex/config.toml, and a server name that appears in both files is rejected. Implicit parent tables avoid writing an empty [mcp_servers] header.
  • Home Manager: mcpServers replaces a source entry of the same name and keeps the source file's other root keys, so the harness still validates the file. Every MCP sync activation runs only when its provider is enabled.

No P0 or P1 issues.

🤖 Generated with Claude Code

furedea and others added 3 commits November 29, 2026 00:28
The sync declaration names the mapping and the form of a remote server,
and the engine derives the tracked claim and the key exclusion from it,
so the MCP spec, the tracked keys, and the key claims cannot disagree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The link field named a provider id that always equals the provider that
owns the link, so it becomes a flag and the module passes the provider's
own id to generate-skills.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
furedea and others added 2 commits November 29, 2026 03:06
`mcp` read as "no MCP" for Codex and Hermes, whose config holds the
servers. The field is now `mcp_outside_config`, and
`ProviderSpec::mcp_destination` tells every provider's destination,
including none, from it and the config's sync declaration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 28, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Automated review (read-only): no P0–P3 findings.

What I checked:

  • The mcp_servers.json parser: the rules for picking either command or url, name checks, and unknown fields.
  • How servers are rendered for each provider: the Claude skills-directory plugin, Codex TOML (including duplicates with codex/config.toml), the Hermes fixed YAML, and the Devin/Antigravity own files.
  • Engine ownership: owns_key keeps the MCP mapping out of Keys claims, and sync_tracked_keys uses the sidecar to remove servers the source dropped.
  • Sidecar file names stay separate: Codex shares one sidecar between two tracked paths with different names, and the Antigravity and Devin main configs have no sidecar of their own.
  • Install now reads and publishes sidecars.
  • The Home Manager merge, the mcp_sync activations, and the switch of providerSkills to provider.id. Only Claude gets the plugin, because Pi, dsh, and Antigravity resolve to a different MCP destination.

I didn't run the tests in this environment, and I didn't check that Devin, Hermes, or Antigravity actually load the files on real installs. The PR also lists that last part as unchecked.

@furedea

furedea commented Nov 29, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Automated review: no blocking findings (no P0/P1, no P2/P3 posted).

What I checked:

  • MCP source parsing and validation (src/generation/mcp_servers.rs): command vs. url exclusivity, name charset, url scheme.
  • Sync engine: mcp_servers is excluded from Keys claims through ConfigSync::owns_key and tracked in the sidecar. Removed servers are deleted only when the sidecar lists them, so user and CLI entries stay. Codex's existing shell_environment_policy_set sidecar entry sits next to the new mcp_servers entry without colliding.
  • Per-provider destinations: Claude gets a skills-directory plugin. Antigravity renders its own skills, and only Claude's spec declares the plugin, so Antigravity gets no copy. Codex and Hermes write into their config. Devin and Antigravity write their own mcp_config.json, each with a sidecar in a directory no other sync uses. Pi and dsh get nothing.
  • Home Manager wiring: mcp_sync activations, generate-skills --provider <id>, and the HM mcpServers entries replacing source entries by name. The Devin and Antigravity MCP files are synced, not linked; no linked path covers them.
  • Codex: a server name declared both in codex/config.toml and in mcp_servers.json is rejected at generation time.

The tests cover the changed behaviour: goldens, sync preservation and removal, the registry invariants, and the HM check. As the PR notes, nobody has yet confirmed on real installs that Devin, Hermes and Antigravity load the generated files.

furedea and others added 2 commits November 29, 2026 09:42
`ProviderSpec::mcp` is `Option<McpSpec>`, a registration (in the config,
a file of its own, or the skills-directory plugin) and the form of a
remote server. The config sync takes the tracked mapping from it, so
`ConfigSync` holds no MCP and servers in both places cannot be declared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 29, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Automated review summary: no findings

I reviewed the MCP server pipeline end to end and found no correctness, security, or test-coverage problems that I could confirm.

  • Parsing: mcp_servers.json is strictly validated. Unknown fields are rejected, a server sets exactly one of command or url, a url server takes no args or env, names are restricted to ASCII letters, digits, - and _, and urls must use http(s).
  • Rendering per provider:
    • Claude: a skills-directory plugin, with a guard against a skill that already uses the plugin's directory.
    • Codex: [mcp_servers.*] added to the source TOML through implicit tables, with an error when a name is also declared in codex/config.toml.
    • Hermes: added to the fixed YAML.
    • Devin and Antigravity: their own mcp_config.json.
    • Pi and dsh: correctly get nothing.
  • Sync and sidecar:
    • The owns_key exclusion keeps every Keys claim from replacing the servers mapping, so servers the user added survive. None of the affected configs (Codex Listed, Hermes EveryExcept, the empty claims on the MCP-only files) claimed the mapping before.
    • Removal tracking writes the sidecar even when the source drops every server, because the tracked entry is recorded with an empty set. Removals still happen on the next sync.
    • Codex keeps its two tracked paths under separate names in the one shared sidecar.
    • Devin's config.json and mcp_config.json share a directory, but only the MCP sync writes the sidecar, so they can't overwrite each other.
  • Home Manager: merging mcpServers into the source file by name, the extra mcp_sync activations, and the switch of generate-skills --provider to ProviderId all line up with providers.json ids. Pi and Antigravity now render their own skills directory without the Claude plugin.
  • Tests: engine, renderer, sync, golden and HM tests cover the new behavior.

Blocking findings (P0/P1): 0

🤖 Generated with Claude Code

@furedea

furedea commented Nov 29, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary (read-only)

No blocking findings (0 × P0/P1). I didn't post any inline comments.

What I checked:

  • Server parsing and validation (src/generation/mcp_servers.rs). Unknown fields are rejected, a server can't have both command and url or neither, a url must start with http:// or https://, and names must match [A-Za-z0-9_-]. A url server can't take args or env.
  • Sync engine (config_sync/engine.rs). Ownership::Keys claims leave out the MCP mapping (owns_key). Tracking reuses the existing sidecar under a separate key (mcp_servers / mcpServers), so it doesn't collide with Codex's shell_environment_policy_set. With no sidecar, or an unreadable one, nothing is removed (formerly_managed is empty), so servers users already have are kept on upgrade. A sidecar is always written for MCP files, even with an empty list.
  • Codex. mcp_servers was never in CODEX_MANAGED_KEYS, so nothing that used to be owned is dropped. A server declared in both codex/config.toml and mcp_servers.json is an error, not a silent override.
  • Hermes. EveryExcept(["plugins"]) now also leaves out mcp_servers, which is tracked separately.
  • Claude plugin. It's added only when servers are declared, and it's rejected if a skill already uses agent-harness/. ReplaceTree removes the plugin once the servers are gone.
  • Home Manager. mcp_sync activations run after linkGeneration. Option entries replace source entries per server name, not by deep merge.

Not covered: Devin, Hermes and Antigravity actually loading the generated files (the PR also lists this as unverified).

@furedea
furedea merged commit 2eb9fe7 into main Nov 29, 2026
21 of 23 checks passed
@furedea
furedea deleted the feat/render-mcp-servers branch November 29, 2026 05:12
furedea pushed a commit that referenced this pull request Dec 1, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](agent-harness-v0.9.16...agent-harness-v0.10.0)
(2026-11-29)


### ⚠ BREAKING CHANGES

* remove the generated protection of installed files
([#265](#265))
* remove the agent GitHub token
([#264](#264))
* **pi:** remove the srt sandbox extension
([#263](#263))

### Features

* render MCP servers declared once in the source
([#268](#268))
([2eb9fe7](2eb9fe7))


### Code Refactoring

* **pi:** remove the srt sandbox extension
([#263](#263))
([d1f8a11](d1f8a11))
* remove the agent GitHub token
([#264](#264))
([ea5741d](ea5741d))
* remove the generated protection of installed files
([#265](#265))
([2008c43](2008c43))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
furedea added a commit to furedea/dotfiles that referenced this pull request Dec 1, 2026
## 概要

furedea/agent-harness#264 でエージェント用 GitHub トークンの発行機能が agent-harness
から削除されたため,発行を dotfiles に移した.

- `scripts/github-app-token/mint_github_app_token.sh`(新規):
`openssl`,`curl`,`jq` でトークンを発行する.`jq` は既存の依存.
  - App の鍵で RS256 の JWT に署名する.
- `GET /app/installations` で App のインストールが 1 つだけであることを確かめ,`POST
/app/installations/{id}/access_tokens` でトークンを発行する.
- `<設定ディレクトリ>/hosts.yml` を一時ファイルからの rename で mode 0600 で書く.設定ディレクトリは
0700.`config.yml` がなければ `version: "1"` を書く.
  - 失敗したときは今の `hosts.yml` をそのまま残す.
  - JWT とトークンは標準入力で curl に渡すので,argv にも出力にも出ない.
- **2 回前のトークンの失効**: 置き換える `hosts.yml` を同じディレクトリの
`hosts.previous.yml`(mode 0600,一時ファイルからの rename)に残す.新しい `hosts.yml`
に置き換えた後,`hosts.previous.yml` にあったトークン(2 回前の実行で発行したもの)を,そのトークン自身で `DELETE
/installation/token` して失効させる.
- 有効なトークンは最大 2 つになる.実行の直前に始まった `gh run watch` のような長い `gh`
も,その次の実行まで(少なくとも 15 分)動き続ける.
  - 漏れたトークンは最大 30 分で失効する(もともと 1 時間で期限切れ).
  - 1 回目と 2 回目の実行は何も失効させない.
  - 発行に失敗したときは `hosts.yml` も `hosts.previous.yml` も変えず,何も失効させない.
  - 401 は期限切れなので何も出さない.
  - ほかの失敗はトークンを含めずにログへ出し,実行は成功として終える.
- **権限の絞り込み**: 権限の指定を必須にし,指定がなければ usage で失敗する.App の全権限を持つトークンは発行されない.
- `nix/home/default.nix`:
  - `programs.agent-harness.github.agentToken` を削除した.
- launchd エージェント `agent-github-token` を両ホストに追加した(`RunAtLoad`,15
分ごとに実行,ログは `~/Library/Logs/agent-github-token.log`).
  - App ID,鍵のパス,設定ディレクトリ `~/.config/agent-harness/gh` は旧版と同じ.
- Claude の `env` と Codex の `shell_environment_policy.set` に
`GH_CONFIG_DIR` を設定した.source の設定は `~` を展開しないので,dotfiles が絶対パスで渡す.
- `flake.lock`: agent-harness を 249aeac(0.10.0,furedea/agent-harness#268
を含む)に,agent-config を 4ea2075(0.6.0,furedea/agent-config#286
を含む)に一緒に更新した.
- furedea/agent-harness#268 は,ソースの `mcp_servers.json` と Home Manager の
`mcpServers` に宣言した MCP サーバーを,各プロバイダーの設定に生成する.
- dotfiles と agent-config は MCP
サーバーを宣言していないので,生成されるのはサーバーを含まない空のファイルだけ.`darwin-rebuild` 後に Mac に現れるのは次の
2 つ.
- `~/.gemini/config/mcp_config.json`: 新しい activation
`agentHarnessAntigravityMcpServers` が,なければ作る.
- `~/.gemini/config/.agent-harness-managed.json`:
そのサイドカー(`{"mcpServers": []}`).
- 既存の `~/.codex/.agent-harness-managed.json` に空の `mcp_servers`
が加わる.Codex の `config.toml` に `[mcp_servers]` は増えず,Claude の skills
ツリーのファイル構成も変わらない.Devin は有効にしていないので `~/.config/devin` には何も書かれない.
  - agent-config 側の差分は 0.6.0 のリリースと依存の更新(hypothesis,ruff).
- `nix/checks.nix`:
- 新しい agent-harness は `composedSettings` を公開しないので,モジュールと同じ評価(source の設定に
Home Manager の `settings` を `recursiveUpdate` で重ねる)で生成後の設定を組み立てるようにした.
  - 契約を追加した.
    - 旧 `github` オプションが削除済みであること
    - 両ホストのジョブの引数(App ID,鍵,設定ディレクトリ,権限)
    - 実行間隔が 1 時間の有効期限の 1/3 未満であること
    - Claude と Codex の `GH_CONFIG_DIR`
    - 組み込んだスクリプトが実行できること(darwinOnly)
  - Claude,Codex,Antigravity のそれぞれで鍵が読み取り拒否されていることを確かめる契約を追加した.
    - **Claude**: `Read(...)` と `denyRead` の両方
    - **Codex**: `default_permissions` のプロファイルの filesystem に `"deny"`
    - **Antigravity**: `read_file(...)`
    - 鍵そのものに加え,`~/.ssh` などの親ディレクトリの拒否も鍵を含むものとして扱う.
    - 設定を生成するプロバイダーが増えたら失敗する契約もある.
- ADR-0055 を追加し,README を更新した.

Closes #531

## 権限の選び方

`GET /apps/furedea-agent` で調べた App の権限は
`actions:read`,`contents:write`,`issues:write`,`metadata:read`,`pull_requests:write`
だった.エージェントはどれも使うので,5 つすべてを明示して要求する.

| 権限 | 使い道 |
| --- | --- |
| `actions:read` | CI の確認 |
| `contents:write` | push |
| `issues:write` | Issue |
| `pull_requests:write` | PR |
| `metadata:read` | 常に必要 |

絞り込みの効果は,後から App に権限を足しても,dotfiles
に書き足すまでエージェントには渡らないこと.リポジトリは絞らなかった.インストールが所有者の全リポジトリを対象にしていて,エージェントは複数のリポジトリにまたがって作業するため.

## マージ後の手順(各 Mac で)

トークンは表示しない.

1. `sudo darwin-rebuild switch --flake
~/ghq/github.com/furedea/dotfiles#<host>` で反映する.
2. launchd エージェントが動いたことを確かめる.
- `launchctl print gui/$(id
-u)/org.nix-community.home.agent-github-token | grep -E 'state|last exit
code'` で `last exit code = 0` になっている.
   - `~/Library/Logs/agent-github-token.log` にエラーがない.
3. エージェントの身元で gh が動くことを確かめる.
- `GH_CONFIG_DIR=~/.config/agent-harness/gh gh api
/installation/repositories --jq .total_count` が数を返す.
   - `stat -f %Lp ~/.config/agent-harness/gh/hosts.yml` が `600` を返す.
4. 新しく起動した Claude Code または Codex のセッションで `gh pr list --repo
furedea/dotfiles` が動く.
5. 旧版の状態ファイル `~/.config/agent-harness/gh/agent_harness_token.json`
は不要なので消してよい.

## 検証

- `bats tests/github-app-token`: 22 件すべて成功.スクリプトを作る前,失効と権限を足す前,2
回前の失効に変える前の各段階で,テストが先に失敗することを確認した.
- `nix flake check`: 成功(`all checks passed!`).
  - lock 更新前は次の 4 件が失敗し,更新後に通ることを確認した.
- `agent-harness-github-option-removed`(旧
`agent-harness-has-no-github-option`)
    - `github-app-key-unreadable-by-claude`,`-codex`,`-antigravity`
  - `GH_CONFIG_DIR` の 2 件は,dotfiles で設定した時点で通った.
- `bats --recursive tests`(137 件): 今回の変更による失敗はなし.ローカルのサンドボックスで zsh の
ssh-agent の 8 件と nvim の lspmux の 1 件が失敗したが,原因は Unix ソケットの listen と
`~/.local/state/nvim` への書き込みの拒否で,今回の変更とは関係ない.
- shellcheck,shfmt,lefthook,commitlint: 成功.
- Nix のチェック `agent-github-token-script`(darwinOnly): bats の仕様を,launchd
ジョブと同じ固定ツール(`nix/agent_github_token.nix`,curl のみ偽物)で実行し,22 件すべて成功.
- CI: `codex-review` と,それに連動する `all-green` 以外はすべて成功.`codex-review`
は利用上限で実行されていない(Codex のコメントで確認).
- 実際の鍵とトークンは,読み取りも表示もしていない.テストは使い捨ての鍵と偽の curl を使う.

## レビュー対応

- **P1(Claude)**: launchd ジョブの `TOOLS_PATH` に `sed` がなく,2 回目以降の実行が exit
127 で失敗してトークンが更新されなくなる.
  - 29e11c7 で修正した.前のトークンは bash の正規表現で読むようにした.
- bats の仕様をジョブと同じ固定ツールで実行する Nix チェックを足した.修正前のスクリプトで,このチェックが `sed:
command not found` で失敗することを確認した.
- **P2(Claude)**: 前のトークンをすぐ失効させるため,次の実行より長く動く `gh`(`gh run watch` など)が
401 になる.
- 所有者の判断で,2 回前のトークンを失効させる方式に変えた(ae6e9e1).有効なトークンは最大 2 つ,漏れたトークンは最大 30
分で失効する.
  - ADR-0055 の Decision と Consequences を更新した(b4fecc3).
- **P3(Claude)**: Claude Code の `Read(/path)`
はプロジェクトからの相対パスとして読まれるので,鍵の契約が保護にならないエントリーを通しうる.
  - 398e377 で修正した.`Read(` の絶対パスは `//` で始まるものだけを数える.
- **P3(Claude,変更なし)**: revoke の対象が `hosts.yml`
の値をそのまま使う点.指摘自身が問題なしとしている.エージェントがそのディレクトリに書けても,送られるのはエージェントがすでに持つトークンだけ.
- **P3(Claude,変更なし)**: checks は agent-harness
の合成を再現していて,生成結果そのものは読んでいない.生成結果を読むには評価時のビルド(IFD)が要るので,今の形にとどめた.agent-harness
の合成方法が変わったときは見直す.
- 最終の再レビュー(Claude): P0〜P2 の指摘なし.未解決のスレッドなし.
- 2 回前の失効と lock 更新後の再レビュー(Claude): P0〜P2 の指摘なし.P3 として,PR 本文の失効方式と lock
のリビジョンが古いと指摘された.push 直後に本文を更新しており,どちらも反映済み.
- Codex: 利用上限のため 2 回とも実行されていない.
- CI の bats で,GNU の `stat -f` によって mode の確認がずれていた.テストの補助関数で `stat -c`
を先に試すように直した.

## 計画からの逸脱

- JSON の読み取りに既存の `jq` を使った.インストール一覧の応答には入れ子の `id` があり,sed では確実に読めないため.
- 期限を追跡せず,毎回発行する.状態は前の `hosts.yml` だけで済む代わりに,1 台あたり毎時 4
回の発行と失効になる(ADR-0055).
- `nix/checks.nix` で agent-harness の合成を再現した.新しい agent-harness が
`composedSettings` を公開しなくなったため.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
furedea added a commit that referenced this pull request Dec 1, 2026
Closes #269

## 原因

#268 の MCP ファイル同期が installed の JSON を `Json::parse`
でそのまま読むため,Antigravity が初回起動時に作る 0 バイトの `mcp_config.json` で `EOF while
parsing` となり,activation 全体が中断していた.YAML には installed の空文書を blank
とする既存の扱いがあったが,JSON にはなかった.

## 修正

- `Json::parse` が `Role::Installed` かつ空白のみのテキストを空オブジェクトとして読む(YAML
と同じ方針.codec レベルなので全 installed JSON に適用)
- generated の空 JSON,非空の不正 JSON,`[]`,`null` は従来どおりエラー(既存の
`pi_rejects_invalid_documents…` が維持を確認)
- 空の installed は通常の描画で書き戻される(同期テストで `mcpServers` が書かれることを確認)
- TOML は空文字列を空ドキュメントとしてもともと受け付ける.テストを追加して固定した

## 備考

リリースと dotfiles の lock 更新後は,回避策の `printf '{}\n' >` は不要になる.ADR は YAML
との整合のみで新たな決定がないため追加していない.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
furedea added a commit to furedea/dotfiles that referenced this pull request Dec 2, 2026
## 変更

`agent-harness` の flake input を v0.10.1(58b900f)に更新する.

v0.10.0(furedea/agent-harness#268)は Antigravity の MCP 設定ファイル
`~/.gemini/config/mcp_config.json` を同期するようになったが,Antigravity が作る 0
バイトのファイルを JSON として読めず,home-manager の activation が
`agentHarnessAntigravityMcpServers` で止まっていた(以降の activation,Claude の
`settings.json`
の同期などが走らない).v0.10.1(furedea/agent-harness#270)は,既存ファイルが空または空白だけのとき空の設定として扱う.

## 確認

- `nix flake check` が通る.
- lock の commit が `agent-harness-v0.10.1` タグと一致する.

## マージ後の確認

1. `sudo darwin-rebuild switch` が最後まで通る(`{}` を書き込む回避策は不要).
2. Claude のセッションを起動し直し,ツールを使っても `Usage: audit_log.py denied …` の hook
エラーが出ない.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

feat: render MCP servers declared once in the source

1 participant