library: Alma takes the Library's MCP servers, in ~/.config/alma/mcp.json as its own MCP settings write them (#1292)
Alma 0.4.164 (read from a copy of its app.asar, out/main/index.js) reads
its servers from <home>/.config/alma/mcp.json on every system, as
{mcpServers:{name:{command,args,env} | {url,headers,transport?}}}: a
server with a url is streamable HTTP falling back to SSE, and SSE only
when transport is "sse". It has no ${VAR} expansion, so a server naming
a variable is refused for Alma as for Kimi or Devin. Alma reads the file
as it starts and when its MCP settings refresh; there is no watcher.
The user's own servers (the real file's computer-use entry with
ELECTRON_RUN_AS_NODE) are kept: TestAgentMCP's alma case writes one
first. Without the change TestAgentMCP/alma fails ("alma has no MCP
target") and TestTakesRefusesAlma refuses mcp.
Run: HOME=<temp> go test -tags nogui ./internal/library ./internal/agent;
go vet for darwin, linux and windows. Not tried with a running Alma.
This commit is contained in:
@@ -36,8 +36,9 @@ agents RTK, a CLI that cuts shell output down before the model reads it.
|
||||
- An edit never silently loses. When an agent's copy of a skill and the library both changed, the newest edit wins, and the losing one is kept with the backups.
|
||||
- A failure for one agent is a `Problem` in the result. It doesn't stop the others.
|
||||
- A server an agent can't reach is not written there, and `mcpFile.supports` says why. For example, Claude Desktop takes no remote server, and Codex, Goose, dsh, Grok and Command Code take no SSE.
|
||||
- A server's headers (remote) or environment (command) can name a variable as `${NAME}` (#1250). `library.json` keeps the placeholder, and `refsOf` gives each MCP format the agent's own syntax, with the agent's source cited beside it: `${NAME}` for most, `{env:NAME}` for OpenCode and MiMo, `${env:NAME}` for Cursor, and Codex's own keys (`bearer_token_env_var`, `env_http_headers`, `env_vars`). Goose gets `${NAME}` plus `env_keys`. An agent with no syntax (Claude Desktop, Antigravity, Kimi, Cline, ZCode, dsh, Devin, Pi with pi-mcp-extension) is never written the value: `refsProblem` makes `supports` refuse the server, a magpie entry already there is taken out, and `AgentView.NoEnvRefs` greys its chip with the reason. Codex and Goose's extra keys are magpie's only while the server names a variable there (`refKeys`), so the user's own `env_vars` or `env_keys` are kept. `CheckServers` expands the variable from magpie's own environment, and one that isn't set is `novar`, naming it.
|
||||
- A server's headers (remote) or environment (command) can name a variable as `${NAME}` (#1250). `library.json` keeps the placeholder, and `refsOf` gives each MCP format the agent's own syntax, with the agent's source cited beside it: `${NAME}` for most, `{env:NAME}` for OpenCode and MiMo, `${env:NAME}` for Cursor, and Codex's own keys (`bearer_token_env_var`, `env_http_headers`, `env_vars`). Goose gets `${NAME}` plus `env_keys`. An agent with no syntax (Claude Desktop, Antigravity, Kimi, Cline, ZCode, dsh, Devin, Alma, Pi with pi-mcp-extension) is never written the value: `refsProblem` makes `supports` refuse the server, a magpie entry already there is taken out, and `AgentView.NoEnvRefs` greys its chip with the reason. Codex and Goose's extra keys are magpie's only while the server names a variable there (`refKeys`), so the user's own `env_vars` or `env_keys` are kept. `CheckServers` expands the variable from magpie's own environment, and one that isn't set is `novar`, naming it.
|
||||
- WorkBuddy's servers go in `$WORKBUDDY_CONFIG_DIR/mcp.json` (default `~/.workbuddy`), and CodeBuddy Code's go in the first of `.mcp.json`, `mcp.json` and `~/.codebuddy.json` that exists, as `resolveMcpFilePath` reads them (#1266). WorkBuddy connects a server only after the user has switched it on once in its own MCP settings. It keeps that approval in `mcp-approvals.json`, keyed by the command, args and env names or the URL's origin, so changing those asks again. magpie never writes the approval, and the servers page says so when a server is given to WorkBuddy.
|
||||
- Alma's servers go in `~/.config/alma/mcp.json` on every system (its home, not its data folder), as its own MCP settings write them: `command`/`args`/`env`, or `url`/`headers` with `transport: "sse"` only for SSE (#1292). Alma reads the file as it starts and when its MCP settings refresh, so a server given to it while it runs reaches it after one of those.
|
||||
- An agent with no place for an item is refused by `Takes`, never recorded as given it. The refusal lists the agents here that take that item (`takenBy`), and says where it goes instead (`noPlace`): OpenChamber reads OpenCode's global AGENTS.md, skills folder and opencode.json (its server's `shared.js`), so it gets them from OpenCode; Claude Desktop's chat keeps its instructions in its own settings, with the Claude account, and its Code tab reads Claude Code's.
|
||||
- Removing RTK never uses `rtk init --uninstall`. That command deletes Gemini's `GEMINI.md` whole and removes Claude Code, OpenCode and Cursor together.
|
||||
- CC Switch's own skills folder is only ever read.
|
||||
|
||||
@@ -2,6 +2,7 @@ package library
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -28,6 +29,8 @@ func TestAgentMCPFiles(t *testing.T) {
|
||||
// what magpie writes for each server, as the agent's add does
|
||||
fs, web, sse entry
|
||||
noSSE bool
|
||||
// pre makes the agent there, beyond its MCP file
|
||||
pre func(t *testing.T, h string)
|
||||
}{
|
||||
{
|
||||
id: "omp", file: ".omp/agent/mcp.json",
|
||||
@@ -127,6 +130,23 @@ func TestAgentMCPFiles(t *testing.T) {
|
||||
web: entry{"type": "http", "url": "https://example.com/mcp", "headers": entry{"Authorization": "Bearer x"}},
|
||||
sse: entry{"type": "sse", "url": "https://example.com/sse"},
|
||||
},
|
||||
{
|
||||
// as Alma's own add writes them, the server it adds itself kept
|
||||
// (#1292); Alma is there once it has its data folder
|
||||
id: "alma", file: ".config/alma/mcp.json",
|
||||
user: `{"mcpServers": {"mine": {"command": "uvx", "args": ["mine"], "env": {"ELECTRON_RUN_AS_NODE": "1"}}}}`,
|
||||
fs: entry{"command": "npx", "args": []any{"-y", "@mcp/fs"}, "env": entry{"K": "V"}},
|
||||
web: entry{"url": "https://example.com/mcp", "headers": entry{"Authorization": "Bearer x"}},
|
||||
sse: entry{"url": "https://example.com/sse", "transport": "sse"},
|
||||
pre: func(t *testing.T, h string) {
|
||||
t.Setenv("APPDATA", filepath.Join(h, "AppData", "Roaming"))
|
||||
cfg, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
os.MkdirAll(filepath.Join(cfg, "alma"), 0o755)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "grok", file: ".grok/config.toml", toml: true,
|
||||
user: "# mine\n[models]\ndefault = \"grok-4\"\n\n[mcp_servers.mine]\ncommand = \"uvx\"\nargs = [\"mine\"]\nenabled = true\n\n[mcp_servers.mine.env]\nA = \"b\"\n",
|
||||
@@ -140,6 +160,9 @@ func TestAgentMCPFiles(t *testing.T) {
|
||||
for k, v := range c.env {
|
||||
t.Setenv(k, filepath.Join(h, v))
|
||||
}
|
||||
if c.pre != nil {
|
||||
c.pre(t, h)
|
||||
}
|
||||
p := filepath.Join(h, c.file)
|
||||
write(t, p, c.user)
|
||||
parse := func() map[string]entry {
|
||||
|
||||
@@ -166,7 +166,10 @@ func (f *mcpFile) refsOf() envSyntax {
|
||||
// and env on (kimi_cli/cli/__init__.py, fastmcp mcp_config.py). Cline's
|
||||
// settings are plain strings (@cline/core 0.0.90). ZCode expands only
|
||||
// its plugins' servers, not mcp.servers (zcode.cjs createTransport).
|
||||
// DeepSeek
|
||||
// Alma
|
||||
// 0.4.164 JSON.parses mcp.json and hands a command its env and a url
|
||||
// its headers as written (out/main/index.js createStdioTransport,
|
||||
// connectRemoteServer). DeepSeek
|
||||
// Harness takes only a YAML !!js expression (dsh-mcp-client README),
|
||||
// which magpie doesn't write. Devin's docs name ${env:NAME} for OAuth
|
||||
// fields only (extensibility/mcp/configuration.mdx), so its headers
|
||||
|
||||
@@ -132,19 +132,20 @@ func TestCrushInstructionsWhereCrushReadsThem(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Alma takes skills, in ~/.config/alma/skills (#824), but has no
|
||||
// user-wide place for instructions or MCP servers, and the library says so
|
||||
// rather than recording it as given any.
|
||||
// Alma takes skills, in ~/.config/alma/skills (#824), and MCP servers, in
|
||||
// ~/.config/alma/mcp.json (#1292), but has no user-wide place for
|
||||
// instructions, and the library says so rather than recording it as given
|
||||
// any.
|
||||
func TestTakesRefusesAlma(t *testing.T) {
|
||||
sandbox(t)
|
||||
for _, kind := range []string{"instructions", "mcp"} {
|
||||
if id, err := Takes("alma", kind); err == nil || !strings.Contains(err.Error(), "Alma has no user-wide place") {
|
||||
if id, err := Takes("alma", "instructions"); err == nil || !strings.Contains(err.Error(), "Alma has no user-wide place") {
|
||||
t.Errorf("instructions: %q %v", id, err)
|
||||
}
|
||||
for _, kind := range []string{"skills", "mcp"} {
|
||||
if id, err := Takes("alma", kind); err != nil || id != "alma" {
|
||||
t.Errorf("%s: %q %v", kind, id, err)
|
||||
}
|
||||
}
|
||||
if id, err := Takes("alma", "skills"); err != nil || id != "alma" {
|
||||
t.Errorf("skills: %q %v", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Claude Desktop keeps its instructions in its own settings and OpenChamber
|
||||
|
||||
@@ -138,6 +138,9 @@ const (
|
||||
// fmtCommandCode is Command Code's mcp.json: transport stdio or http,
|
||||
// and enabled
|
||||
fmtCommandCode
|
||||
// fmtAlma is Alma's ~/.config/alma/mcp.json: a url is streamable HTTP
|
||||
// (SSE when that fails) unless transport says sse, a command stdio
|
||||
fmtAlma
|
||||
)
|
||||
|
||||
// mcpFile is the file an agent keeps its user-wide MCP servers in.
|
||||
@@ -439,10 +442,12 @@ func (f *mcpFile) encode(s *Server) ordered {
|
||||
add("args", list(s.Args))
|
||||
optional("env", s.Env)
|
||||
}
|
||||
case fmtHermes:
|
||||
case fmtHermes, fmtAlma:
|
||||
// Hermes' own `hermes mcp add` writes url/headers or
|
||||
// command/args/env; transport: sse is its only other transport
|
||||
// (tools/mcp_tool.py)
|
||||
// (tools/mcp_tool.py). Alma's own add writes the same keys, and
|
||||
// it reads transport "sse" alone, else tries streamable HTTP
|
||||
// first (0.4.164's out/main/index.js connectRemoteServer)
|
||||
if s.Remote() {
|
||||
add("url", s.URL)
|
||||
optional("headers", s.Headers)
|
||||
@@ -684,7 +689,7 @@ func (f *mcpFile) decode(name string, m map[string]any) (*Server, bool) {
|
||||
case "streamable-http":
|
||||
remote("http", str(m, "url"), m["headers"])
|
||||
}
|
||||
case fmtHermes, fmtKimi, fmtDevin:
|
||||
case fmtHermes, fmtKimi, fmtDevin, fmtAlma:
|
||||
// each takes a url over a command when an entry has both
|
||||
if u := str(m, "url"); u != "" {
|
||||
t := "http"
|
||||
@@ -884,6 +889,7 @@ var owned = map[mcpFormat][]string{
|
||||
fmtDsh: {"serverName", "transport", "url", "headers", "command", "args", "env"},
|
||||
// timeout, enabled, tools, sampling, auth… are the user's
|
||||
fmtHermes: {"transport", "url", "headers", "command", "args", "env"},
|
||||
fmtAlma: {"transport", "url", "headers", "command", "args", "env"},
|
||||
fmtOmp: {"type", "url", "headers", "command", "args", "env"},
|
||||
fmtKimi: {"transport", "type", "url", "headers", "command", "args", "env"},
|
||||
fmtDevin: {"transport", "type", "url", "headers", "command", "args", "env"},
|
||||
|
||||
@@ -225,10 +225,13 @@ func targetOf(a *agent.Agent) *Target {
|
||||
case "alma":
|
||||
// Alma reads personal skills from ~/.config/alma/skills, on every
|
||||
// system (its home, not its data folder), and Claude Code's, Codex's
|
||||
// and ~/.agents/skills besides (its skills service, #824); it has
|
||||
// no user-wide instructions file or MCP file of the kind magpie
|
||||
// writes, its prompts being its settings' own
|
||||
// and ~/.agents/skills besides (its skills service, #824). Its MCP
|
||||
// servers are ~/.config/alma/mcp.json's mcpServers, read as Alma
|
||||
// starts and when its MCP settings refresh (0.4.164's
|
||||
// out/main/index.js, #1292). It has no user-wide instructions file,
|
||||
// its prompts being its settings' own
|
||||
t.Skills = filepath.Join(h, ".config", "alma", "skills")
|
||||
t.MCP = &mcpFile{Path: filepath.Join(h, ".config", "alma", "mcp.json"), Format: fmtAlma}
|
||||
t.SkillsAlso = []string{"claude", "codex"}
|
||||
case "cindy":
|
||||
// Cindy keeps its user-wide skills in ~/.agents/skills
|
||||
|
||||
Reference in New Issue
Block a user