feat: add local tools and read-only remote MCP servers

Increment 6 of .scratch/solution-architect-agent/spec.md, test-first.

- app/tools/mcp.py: MCP client and catalog exposing only allowlisted,
  readOnlyHint tools as framework-neutral ToolSpecs; unreachable servers
  and failed calls become discovery gaps; ADC auth with quota project.
- app/tools/local.py: Mermaid structure check and Terraform fmt,
  validate and plan in a scratch copy; apply is never constructed.
- Tool factory gives roles their named local tools and bundle MCP
  servers; pillar advisors get general-tier documentation tools.
- providers/gcp.yaml: 42 allowlisted tools reviewed against live
  tools/list of 12 Google Cloud MCP servers (snapshot in
  providers/reviews/), excluding data-reading and secret-capable tools.
- scripts/list-mcp-tools.py, docs/operations/mcp-access.md (IAM deny
  policy, service account roles), cloud-discovery and iac-validation
  Skills, MCP and Terraform settings, pytest asyncio auto mode.
- 31 new tests; full suite 189 passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-16 10:14:05 +01:00
parent f040493583
commit ed104e5697
37 changed files with 2302 additions and 65 deletions

View File

@@ -177,3 +177,44 @@ def test_invalid_bundles_are_rejected(tmp_path, override, message):
with pytest.raises(ProviderConfigError, match=message):
load_provider("test", root=tmp_path)
REVIEW = REPO_ROOT / "providers" / "reviews" / "gcp-mcp-tools.json"
def test_every_allowlisted_mcp_tool_was_reviewed_as_read_only():
import json
review = json.loads(REVIEW.read_text(encoding="utf-8"))
bundle = load_provider("gcp")
for server in bundle.mcp_servers.values():
assert server.allow, f"{server.id} exposes no tools"
reviewed = {tool["name"]: tool for tool in review[server.id]["tools"]}
for name in server.allow:
assert name in reviewed, (
f"{server.id}.{name} was not in the reviewed tools/list"
)
assert reviewed[name]["read_only"], f"{server.id}.{name} is not read-only"
def test_data_reading_and_secret_capable_tools_stay_excluded():
bundle = load_provider("gcp")
excluded = {
"cloud_sql": {"execute_sql", "execute_sql_readonly"},
"storage": {"read_object", "read_text", "list_objects"},
"gke": {"get_k8s_resource", "describe_k8s_resource"},
}
for server_id, tools in excluded.items():
assert not tools & set(bundle.mcp_servers[server_id].allow), server_id
def test_bundle_places_each_local_tool_in_its_own_tier():
from app.tools.local import LOCAL_TOOLS
bundle = load_provider("gcp")
for tier, names in bundle.tools.items():
for name in names:
assert LOCAL_TOOLS[name][0] == tier, name