feat(coding/agents): hand the shared MCP catalogue to Claude Code
- Move programs.mcp.servers out of agents.nix into mcp.nix so hosts that do not load the whole coding set (T3 Code servers) can import it alone - Add claude-code.nix: programs.claude-code with enableMcpIntegration, replacing the bare llm-agents.claude-code package (would collide on bin/claude). home-manager delivers the catalogue as a generated plugin, ~/.claude/settings.json and ~/.claude.json stay writable - ai-memory: register the session-aware Claude bridge via programs.claude-code.mcpServers instead of `ai-memory install-mcp`; activation only removes the stale user-scope entry now - Adjust ai-memory.test.sh accordingly Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
b63db50485
commit
c9f68a4361
5 files changed
+97
-52
No files matched your search
@@ -3,12 +3,13 @@
|
||||
# The server runs on m3-hermes (nixos-config) and is reached at
|
||||
# memory.m3ta.dev; no server runs on clients. Hybrid setup:
|
||||
# - Nix owns the package, the client config (server URL + bearer token
|
||||
# file), the OpenCode MCP entry (via programs.mcp, since opencode.json
|
||||
# is a home-manager symlink) and the scope markers (~/.ai-memory.toml
|
||||
# plus one marker per workspace directory).
|
||||
# - Activation runs ai-memory's own installers for the lifecycle hooks,
|
||||
# the session-aware Claude Code MCP entry and the skills, so generated
|
||||
# files always match the installed ai-memory version.
|
||||
# file), the MCP entries (programs.mcp for OpenCode, and a session-aware
|
||||
# override in programs.claude-code.mcpServers for Claude Code, both
|
||||
# delivered through the agents' enableMcpIntegration) and the scope
|
||||
# markers (~/.ai-memory.toml plus one marker per workspace directory).
|
||||
# - Activation runs ai-memory's own installers for the lifecycle hooks and
|
||||
# the skills, so generated files always match the installed ai-memory
|
||||
# version.
|
||||
#
|
||||
# The bearer token (an `aim_` API key, one per host) is an agenix secret the
|
||||
# host repo provides at `tokenFile`. It is never copied into a generated
|
||||
@@ -100,6 +101,18 @@ in {
|
||||
args = ["mcp-bridge" "--no-session-id" "--server-url" "${cfg.serverUrl}/mcp"];
|
||||
};
|
||||
|
||||
# Claude Code gets the same server name through
|
||||
# programs.claude-code.enableMcpIntegration, but session-aware: the stdio
|
||||
# bridge forwards the lifecycle-hook session id and reads the token file
|
||||
# itself. (A plain HTTP entry carries no credentials, and Claude Code then
|
||||
# tries OAuth client registration, which ai-memory does not offer.)
|
||||
# Claude Code's own mcpServers take precedence over the shared entry, so
|
||||
# this is one server, not two.
|
||||
programs.claude-code.mcpServers.ai-memory = mkIf (elem "claude-code" cfg.agents) {
|
||||
command = exe;
|
||||
args = ["mcp-bridge" "--server-url" "${cfg.serverUrl}/mcp"];
|
||||
};
|
||||
|
||||
home.file =
|
||||
{
|
||||
# Client config: `ai-memory hook`, `mcp-bridge` and the installers
|
||||
@@ -130,13 +143,10 @@ in {
|
||||
'')
|
||||
cfg.agents}
|
||||
${optionalString (elem "claude-code" cfg.agents) ''
|
||||
# The MCP entry now comes from programs.claude-code (see above);
|
||||
# drop the user-scope entry earlier versions wrote into ~/.claude.json.
|
||||
export PATH="${pkgs.llm-agents.claude-code}/bin:$PATH"
|
||||
run claude mcp remove ai-memory -s user >/dev/null 2>&1 || true
|
||||
# --session-aware: stdio bridge that reads the token file itself. A
|
||||
# plain HTTP entry carries no credentials, and Claude Code then tries
|
||||
# OAuth client registration, which ai-memory does not offer.
|
||||
run ${exe} install-mcp --client claude-code --apply --session-aware \
|
||||
--server-url ${escapeShellArg "${cfg.serverUrl}/mcp"}
|
||||
''}
|
||||
# Into ~/.agents/skills; claude-skills-sync mirrors them to Claude.
|
||||
run ${exe} install-skills --scope global --agent agents
|
||||
|
||||
Reference in new issue
Block a user