phase 2 (part 5): MCP server with official Go SDK
- MCP server at /mcp using github.com/modelcontextprotocol/go-sdk v1.6.1 with Streamable HTTP transport - 9 tools implemented: get_entity, list_entities, get_relations, get_blast_radius, get_health_summary, get_audit_trail, search_knowledge, query_metrics, request_execution (policy-gated) - All tools use the untyped ToolHandler pattern with raw JSON argument parsing - Mounted on the same binary and port with bearer/OIDC auth - SSE stream endpoint now handled by oapi-codegen strict handler Phase 2 acceptance criteria: - GET /entities?type=service ✅ (part 1) - MCP list_entities ✅ (part 5) - PATCH /entities with If-Match → 412 ✅ (part 3) - Idempotency-Key replay ✅ (part 3) - SSE stream shows events ✅ (part 4) - Audit rows carry OIDC sub ✅ (part 4) - Spec-conformance tests ⬜ (CI setup, Phase 2 completing) Remaining stubs: CreateEntityType, PatchEntityType, CreateCheck, PatchCheck, RequestExecution, CancelExecution, ListApprovals, DecideApproval, ListExecutions, GetExecution, ListPatterns, PatchPattern, ListSkills, PatchSkill, etc. (Phase 3)
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/dtoro/oikos/internal/db"
|
||||
"github.com/dtoro/oikos/internal/db/sqlcgen"
|
||||
"github.com/dtoro/oikos/internal/httpapi/gen"
|
||||
mcphandler "github.com/dtoro/oikos/internal/mcp"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
@@ -96,10 +97,11 @@ func NewHandler(pool *db.Pool, cfg config.Config) http.Handler {
|
||||
},
|
||||
})
|
||||
|
||||
// Register SSE stream endpoint directly on the chi router with the
|
||||
// same auth middleware, bypassing the oapi-codegen strict handler
|
||||
// (which would buffer the entire response body).
|
||||
r.With(combinedAuth(cfg)).Get("/api/v1/events/stream", s.serveSSE)
|
||||
// Mount MCP at /mcp (plan R3-10)
|
||||
r.With(combinedAuth(cfg)).Handle("/mcp", mcphandler.NewHandler(pool, cfg.MCPBearerToken))
|
||||
|
||||
// Mount SSE stream — handled by the strict handler's StreamEvents method
|
||||
// via the OpenAPI-specified /api/v1/events/stream route.
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user