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>
97 lines
3.1 KiB
Python
97 lines
3.1 KiB
Python
"""Typed settings for GCP Solution Architecture Agent."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application Settings."""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
# Agent Identity
|
|
AGENT_NAME: str = "gcp_solution_architecture_agent"
|
|
AGENT_VERSION: str = "1.0.0"
|
|
LOG_LEVEL: str = "INFO"
|
|
|
|
# Server Configuration
|
|
HOST: str = "0.0.0.0"
|
|
PORT: int = 8080
|
|
|
|
# LLM Settings
|
|
OPENAI_API_KEY: str | None = None
|
|
AZURE_OPENAI_API_KEY: str | None = None
|
|
AZURE_OPENAI_ENDPOINT: str | None = None
|
|
AZURE_OPENAI_DEPLOYMENT: str = "gpt-4o"
|
|
AZURE_OPENAI_API_VERSION: str = "2024-02-15-preview"
|
|
LLM_TEMPERATURE: float = 0.2
|
|
|
|
# Google Cloud Environment & Scanner Credentials
|
|
GOOGLE_APPLICATION_CREDENTIALS: str | None = None
|
|
GCP_PROJECT_ID: str | None = None
|
|
GCP_REGION: str = "us-central1"
|
|
|
|
# Database & Storage Settings (External PostgreSQL)
|
|
POSTGRES_HOST: str = "localhost"
|
|
POSTGRES_PORT: int = 5432
|
|
POSTGRES_DB: str = "gcp_agent_db"
|
|
POSTGRES_USER: str = "postgres"
|
|
POSTGRES_PASSWORD: str = "postgres"
|
|
DATABASE_URL: str | None = None
|
|
SQLITE_FALLBACK_DB: str = "gcp_agent_local.db"
|
|
|
|
# ADK Multi-Agent Orchestrator Settings
|
|
ADK_MAX_LOOP_ITERATIONS: int = 5
|
|
ADK_ENABLE_ARTIFACT_STORE: bool = True
|
|
|
|
# Cloud Provider Bundle (providers/<name>.yaml) & Remote MCP Servers
|
|
CLOUD_PROVIDER: str = "gcp"
|
|
MCP_ENABLE_PREVIEW: bool = True
|
|
MCP_QUOTA_PROJECT: str | None = None # defaults to the ADC project
|
|
MCP_TIMEOUT_SECONDS: float = 30
|
|
|
|
# Local Terraform tools (fmt, validate, plan; never apply)
|
|
TERRAFORM_BINARY: str = "terraform"
|
|
TERRAFORM_TIMEOUT_SECONDS: float = 300
|
|
TF_PLUGIN_CACHE_DIR: str | None = None
|
|
|
|
# Hierarchical Execution Engine (LangGraph state, ReAct agents)
|
|
ORCHESTRATOR_BUDGET: int = 40
|
|
SPECIALIST_BUDGET: int = 15
|
|
MAX_REVISIONS: int = 3
|
|
MAX_ORCHESTRATOR_TURNS: int = 100
|
|
CHECKPOINTER: str = "sqlite" # memory | sqlite | postgres
|
|
CHECKPOINT_DB_PATH: str = "checkpoints.db"
|
|
|
|
# Google Developer Knowledge MCP Server Settings
|
|
DEVELOPER_KNOWLEDGE_MCP_URL: str = "https://developerknowledge.googleapis.com/mcp"
|
|
DEVELOPER_KNOWLEDGE_MCP_ENABLED: bool = True
|
|
|
|
# Paths
|
|
BASE_DIR: Path = Path(__file__).resolve().parent.parent
|
|
SKILLS_DIR: Path = Path(__file__).resolve().parent / "skills"
|
|
EVAL_DATASET_PATH: Path = Path(__file__).resolve().parent.parent / "eval" / "datasets" / "benchmark_cases.json"
|
|
|
|
def get_database_url(self) -> str:
|
|
"""Construct database connection URL (PostgreSQL or SQLite fallback)."""
|
|
if self.DATABASE_URL:
|
|
return self.DATABASE_URL
|
|
return f"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
|
|
|
|
|
_settings: Settings | None = None
|
|
|
|
|
|
def get_settings() -> Settings:
|
|
"""Get singleton Settings instance."""
|
|
global _settings
|
|
if _settings is None:
|
|
_settings = Settings()
|
|
return _settings
|
|
|