Skip to content

Commit b347240

Browse files
move .mcp.json into runners
Signed-off-by: Michael Clifford <mcliffor@redhat.com>
1 parent 77841b8 commit b347240

File tree

2 files changed

+19
-51
lines changed

2 files changed

+19
-51
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mcpServers": {}
3+
}

components/runners/claude-code-runner/wrapper.py

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,72 +1813,37 @@ def _filter_mcp_servers(self, servers: dict) -> dict:
18131813
return allowed_servers
18141814

18151815
def _load_mcp_config(self, cwd_path: str) -> dict | None:
1816-
"""Load MCP server configuration from .mcp.json file in the workspace.
1816+
"""Load MCP server configuration from the vTeam runner's .mcp.json file.
18171817
1818-
Searches for .mcp.json in the following locations:
1819-
1. MCP_CONFIG_PATH environment variable (if set)
1820-
2. cwd_path/.mcp.json (main working directory)
1821-
3. workspace root/.mcp.json (for multi-repo setups)
1818+
Only loads MCP servers from the centrally-controlled configuration file
1819+
in the runner's own directory. Does NOT load from user workspace repos
1820+
for security reasons.
1821+
1822+
The .mcp.json file should be located at:
1823+
/app/claude-runner/.mcp.json (in the container)
18221824
18231825
Only allows http and sse type MCP servers.
18241826
18251827
Returns the parsed MCP servers configuration dict, or None if not found.
18261828
"""
18271829
try:
1828-
# Check if MCP discovery is disabled
1829-
if os.getenv('MCP_CONFIG_SEARCH', '').strip().lower() in ('0', 'false', 'no'):
1830-
logging.info("MCP config search disabled by MCP_CONFIG_SEARCH env var")
1831-
return None
1832-
1833-
# Option 1: Explicit path from environment
1834-
explicit_path = os.getenv('MCP_CONFIG_PATH', '').strip()
1835-
if explicit_path:
1836-
mcp_file = Path(explicit_path)
1837-
if mcp_file.exists() and mcp_file.is_file():
1838-
logging.info(f"Loading MCP config from MCP_CONFIG_PATH: {mcp_file}")
1839-
with open(mcp_file, 'r') as f:
1840-
config = _json.load(f)
1841-
all_servers = config.get('mcpServers', {})
1842-
filtered_servers = self._filter_mcp_servers(all_servers)
1843-
if filtered_servers:
1844-
logging.info(f"MCP servers loaded: {list(filtered_servers.keys())}")
1845-
return filtered_servers
1846-
logging.info("No valid MCP servers found after filtering")
1847-
return None
1848-
else:
1849-
logging.warning(f"MCP_CONFIG_PATH specified but file not found: {explicit_path}")
1830+
# Only load from the runner's own directory
1831+
runner_mcp_file = Path("/app/claude-runner/.mcp.json")
18501832

1851-
# Option 2: Look in cwd_path (main working directory)
1852-
mcp_file = Path(cwd_path) / ".mcp.json"
1853-
if mcp_file.exists() and mcp_file.is_file():
1854-
logging.info(f"Found .mcp.json in working directory: {mcp_file}")
1855-
with open(mcp_file, 'r') as f:
1833+
if runner_mcp_file.exists() and runner_mcp_file.is_file():
1834+
logging.info(f"Loading MCP config from runner directory: {runner_mcp_file}")
1835+
with open(runner_mcp_file, 'r') as f:
18561836
config = _json.load(f)
18571837
all_servers = config.get('mcpServers', {})
18581838
filtered_servers = self._filter_mcp_servers(all_servers)
18591839
if filtered_servers:
1860-
logging.info(f"MCP servers loaded from {mcp_file}: {list(filtered_servers.keys())}")
1840+
logging.info(f"MCP servers loaded: {list(filtered_servers.keys())}")
18611841
return filtered_servers
18621842
logging.info("No valid MCP servers found after filtering")
18631843
return None
1864-
1865-
# Option 3: Look in workspace root (for multi-repo setups)
1866-
if self.context and self.context.workspace_path != cwd_path:
1867-
workspace_mcp_file = Path(self.context.workspace_path) / ".mcp.json"
1868-
if workspace_mcp_file.exists() and workspace_mcp_file.is_file():
1869-
logging.info(f"Found .mcp.json in workspace root: {workspace_mcp_file}")
1870-
with open(workspace_mcp_file, 'r') as f:
1871-
config = _json.load(f)
1872-
all_servers = config.get('mcpServers', {})
1873-
filtered_servers = self._filter_mcp_servers(all_servers)
1874-
if filtered_servers:
1875-
logging.info(f"MCP servers loaded from {workspace_mcp_file}: {list(filtered_servers.keys())}")
1876-
return filtered_servers
1877-
logging.info("No valid MCP servers found after filtering")
1878-
return None
1879-
1880-
logging.info("No .mcp.json file found in any search location")
1881-
return None
1844+
else:
1845+
logging.info("No .mcp.json file found in runner directory")
1846+
return None
18821847

18831848
except _json.JSONDecodeError as e:
18841849
logging.error(f"Failed to parse .mcp.json: {e}")

0 commit comments

Comments
 (0)