openclaw - 💡(How to fix) Fix Feature Request: Per-agent MCP Server Configuration [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#55486Fetched 2026-04-08 01:39:00
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1locked ×1
RAW_BUFFERClick to expand / collapse

Feature Request: Per-agent MCP Server Configuration

Problem

Skills (技能) support per-agent configuration via the workspace/skills directory, but MCP Servers are loaded globally by the gateway and cannot be isolated per agent.

Real-world Scenario

  • User wants only a specific agent (e.g. ai-data-engineer) to access a particular MCP Server (e.g. ontoflow-jtbc)
  • Other agents (e.g. main) do not need this MCP tool, but it still occupies token space in the context window (tool listing is included in context)
  • Skills cannot replace MCP — MCP is a remote service, skills are local tools

Expected Behavior

  • Support per-agent MCP configuration like agents.list[].mcpServers similar to how skills work
  • Or auto-load MCP config from ~/.openclaw/workspace-<agentId>/config/mcporter.json

Reference

Skills already have a per-agent design. MCP configuration could follow the same pattern.

Additional Context

Currently:

  • ~/.mcporter/mcporter.json is loaded globally by the gateway
  • ~/.openclaw/workspace-<agentId>/config/mcporter.json is NOT auto-loaded
  • Skills in ~/.openclaw/workspace-<agentId>/skills/ are per-agent, but mcporter skill only provides CLI access — it does not register MCP tools

This means MCP tools are always visible to all agents, which is not ideal for:

  1. Token optimization (unnecessary tool lists in context)
  2. Security/isolation (not all agents should access all MCP servers)

extent analysis

Fix Plan

To support per-agent MCP server configuration, we will implement the following steps:

  • Introduce a new configuration option agents.list[].mcpServers to allow specifying MCP servers per agent
  • Update the gateway to load MCP configuration from ~/.openclaw/workspace-<agentId>/config/mcporter.json for each agent

Example Code

# config.py
import json
import os

class Config:
    def __init__(self, agent_id):
        self.agent_id = agent_id
        self.mcp_servers = self.load_mcp_servers()

    def load_mcp_servers(self):
        config_file = f"~/.openclaw/workspace-{self.agent_id}/config/mcporter.json"
        if os.path.exists(config_file):
            with open(config_file, "r") as f:
                return json.load(f)
        return []

# gateway.py
import config

class Gateway:
    def __init__(self, agents):
        self.agents = agents
        self.mcp_servers = {}

    def load_mcp_servers(self):
        for agent in self.agents:
            config = Config(agent["id"])
            self.mcp_servers[agent["id"]] = config.mcp_servers

# example usage
agents = [
    {"id": "ai-data-engineer", "name": "AI Data Engineer"},
    {"id": "main", "name": "Main"}
]

gateway = Gateway(agents)
gateway.load_mcp_servers()
print(gateway.mcp_servers)

Verification

To verify that the fix worked, check the following:

  • MCP servers are loaded correctly for each agent
  • Only the specified MCP servers are visible to each agent
  • Token optimization and security/isolation are improved

Extra Tips

  • Make sure to handle cases where the mcporter.json file is missing or invalid
  • Consider adding logging and error handling to the configuration loading process
  • Review the existing skills implementation to ensure consistency with the new MCP server configuration approach

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature Request: Per-agent MCP Server Configuration [1 comments, 1 participants]