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:
@@ -26,6 +26,7 @@ def pillar_consultation_tool(
|
||||
runtime: AgentRuntime,
|
||||
advisor: RoleSpec,
|
||||
pillar_skills: Mapping[str, str],
|
||||
extra_tools: Sequence[ToolSpec] = (),
|
||||
) -> ToolSpec:
|
||||
"""A tool that runs one pillar advisor per pillar, in parallel, each with its Skill."""
|
||||
|
||||
@@ -39,7 +40,9 @@ def pillar_consultation_tool(
|
||||
)
|
||||
results = await asyncio.gather(
|
||||
*(
|
||||
_advise(runtime, advisor, pillar, pillar_skills[pillar], brief)
|
||||
_advise(
|
||||
runtime, advisor, pillar, pillar_skills[pillar], brief, extra_tools
|
||||
)
|
||||
for pillar in chosen
|
||||
)
|
||||
)
|
||||
@@ -65,7 +68,12 @@ def pillar_consultation_tool(
|
||||
|
||||
|
||||
async def _advise(
|
||||
runtime: AgentRuntime, advisor: RoleSpec, pillar: str, skill: str, brief: str
|
||||
runtime: AgentRuntime,
|
||||
advisor: RoleSpec,
|
||||
pillar: str,
|
||||
skill: str,
|
||||
brief: str,
|
||||
extra_tools: Sequence[ToolSpec],
|
||||
) -> str:
|
||||
role = dataclasses.replace(advisor, skills=(skill,))
|
||||
task = AgentTask(
|
||||
@@ -74,7 +82,7 @@ async def _advise(
|
||||
context={"pillar": pillar, "brief": brief},
|
||||
)
|
||||
try:
|
||||
outcome = await runtime.run(role, task, [_submit_advice_tool()])
|
||||
outcome = await runtime.run(role, task, [_submit_advice_tool(), *extra_tools])
|
||||
except Exception as exc: # noqa: BLE001 - one failed advisor must not lose the others
|
||||
return f"## {pillar}\n\nNo guidance: the advisor failed ({exc})."
|
||||
if isinstance(outcome, Submitted):
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""Which extra tools each role gets beyond the Execution tools.
|
||||
"""Which tools each role gets beyond the Execution tools.
|
||||
|
||||
Increment 6 adds the local general and cloud-read tools and remote MCP servers here.
|
||||
A role gets the local tools its role file names, the tools of the remote MCP servers
|
||||
the provider bundle assigns it, and, for the design advisor, the pillar consultation.
|
||||
Cloud-read gating is applied later, per Execution, by `specialist_tools`.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -12,22 +14,36 @@ from app.agents.runtime import AgentRuntime, RoleSpec, ToolSpec
|
||||
from app.execution.deliverables import DeliverableKind
|
||||
from app.execution.graph import ToolFactory
|
||||
from app.execution.pillars import pillar_consultation_tool
|
||||
from app.tools.mcp import McpCatalog
|
||||
|
||||
|
||||
def make_tool_factory(
|
||||
runtime: AgentRuntime,
|
||||
roles: Mapping[str, RoleSpec],
|
||||
pillar_skills: Mapping[str, str],
|
||||
*,
|
||||
local_tools: Sequence[ToolSpec] = (),
|
||||
catalog: McpCatalog | None = None,
|
||||
) -> ToolFactory:
|
||||
consult = (
|
||||
pillar_consultation_tool(runtime, roles[PILLAR_ADVISOR], pillar_skills)
|
||||
if pillar_skills and PILLAR_ADVISOR in roles
|
||||
else None
|
||||
)
|
||||
local_by_name = {tool.name: tool for tool in local_tools}
|
||||
|
||||
def mcp_tools(role: RoleSpec) -> list[ToolSpec]:
|
||||
return catalog.tools_for(role.mcp_servers) if catalog else []
|
||||
|
||||
consult = None
|
||||
advisor = roles.get(PILLAR_ADVISOR)
|
||||
if pillar_skills and advisor:
|
||||
# Pillar advisors can't ask for permission, so they get general-tier tools only.
|
||||
advisor_tools = [tool for tool in mcp_tools(advisor) if tool.tier == "general"]
|
||||
consult = pillar_consultation_tool(
|
||||
runtime, advisor, pillar_skills, extra_tools=advisor_tools
|
||||
)
|
||||
|
||||
def tools_for(role: RoleSpec, deliverable: str | None) -> Sequence[ToolSpec]:
|
||||
tools = [local_by_name[name] for name in role.tools if name in local_by_name]
|
||||
tools += mcp_tools(role)
|
||||
if consult and deliverable == DeliverableKind.DESIGN_RECOMMENDATIONS.value:
|
||||
return [consult]
|
||||
return []
|
||||
tools.append(consult)
|
||||
return tools
|
||||
|
||||
return tools_for
|
||||
|
||||
Reference in New Issue
Block a user