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
Problem
agent-shell-make-agent-confighas no:mcp-serversslot. The only way to configure MCP servers is the globalagent-shell-mcp-serversvariable, which means every agent session gets the same full set of MCP servers regardless of which agent config is selected.This matters for:
Current behavior
The
:client-makerlambda pattern appears to support per-agent MCP isolation vialet-binding:But this doesn't work.
agent-shell--make-acp-clientonly creates the ACP client connection, it doesn't send MCP server configs. The MCP servers are sent later during session creation inagent-shell--initiate-new-sessionandagent-shell--initiate-session-resume-by-id, which call(agent-shell--mcp-servers). By that point theletbinding is long gone and the global value is used.Proposed solution
Add a
:mcp-serverskey toagent-shell-make-agent-config:And have
agent-shell--mcp-serverscheck for a per-agent override:With
agent-shell--startstoring the config's:mcp-serversinto the buffer-local state.Alternative (less invasive)
Make
agent-shell-mcp-serversbuffer-local in agent buffers.agent-shell--startcouldsetq-localit from the config's:mcp-serverskey before session init. This requires no changes toagent-shell--mcp-serversitself.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