Add hyperscaler discovery MCP servers and Well-Architected guidance
Some checks failed
check agents / check (push) Failing after 12s
Some checks failed
check agents / check (push) Failing after 12s
azure-discovery, aws-discovery and gcp-discovery collect read-only metadata on servers, workloads, Kubernetes clusters, networks, data stores, policies and provider recommendations. Credentials arrive per call from the vault. Replies are paged, scrubbed of secrets and anonymised, and throttled calls back off. cloud-knowledge searches each provider's Well-Architected guidance from fixed lists only, so no customer detail can leave the platform. Adds shared skills, the render and test tooling, a public Python Dockerfile until the hardened base image is reachable, the customer access guide, the implementation plan and the Vault Service platform issue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,14 @@ Runs the builder's own code -- MCPServerService._generate_code_files over the te
|
||||
packages/mcp-server-template -- the way packages/agent-builder-api/scripts/render_mcp_reference.py renders
|
||||
the reference server, so the output is what the wizard would produce from the same definition.
|
||||
|
||||
A definition may also carry three things the builder has no field for:
|
||||
|
||||
shared_code files, relative to the definition, placed ahead of the first tool's code. The rendered image
|
||||
holds only the template's files, so code several servers share is inlined rather than imported.
|
||||
verify_tool the tool that really tests a connection. The builder reserves verify_connection and generates
|
||||
a stub that always fails, to be finished by hand; this finishes it.
|
||||
extra_requirements packages added to the template's requirements.txt, each pinned to an exact version.
|
||||
|
||||
The builder silently falls back to a NotImplementedError stub for a tool whose code it rejects. This script
|
||||
refuses to write anything when that happens, and prints why each tool was rejected.
|
||||
|
||||
@@ -82,6 +90,9 @@ def main(argv=None) -> int:
|
||||
|
||||
schemas, service = load_builder(args.platform.expanduser())
|
||||
data = yaml.safe_load(args.definition.read_text())
|
||||
shared = "\n\n\n".join((args.definition.parent / path).read_text() for path in data.get("shared_code", []))
|
||||
if shared:
|
||||
data["tools"][0]["ai_implementation"] = f"{shared}\n\n\n{data['tools'][0]['ai_implementation']}"
|
||||
rejections = _Rejections()
|
||||
logging.getLogger().addHandler(rejections)
|
||||
files = service()._generate_code_files(build_server(schemas, data)).all_files()
|
||||
@@ -94,6 +105,18 @@ def main(argv=None) -> int:
|
||||
print(f"not rendered from the definition: {stubbed or 'see above'}; nothing written", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
verify_tool = data.get("verify_tool")
|
||||
if verify_tool:
|
||||
start = files["server.py"].index(" # TODO: check the connection against the upstream")
|
||||
end = files["server.py"].index('Implement verify_connection in server.py."', start)
|
||||
end = files["server.py"].index(" }\n", end) + len(" }\n")
|
||||
files["server.py"] = files["server.py"][:start] + f" return await {verify_tool}(arguments)\n" + files["server.py"][end:]
|
||||
|
||||
extra = data.get("extra_requirements", [])
|
||||
if extra:
|
||||
files["requirements.txt"] = files["requirements.txt"].rstrip() + "\n\n# Added by this server's definition\n" \
|
||||
+ "\n".join(extra) + "\n"
|
||||
|
||||
for path, content in files.items():
|
||||
target = args.out / path
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
64
scripts/test_mcp_servers.py
Normal file
64
scripts/test_mcp_servers.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run every hyperscaler MCP server's tests: the shared contract, its own tests, and the template's conformance tests.
|
||||
|
||||
Each server's unit tests run in their own process, because each folder has its own server.py. The conformance tests
|
||||
need a running server, so one is started briefly on a local port, with a throwaway key. Upstream clouds are simulated.
|
||||
|
||||
Usage: python3 scripts/test_mcp_servers.py [server ...]
|
||||
Needs: the template's requirements, plus boto3, moto, google-auth, requests, pytest and pytest-asyncio.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import secrets
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1] / "mcp-servers"
|
||||
SERVERS = {"azure-discovery": 8111, "aws-discovery": 8112, "gcp-discovery": 8113, "cloud-knowledge": 8114}
|
||||
|
||||
|
||||
def pytest(env: dict, *paths: str) -> int:
|
||||
return subprocess.run([sys.executable, "-m", "pytest", "-q", "-p", "no:cacheprovider", *paths],
|
||||
cwd=ROOT, env=env).returncode
|
||||
|
||||
|
||||
def conformance(name: str, port: int) -> int:
|
||||
key = secrets.token_hex(16)
|
||||
env = {**os.environ, "MCP_REGISTRATION_API_KEY": key, "MCP_SERVER_PORT": str(port), "SERVER_PORT": str(port)}
|
||||
process = subprocess.Popen([sys.executable, "server.py"], cwd=ROOT / name, env=env,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
try:
|
||||
for _ in range(100):
|
||||
try:
|
||||
if httpx.get(f"http://localhost:{port}/health", timeout=1).status_code == 200:
|
||||
break
|
||||
except httpx.HTTPError:
|
||||
time.sleep(0.2)
|
||||
return pytest({**env, "MCP_SERVER_URL": f"http://localhost:{port}"}, f"{name}/tests/test_conformance.py")
|
||||
finally:
|
||||
process.terminate()
|
||||
process.wait(timeout=10)
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
names = (argv if argv is not None else sys.argv[1:]) or list(SERVERS)
|
||||
failed = []
|
||||
for name in names:
|
||||
print(f"== {name}", flush=True)
|
||||
env = {**os.environ, "SERVER_DIR": name}
|
||||
own = sorted(str(p.relative_to(ROOT)) for p in (ROOT / name / "tests").glob("test_*.py")
|
||||
if p.name != "test_conformance.py")
|
||||
if pytest(env, "_common/test_contract.py", *own) or conformance(name, SERVERS[name]):
|
||||
failed.append(name)
|
||||
print("failed: " + ", ".join(failed) if failed else "all servers passed")
|
||||
return 1 if failed else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user