- Scripts to run workflows from a YAML context or run inputs (kab_run_workflow.py, with --input name=@file), store per-project discovery connections, bootstrap agent MCP keys, refresh the KAB token, publish reports and build estate snapshots. - Hyperscaler discovery servers extended in place; cloud-knowledge folded into them. - deploy/crucible-kab-dev.yaml: the Discovery package agent and the Assessment agents. - Platform issue write-ups and current-wiring notes under docs/platform-issues/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
283 lines
12 KiB
YAML
283 lines
12 KiB
YAML
# Read-only discovery of a customer's Google Cloud estate. Render with scripts/render_mcp_server.py.
|
|
# Credentials arrive per call from the Vault Service. Store them per project, never tenant-wide.
|
|
|
|
server_id: gcp-discovery
|
|
name: Google Cloud Discovery
|
|
description: Read-only discovery of a customer's Google Cloud estate - servers, workloads, Kubernetes clusters,
|
|
networks, data stores, policies and Recommender findings - through Cloud Asset Inventory.
|
|
version: 0.1.4
|
|
port: 8113
|
|
verify_tool: gcp_check_connection
|
|
shared_code:
|
|
- _common/tool_support.py
|
|
- _common/gcp_support.py
|
|
- _common/knowledge_support.py
|
|
extra_requirements:
|
|
- google-auth==2.62.0
|
|
- requests==2.32.5
|
|
connection_fields:
|
|
- name: scope_root
|
|
title: Scope root
|
|
description: 'What may be read: organizations/<id>, folders/<id> or projects/<id>.'
|
|
required: true
|
|
secret: false
|
|
- name: quota_project
|
|
title: Quota project
|
|
description: Optional. The project Google bills Recommender and guidance calls to, for a user token; defaults to a projects/<id> scope root. The caller needs serviceusage.services.use on it.
|
|
required: false
|
|
secret: false
|
|
- name: service_account_json
|
|
title: Service account key
|
|
description: The read-only service account's JSON key.
|
|
required: false
|
|
secret: true
|
|
- name: access_token
|
|
title: Access token
|
|
description: For a short trial only, instead of the key. A token from gcloud auth print-access-token. It expires within about an hour and carries that person's rights.
|
|
required: false
|
|
secret: true
|
|
tools:
|
|
- name: gcp_check_connection
|
|
display_name: Check connection
|
|
description: 'Test the stored connection: sign in and search the scope root. Returns no customer data.'
|
|
parameters: []
|
|
ai_implementation: |
|
|
async def gcp_check_connection(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
try:
|
|
await _gcp_get(f"{GCP_ASSET_API}/{_gcp_scope()}:searchAllResources", {"pageSize": 1})
|
|
except Exception as error:
|
|
return {"ok": False, "message": _upstream_failed("gcp", error)["error"]["message"]}
|
|
return {"ok": True, "message": "Signed in and searched the scope root."}
|
|
- name: gcp_list_accounts
|
|
display_name: List accounts
|
|
description: 'List the estate structure: projects or folders under the scope root.'
|
|
parameters:
|
|
- name: kind
|
|
type: string
|
|
description: 'One of: projects, folders.'
|
|
required: false
|
|
- &id001
|
|
name: page_size
|
|
type: integer
|
|
description: Items per page, up to 200. Default 50.
|
|
required: false
|
|
- &id002
|
|
name: page_token
|
|
type: string
|
|
description: next_page_token from the previous reply.
|
|
required: false
|
|
ai_implementation: |
|
|
async def gcp_list_accounts(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
return await _gcp_kind("gcp_list_accounts", arguments, GCP_ACCOUNTS, "projects")
|
|
- name: gcp_list_resources
|
|
display_name: List resources
|
|
description: List every resource under the scope root, or one asset type.
|
|
parameters:
|
|
- name: asset_type
|
|
type: string
|
|
description: Optional asset type, such as compute.googleapis.com/Instance.
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_resources(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
asset_type = arguments.get("asset_type")
|
|
if asset_type and not re.fullmatch(r"[a-z0-9.]+\.googleapis\.com/[A-Za-z0-9]+", str(asset_type)):
|
|
return _refuse("invalid_argument", "asset_type must look like compute.googleapis.com/Instance")
|
|
return await _gcp_search("gcp_list_resources", arguments, [asset_type] if asset_type else [])
|
|
- name: gcp_query_resources
|
|
display_name: Query resources
|
|
description: Search resources under the scope root with Cloud Asset's query syntax.
|
|
parameters:
|
|
- name: query
|
|
type: string
|
|
description: A Cloud Asset search query, such as location:europe-west2.
|
|
required: true
|
|
- name: asset_type
|
|
type: string
|
|
description: Optional asset type.
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_query_resources(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
query = str(arguments.get("query") or "").strip()
|
|
if not query or len(query) > 2000:
|
|
return _refuse("invalid_argument", "query is required, up to 2000 characters")
|
|
asset_type = arguments.get("asset_type")
|
|
return await _gcp_search("gcp_query_resources", arguments, [asset_type] if asset_type else [], query)
|
|
- name: gcp_get_resource_metadata
|
|
display_name: Get resource metadata
|
|
description: Read-only provider metadata for one resource under the scope root.
|
|
parameters:
|
|
- name: resource_name
|
|
type: string
|
|
description: The full resource name, starting //.
|
|
required: true
|
|
- name: scope_entry_id
|
|
type: string
|
|
description: The scope entry this answers, echoed in the reply.
|
|
required: false
|
|
ai_implementation: |
|
|
async def gcp_get_resource_metadata(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
name = str(arguments.get("resource_name") or "")
|
|
if not re.fullmatch(r"//[a-z0-9.]+\.googleapis\.com/[A-Za-z0-9._/\-]+", name):
|
|
return _refuse("invalid_argument", "resource_name must be a full resource name")
|
|
try:
|
|
body = await _gcp_get(f"{GCP_ASSET_API}/{_gcp_scope()}:searchAllResources", {"query": f'name="{name}"', "readMask": "*", "pageSize": 5})
|
|
except Exception as error:
|
|
return _upstream_failed("gcp", error)
|
|
found = [r for r in body.get("results", []) if r.get("name") == name]
|
|
if not found:
|
|
return _refuse("outside_scope", "no such resource under this connection's scope")
|
|
return _one_result("gcp", "gcp_get_resource_metadata", arguments, found[0])
|
|
- name: gcp_list_servers
|
|
display_name: List servers
|
|
description: List Compute Engine instances, instance groups or disks.
|
|
parameters:
|
|
- name: kind
|
|
type: string
|
|
description: 'One of: instances, instance_groups, disks.'
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_servers(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
return await _gcp_kind("gcp_list_servers", arguments, GCP_SERVERS, "instances")
|
|
- name: gcp_list_workloads
|
|
display_name: List workloads
|
|
description: List Cloud Run services, Cloud Functions or App Engine services. Environment variables are removed.
|
|
parameters:
|
|
- name: kind
|
|
type: string
|
|
description: 'One of: cloud_run, cloud_functions, app_engine.'
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_workloads(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
return await _gcp_kind("gcp_list_workloads", arguments, GCP_WORKLOADS, "cloud_run")
|
|
- name: gcp_list_kubernetes_clusters
|
|
display_name: List Kubernetes clusters
|
|
description: List GKE clusters or node pools with version and networking. Stops at the cloud control plane.
|
|
parameters:
|
|
- name: kind
|
|
type: string
|
|
description: 'One of: clusters, node_pools.'
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_kubernetes_clusters(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
return await _gcp_kind("gcp_list_kubernetes_clusters", arguments, GCP_KUBERNETES, "clusters")
|
|
- name: gcp_get_network_topology
|
|
display_name: Get network topology
|
|
description: List VPC networks, subnetworks, routes, firewall rules, load balancers or gateways.
|
|
parameters:
|
|
- name: kind
|
|
type: string
|
|
description: 'One of: networks, subnetworks, routes, firewall_rules, load_balancers, gateways.'
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_get_network_topology(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
return await _gcp_kind("gcp_get_network_topology", arguments, GCP_NETWORK, "networks")
|
|
- name: gcp_list_data_stores
|
|
display_name: List data stores
|
|
description: List Cloud SQL instances, Firestore databases or Cloud Storage buckets. Metadata only.
|
|
parameters:
|
|
- name: kind
|
|
type: string
|
|
description: 'One of: cloud_sql, firestore, cloud_storage.'
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_data_stores(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
return await _gcp_kind("gcp_list_data_stores", arguments, GCP_DATA, "cloud_sql")
|
|
- name: gcp_list_organization_policies
|
|
display_name: List organization policies
|
|
description: List Organization Policy constraints set at the scope root, or VPC Service Controls perimeters.
|
|
parameters:
|
|
- name: kind
|
|
type: string
|
|
description: 'One of: organization_policies, vpc_service_controls.'
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_organization_policies(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
kind = arguments.get("kind") or "organization_policies"
|
|
if kind == "vpc_service_controls":
|
|
return await _gcp_kind("gcp_list_organization_policies", arguments, GCP_PERIMETERS, kind)
|
|
if kind != "organization_policies":
|
|
return _refuse("unknown_kind", "kind must be organization_policies or vpc_service_controls")
|
|
return await _gcp_page("gcp_list_organization_policies", arguments, f"{GCP_ORG_POLICY_API}/{_gcp_scope()}/policies", {}, "policies")
|
|
- name: gcp_list_resource_policies
|
|
display_name: List resource policies
|
|
description: List IAM policies set on resources under the scope root. People and groups are anonymised; service
|
|
accounts stay.
|
|
parameters:
|
|
- name: query
|
|
type: string
|
|
description: Optional Cloud Asset IAM search query.
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_resource_policies(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
params = {"query": arguments["query"]} if arguments.get("query") else {}
|
|
return await _gcp_page("gcp_list_resource_policies", arguments, f"{GCP_ASSET_API}/{_gcp_scope()}:searchAllIamPolicies", params, "results")
|
|
- name: gcp_list_recommendations
|
|
display_name: List recommendations
|
|
description: List Recommender findings for one project, each with a common Well-Architected pillar.
|
|
parameters:
|
|
- name: project_id
|
|
type: string
|
|
description: A project under the scope root.
|
|
required: true
|
|
- name: recommender
|
|
type: string
|
|
description: 'One of the supported recommender ids. Default: machine type.'
|
|
required: false
|
|
- name: location
|
|
type: string
|
|
description: A zone or region. Default global.
|
|
required: false
|
|
- *id001
|
|
- *id002
|
|
ai_implementation: |
|
|
async def gcp_list_recommendations(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
project_id = str(arguments.get("project_id") or "")
|
|
location = str(arguments.get("location") or "global")
|
|
recommender = arguments.get("recommender") or GCP_RECOMMENDERS[0]
|
|
if recommender not in GCP_RECOMMENDERS:
|
|
return _refuse("unknown_kind", "recommender must be one of: " + ", ".join(GCP_RECOMMENDERS))
|
|
if not re.fullmatch(r"[a-z0-9\-]+", project_id) or not re.fullmatch(r"[a-z0-9\-]+", location):
|
|
return _refuse("invalid_argument", "project_id and location must be plain identifiers")
|
|
try:
|
|
allowed = await _gcp_project_in_scope(project_id)
|
|
except Exception as error:
|
|
return _upstream_failed("gcp", error)
|
|
if not allowed:
|
|
return _refuse("outside_scope", "project_id isn't under this connection's scope")
|
|
url = f"{GCP_RECOMMENDER_API}/projects/{project_id}/locations/{location}/recommenders/{recommender}/recommendations"
|
|
return await _gcp_page("gcp_list_recommendations", arguments, url, {}, "recommendations", _gcp_recommendation)
|
|
- name: gcp_search_well_architected
|
|
display_name: Search Well-Architected guidance
|
|
description: Search the Google Cloud Well-Architected Framework's guidance by pillar and topic. Both come from fixed lists, so no customer detail
|
|
leaves the platform. Uses this connection's own credential.
|
|
parameters:
|
|
- name: pillar
|
|
type: string
|
|
description: reliability, security, cost, operations, performance or sustainability.
|
|
required: true
|
|
- name: topic
|
|
type: string
|
|
description: One of the fixed topics; an invalid value lists them.
|
|
required: true
|
|
ai_implementation: |
|
|
async def gcp_search_well_architected(arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
return await _knowledge_tool("gcp", "gcp_search_well_architected", arguments, get_connection(), await _gcp_auth(True))
|