Platform scripts, MCP servers, deployment and docs for the KAB runs
- 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>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
# cloud-knowledge: calls each hyperscaler's hosted knowledge server over MCP. A query is only ever built from the
|
||||
# fixed lists below, so a customer's name or resource can't reach a third party.
|
||||
# Well-Architected guidance: calls each hyperscaler's hosted knowledge server over MCP. Inlined into the
|
||||
# azure-discovery and gcp-discovery servers (cloud-knowledge, which also used it, was retired on 2026-11-04). A query is only ever built from the fixed lists below, so a
|
||||
# customer's name or resource can't reach a third party. boto3 is imported only for AWS, so the other servers don't
|
||||
# need it.
|
||||
import asyncio
|
||||
import boto3
|
||||
from botocore.auth import SigV4Auth
|
||||
from botocore.awsrequest import AWSRequest
|
||||
|
||||
KNOWLEDGE_SERVERS = {
|
||||
"azure": {"url": "https://learn.microsoft.com/api/mcp", "tool": "microsoft_docs_search",
|
||||
@@ -36,15 +35,23 @@ def _knowledge_message(response) -> Dict[str, Any]:
|
||||
|
||||
|
||||
async def _knowledge_post(provider: str, connection: Dict[str, Any], body: Dict[str, Any],
|
||||
session: Optional[str] = None):
|
||||
session: Optional[str] = None, auth: Optional[Dict[str, str]] = None):
|
||||
"""auth: headers a discovery server supplies from its own connection (gcp-discovery's OAuth token), used in
|
||||
place of the stored API key."""
|
||||
url = KNOWLEDGE_SERVERS[provider]["url"]
|
||||
headers = {"Accept": "application/json, text/event-stream", "Content-Type": "application/json"}
|
||||
if session:
|
||||
headers["Mcp-Session-Id"] = session
|
||||
if provider == "gcp":
|
||||
if auth:
|
||||
headers.update(auth)
|
||||
elif provider == "gcp":
|
||||
headers["X-Goog-Api-Key"] = connection.get("google_api_key", "")
|
||||
content = json.dumps(body)
|
||||
if provider == "aws":
|
||||
import boto3
|
||||
from botocore.auth import SigV4Auth
|
||||
from botocore.awsrequest import AWSRequest
|
||||
|
||||
def sign():
|
||||
credentials = boto3.Session(aws_access_key_id=connection.get("aws_access_key_id"),
|
||||
aws_secret_access_key=connection.get("aws_secret_access_key")).get_credentials()
|
||||
@@ -58,17 +65,18 @@ async def _knowledge_post(provider: str, connection: Dict[str, Any], body: Dict[
|
||||
return response
|
||||
|
||||
|
||||
async def _knowledge_session(provider: str, connection: Dict[str, Any]) -> Optional[str]:
|
||||
async def _knowledge_session(provider: str, connection: Dict[str, Any], auth: Optional[Dict[str, str]] = None) -> Optional[str]:
|
||||
response = await _knowledge_post(provider, connection, {
|
||||
"jsonrpc": "2.0", "id": 1, "method": "initialize",
|
||||
"params": {"protocolVersion": "2025-06-18", "capabilities": {},
|
||||
"clientInfo": {"name": "cloud-knowledge", "version": "0.1.0"}}})
|
||||
"clientInfo": {"name": "kab-cp1-discovery", "version": "0.1.0"}}}, auth=auth)
|
||||
return response.headers.get("mcp-session-id")
|
||||
|
||||
|
||||
async def _knowledge_tools(provider: str, connection: Dict[str, Any], session: Optional[str] = None) -> List[Dict[str, Any]]:
|
||||
session = session or await _knowledge_session(provider, connection)
|
||||
response = await _knowledge_post(provider, connection, {"jsonrpc": "2.0", "id": 2, "method": "tools/list"}, session)
|
||||
async def _knowledge_tools(provider: str, connection: Dict[str, Any], session: Optional[str] = None,
|
||||
auth: Optional[Dict[str, str]] = None) -> List[Dict[str, Any]]:
|
||||
session = session or await _knowledge_session(provider, connection, auth)
|
||||
response = await _knowledge_post(provider, connection, {"jsonrpc": "2.0", "id": 2, "method": "tools/list"}, session, auth)
|
||||
return _knowledge_message(response).get("result", {}).get("tools", [])
|
||||
|
||||
|
||||
@@ -82,15 +90,16 @@ def _knowledge_argument(tool: Dict[str, Any]) -> str:
|
||||
return "query"
|
||||
|
||||
|
||||
async def _knowledge_search(provider: str, connection: Dict[str, Any], query: str) -> List[Dict[str, Any]]:
|
||||
session = await _knowledge_session(provider, connection)
|
||||
async def _knowledge_search(provider: str, connection: Dict[str, Any], query: str,
|
||||
auth: Optional[Dict[str, str]] = None) -> List[Dict[str, Any]]:
|
||||
session = await _knowledge_session(provider, connection, auth)
|
||||
name = KNOWLEDGE_SERVERS[provider]["tool"]
|
||||
tools = {t.get("name"): t for t in await _knowledge_tools(provider, connection, session)}
|
||||
tools = {t.get("name"): t for t in await _knowledge_tools(provider, connection, session, auth)}
|
||||
if name not in tools:
|
||||
raise LookupError(f"{provider} no longer offers {name}")
|
||||
response = await _knowledge_post(provider, connection, {
|
||||
"jsonrpc": "2.0", "id": 3, "method": "tools/call",
|
||||
"params": {"name": name, "arguments": {_knowledge_argument(tools[name]): query}}}, session)
|
||||
"params": {"name": name, "arguments": {_knowledge_argument(tools[name]): query}}}, session, auth)
|
||||
message = _knowledge_message(response)
|
||||
results = []
|
||||
for part in message.get("result", {}).get("content", []):
|
||||
@@ -106,3 +115,20 @@ async def _knowledge_search(provider: str, connection: Dict[str, Any], query: st
|
||||
results.append({"title": item.get("title"), "url": item.get("contentUrl") or item.get("url"),
|
||||
"text": str(item.get("content") or item.get("text") or "")[:KNOWLEDGE_MAX_TEXT]})
|
||||
return results
|
||||
|
||||
|
||||
async def _knowledge_tool(provider: str, tool: str, arguments: Dict[str, Any], connection: Dict[str, Any],
|
||||
auth: Optional[Dict[str, str]] = None) -> Dict[str, Any]:
|
||||
"""One provider's `<provider>_search_well_architected` tool: fixed pillar and topic in, guidance excerpts out."""
|
||||
pillar, topic = arguments.get("pillar"), arguments.get("topic")
|
||||
if pillar not in KNOWLEDGE_PILLARS:
|
||||
return _refuse("invalid_argument", "pillar must be one of: " + ", ".join(KNOWLEDGE_PILLARS))
|
||||
if topic not in KNOWLEDGE_TOPICS:
|
||||
return _refuse("invalid_argument", "topic must be one of: " + ", ".join(KNOWLEDGE_TOPICS))
|
||||
query = f"{KNOWLEDGE_SERVERS[provider]['framework']} {pillar} {topic}"
|
||||
try:
|
||||
results = await _knowledge_search(provider, connection, query, auth)
|
||||
except Exception as error:
|
||||
return _upstream_failed(provider, error)
|
||||
return {"success": True, "data": {"provider": provider, "pillar": pillar, "topic": topic, "results": results,
|
||||
"collected_at": _collected_at(), "evidence_ref": _evidence_ref(tool, arguments, results)}}
|
||||
|
||||
Reference in New Issue
Block a user