POST /mcp — Streamable HTTP JSON-RPC 2.0 (MCP spec 2024-11-05)
11 governance tools for consortia builders:
request_ac — AC issuance (wraps /governance/authorize/)
validate_ac — AC validation (wraps /governance/authorize/{token}/)
post_cr — CR posting (wraps /governance/complete/)
query_accord — AccordTemplate lookup
request_delegation — proxy to LLM Principal Broker
revoke_delegation — proxy to LLM Principal Broker
get_delegation — proxy to LLM Principal Broker
list_agents — proxy to LLM Principal Broker
get_posture — DEFCON level and restrictions (30s cache)
check_operation — dry-run operation check against posture
session_info — current session context
Tool handlers call existing broker internals — no logic duplication.
Delegation tools proxy to LLM Principal Broker via HTTP.
Every tool call recorded in Chronicle (MCP_TOOL_CALL 0x3020).
Any MCP-compatible agent can discover and use governance operations
through standard protocol — no Capstone, no Django required.
All 7 smoke tests pass (init, list, posture, check_op, session, accord, error).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
31 lines
1.5 KiB
Python
31 lines
1.5 KiB
Python
"""fastapi-gsap: Lightweight GSAP broker — GCAP-SPEC-SHELLBOUND-BROKER-0001."""
|
|
import structlog
|
|
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from gsap_broker.settings import settings
|
|
from gsap_broker.db import init_db
|
|
from gsap_broker.routers import authorize, complete, session, elevate, health, drivers, connectors, functions
|
|
from gsap_broker import mcp
|
|
|
|
logger = structlog.get_logger()
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await init_db()
|
|
logger.info("fastapi-gsap started", broker_did=settings.broker_did)
|
|
yield
|
|
|
|
app = FastAPI(title="fastapi-gsap", description="GSAP broker PoC — GCAP-SPEC-SHELLBOUND-BROKER-0001",
|
|
version="0.1.0", lifespan=lifespan)
|
|
app.add_middleware(CORSMiddleware, allow_origins=settings.cors_origins, allow_credentials=True,
|
|
allow_methods=["*"], allow_headers=["*"])
|
|
app.include_router(authorize.router, prefix="/governance", tags=["AC"])
|
|
app.include_router(complete.router, prefix="/governance", tags=["CR"])
|
|
app.include_router(session.router, prefix="/governance", tags=["Session"])
|
|
app.include_router(elevate.router, prefix="/governance", tags=["Elevation"])
|
|
app.include_router(drivers.router, prefix="/governance", tags=["Drivers"])
|
|
app.include_router(connectors.router, prefix="/connectors", tags=["Connectors"])
|
|
app.include_router(functions.router, prefix="/functions", tags=["Functions"])
|
|
app.include_router(health.router, tags=["Health"])
|
|
app.include_router(mcp.router, tags=["MCP"])
|