Coverage for gco_mcp/resources/config.py: 92.00%
21 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-30 21:22 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-30 21:22 +0000
1"""Current configuration resources for the GCO MCP server."""
3from cli_runner import PROJECT_ROOT # runtime-resolved checkout root (uvx-safe)
4from feature_flags import ALL_FLAGS, FLAG_ALL_TOOLS
5from server import mcp
7_FLAG_DESCRIPTIONS = {
8 "GCO_ENABLE_CAPACITY_PURCHASE": "Enable cost-incurring capacity reservation tools.",
9 "GCO_ENABLE_MODEL_UPLOAD": "Enable local model-data uploads to central or regional S3.",
10 "GCO_ENABLE_IMAGE_PUBLISH": "Enable image build, push, and mirror operations.",
11 "GCO_ENABLE_INFRASTRUCTURE_DEPLOY": "Enable infrastructure deployment tools.",
12 "GCO_ENABLE_INFRASTRUCTURE_DESTROY": "Enable infrastructure destroy tools.",
13 "GCO_ENABLE_DESTRUCTIVE_OPERATIONS": "Enable irreversible deletion/cancellation tools.",
14 "GCO_ENABLE_MISSION": "Enable autonomous Mission tools.",
15 "GCO_ENABLE_LOCAL_METRICS": "Enable reads beneath GCO_METRICS_LOCAL_ROOT.",
16 "GCO_ENABLE_LOCAL_STORAGE_SYNC": "Enable local storage sync operations.",
17 "GCO_ENABLE_SEMANTIC_PROGRESS": "Enable LLM-based semantic progress scoring.",
18}
21@mcp.resource("config://gco/index")
22def config_index() -> str:
23 """List authoritative CDK and MCP configuration resources."""
24 return "\n".join(
25 [
26 "# GCO Configuration\n",
27 "## Authoritative Configuration",
28 "- `config://gco/cdk.json` — Current CDK deployment configuration",
29 "- `mcp://gco/feature-flags` — Live MCP feature flags and gated tools",
30 "- `config://gco/env-vars` — MCP, CLI, and service environment variables\n",
31 "## Related",
32 "- `source://gco/config/pyproject.toml` — Python project metadata",
33 "- `source://gco/config/app.py` — CDK app entry point",
34 "- `docs://gco/docs/CUSTOMIZATION` — Full customization guide",
35 ]
36 )
39@mcp.resource("config://gco/cdk.json")
40def cdk_json_resource() -> str:
41 """Read the authoritative CDK deployment configuration without projection."""
42 path = PROJECT_ROOT / "cdk.json"
43 if not path.is_file(): 43 ↛ 44line 43 didn't jump to line 44 because the condition on line 43 was never true
44 return "cdk.json not found."
45 return path.read_text()
48@mcp.resource("config://gco/env-vars")
49def env_vars_resource() -> str:
50 """List MCP feature flags and operational environment variables."""
51 lines = [
52 "# GCO Environment Variables\n",
53 "## MCP Server\n",
54 "| Variable | Default | Description |",
55 "|----------|---------|-------------|",
56 "| `GCO_MCP_ROLE_ARN` | (unset) | IAM role ARN assumed when the server starts. |",
57 "| `GCO_MCP_ROLE_SESSION_NAME` | `gco-mcp-server` | Assumed-role session name. |",
58 "| `GCO_MCP_ROLE_DURATION_SECONDS` | `3600` | Assumed-role credential duration. |",
59 "| `GCO_MCP_TOOL_SEARCH` | `bm25` | Tool catalog mode: bm25, regex, code_mode, or off. |",
60 "| `GCO_MCP_CODE_MODE_MAX_DURATION_SECS` | `30` | Code Mode execution time limit. |",
61 "| `GCO_MCP_CODE_MODE_MAX_MEMORY` | `200000000` | Code Mode memory limit in bytes. |",
62 f"| `{FLAG_ALL_TOOLS}` | `false` | Enable every per-tool feature gate. |",
63 ]
64 for flag in ALL_FLAGS:
65 description = _FLAG_DESCRIPTIONS.get(flag, "Enable the corresponding gated MCP tools.")
66 lines.append(f"| `{flag}` | `false` | {description} |")
67 lines.extend(
68 [
69 "| `GCO_STORAGE_LOCAL_ROOT` | (unset) | Required root for model uploads and storage sync; relative paths resolve beneath it and short uploads use a descriptor-backed same-filesystem snapshot. |",
70 "| `GCO_METRICS_LOCAL_ROOT` | (unset) | Required root for local metric-file reads. |",
71 "| `GCO_TASK_STATUS_DIR` | `~/.gco/tasks` | Private bounded task status/log directory. |",
72 "| `GCO_DISABLE_TASK_STATUS` | `false` | Disable disk-backed task status emission. |",
73 "| `FASTMCP_DOCKET_URL` | `memory://` | FastMCP background-task store. |",
74 "\n## CLI\n",
75 "| Variable | Default | Description |",
76 "|----------|---------|-------------|",
77 "| `AWS_REGION` | (from config) | Default AWS region for CLI commands. |",
78 "| `AWS_PROFILE` | (default) | AWS CLI profile to use. |",
79 "| `GCO_CONFIG_PATH` | `cdk.json` | Path to the CDK configuration file. |",
80 "\n## Services (Kubernetes)\n",
81 "| Variable | Default | Description |",
82 "|----------|---------|-------------|",
83 "| `AUTH_SECRET_ARN` | (from stack) | Secrets Manager ARN for authentication. |",
84 "| `CLUSTER_NAME` | (from stack) | EKS cluster name. |",
85 "| `JOB_QUEUE_URL` | (from stack) | SQS job queue URL. |",
86 "| `DLQ_URL` | (from stack) | Dead-letter queue URL. |",
87 "| `DYNAMODB_TABLE` | (from stack) | Job/template/webhook table name. |",
88 ]
89 )
90 return "\n".join(lines)