Use store.for_agent(agent_id) to create isolated subsets of MCP services for different agents. This prevents context window bloat by ensuring an agent only sees the tools relevant to its specific task.
store.for_agent(agent_id) mirrors most of the interface found in store.for_store(), but operates on a logical subset of the total services.
Example: Isolating Services
from mcpstore import MCPStore
store = MCPStore.setup_store()
# Agent 1 gets wiki access
agent_id1 = "agent1"
store.for_agent(agent_id1).add_service({"name": "mcpstore_wiki", "url": "https://example.com/mcp"})
# Agent 2 gets gitodo access via command line
agent_id2 = "agent2"
store.for_agent(agent_id2).add_service({"name": "gitodo", "command": "uvx", "args": ["gitodo"]})
# Retrieve tools for specific agents
agent1_tools = store.for_agent(agent_id1).list_tools()
agent2_tools = store.for_agent(agent_id2).list_tools()
from mcpstore import MCPStore
store = MCPStore.setup_store()
agent_id1 = "agent1"
store.for_agent(agent_id1).add_service({"name": "mcpstore_wiki", "url": "https://example.com/mcp"})
agent_id2 = "agent2"
store.for_agent(agent_id2).add_service({"name": "gitodo", "command": "uvx", "args": ["gitodo"]})
agent1_tools = store.for_agent(agent_id1).list_tools()
agent2_tools = store.for_agent(agent_id2).list_tools()