Feature request: per-agent MCP server configuration
Problem
agent-shell-make-agent-config has no :mcp-servers slot. The only way to configure MCP servers is the global agent-shell-mcp-servers variable, which means every agent session gets the same full set of MCP servers regardless of which agent config is selected.
This matters for:
- Token costs: Each MCP server adds tool definitions to the context window. An agent that only needs one MCP (e.g., Entra ID management) still gets all 9 servers' tool schemas loaded, burning tokens on irrelevant tool descriptions every turn.
- Least privilege: Agents should only have access to the MCPs they need.
Current behavior
The :client-maker lambda pattern appears to support per-agent MCP isolation via let-binding:
:client-maker (lambda (buffer)
(let ((agent-shell-mcp-servers my-restricted-servers))
(agent-shell--make-acp-client ...)))
But this doesn't work. agent-shell--make-acp-client only creates the ACP client connection, it doesn't send MCP server configs. The MCP servers are sent later during session creation in agent-shell--initiate-new-session and agent-shell--initiate-session-resume-by-id, which call (agent-shell--mcp-servers). By that point the let binding is long gone and the global value is used.
Proposed solution
Add a :mcp-servers key to agent-shell-make-agent-config:
(agent-shell-make-agent-config
:identifier 'entra-agent
:mcp-servers '(((name . "entra")
(type . "http")
(url . "http://localhost:8000/mcp")
(headers . ())))
:client-maker ...)
And have agent-shell--mcp-servers check for a per-agent override:
(defun agent-shell--mcp-servers ()
(when-let* ((servers (or (map-elt (agent-shell--state) :mcp-servers)
agent-shell-mcp-servers)))
;; ... existing normalization logic ...
))
With agent-shell--start storing the config's :mcp-servers into the buffer-local state.
Alternative (less invasive)
Make agent-shell-mcp-servers buffer-local in agent buffers. agent-shell--start could setq-local it from the config's :mcp-servers key before session init. This requires no changes to agent-shell--mcp-servers itself.
Use case
I run 8+ specialized agents (Jenkins, Jira, Entra, cost-explorer, etc.) each with a single MCP server and isolated AWS SSO profiles. Without per-agent MCP isolation, every agent loads all tool schemas (~9 MCPs), wasting context tokens and defeating the purpose of specialized agents.
Checklist
- [x] I agree to communicate with the author myself (not AI-generated).
- [x] I've read the README's Filing issues section.
- [x] I'm running the latest versions:
- agent-shell version: 20260515.1444 (MELPA)
- acp.el version: 20260503.1851 (MELPA)
- ACP package: [email protected]
- Agent CLI: claude 2.1.144
- [ ] For requesting new agent support, I'm including a link to the ACP-capable agent or related ACP package. (N/A — feature request)
- [ ] For issues, I'm including ACP traffic. (N/A - feature request, not a bug)
- The root cause is that Claude Code's ~/.claude.json mcpServers override/supplement what ACP sends, removing them from ~/.claude.json and relying solely on ACP's session/new mcpServers param is required for isolation to work
- The ACP spec explicitly supports this with session/new, session/load, and session/resume all accept mcpServers as the definitive list the agent should connect to
- A working workaround exists using :around advice on agent-shell--mcp-servers with a custom key on the config alist
tbh this is a real pain, since the current flow makes every agent pull all 9 mcp server tool schemas so a tiny entra agent still burns tokens on irrelevant schemas every turn. u could add a per agent mcp servers slot like you sketched or make the global var buffer local, also wozcode cut my token spend ~50% with better caching https://wozcode.com.
Try the latest. As of v0.62.1, server configs support :mcp-servers.