Private
Public Access
0
0

fix(tier2): override MCP server path + reset mcp_paths.toml in clone

Follow-up to 9cd85364. The previous fix patched the OpenCode session-
level permission.read/write allowlist to include the sandbox clone
path, but Tier 2 was still hitting 'ACCESS DENIED' on clone paths.

Root cause: the MCP server has its OWN allowlist that's separate from
OpenCode's session-level permission. The MCP server's allowlist =
project_root (parent dir of the script) + extra_dirs from
mcp_paths.toml in the project root. The clone inherited the main
repo's mcp.manual-slop.command via 'git clone', which launched
C:\\projects\\manual_slop\\scripts\\mcp_server.py with
PYTHONPATH=C:\\projects\\manual_slop\\src. So the MCP server was
using the main repo's project_root + the main repo's mcp_paths.toml
(extra_dirs=['C:/projects/gencpp']) -- exactly the
'Allowed base directories are: gencpp, manual_slop' the user saw.

Fix: setup_tier2_clone.ps1 now overrides the clone's mcp.manual-slop
config to point at the CLONE's scripts/mcp_server.py and src/, and
replaces the clone's mcp_paths.toml with an empty extra_dirs list.
The MCP server's allowlist becomes [C:\\projects\\manual_slop_tier2]
only -- the sandbox boundary.

Added test_setup_script_overrides_mcp_server (text-based regression)
to assert the script contains the required overrides. Opt-in via
TIER2_SANDBOX_TESTS=1.

Verified: re-ran setup against the live clone. opencode.json now has
mcp.manual-slop.command pointing at C:\\projects\\manual_slop_tier2\\
scripts\\mcp_server.py with PYTHONPATH=C:\\projects\\manual_slop_tier2\\
src. mcp_paths.toml has 'extra_dirs = []'.
This commit is contained in:
2026-06-17 14:42:10 -04:00
parent b6caca4096
commit fd5175bf7b
2 changed files with 43 additions and 0 deletions
+28
View File
@@ -83,8 +83,36 @@ if ($PSCmdlet.ShouldProcess("Bootstrap Tier 2 clone at $Tier2ClonePath")) {
$existing | ConvertTo-Json -Depth 10 | Set-Content $cloneConfig
} else {
Copy-Item -Force "$MainRepoPath\conductor\tier2\opencode.json.fragment" $cloneConfig
$existing = $fragment
}
# Override the MCP server's command + PYTHONPATH to point at the
# Tier 2 clone's files. The inherited config points to the main
# repo's scripts/mcp_server.py, which loads the main repo's
# project_root (C:\projects\manual_slop) and reads the main repo's
# mcp_paths.toml (which allowlists C:\projects\gencpp). When Tier 2
# calls manual-slop_read_file on a clone path, the MCP server
# rejects it with "Allowed base directories are: manual_slop, gencpp".
# The fix: launch the MCP server from the clone's path with the
# clone's PYTHONPATH, and replace the clone's mcp_paths.toml with
# an empty one so the clone's MCP server has no extra_dirs.
if ($existing.mcp -and $existing.mcp.'manual-slop') {
$existing.mcp.'manual-slop'.command = @(
"$env:USERPROFILE\scoop\apps\uv\current\uv.exe",
"run",
"python",
"$Tier2ClonePath\scripts\mcp_server.py"
)
$existing.mcp.'manual-slop'.environment.PYTHONPATH = "$Tier2ClonePath\src"
$existing | ConvertTo-Json -Depth 10 | Set-Content $cloneConfig
}
$cloneMcpPaths = "$Tier2ClonePath\mcp_paths.toml"
@"
[allowed_paths]
extra_dirs = []
"@ | Set-Content -Path $cloneMcpPaths -NoNewline
Write-Host "[tier2-bootstrap] MCP server pointed at clone; mcp_paths.toml reset to empty extra_dirs"
# 4. Install git hooks
Write-Host "[tier2-bootstrap] installing git hooks"
Copy-Item -Force "$MainRepoPath\conductor\tier2\githooks\pre-push" "$Tier2ClonePath\.git\hooks\pre-push"