Add tools and update authenticztion and RBAC

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-11-21 10:22:01 +01:00
parent deb656d95e
commit dfd924abeb
16 changed files with 15634 additions and 39441 deletions

View File

@@ -2,7 +2,6 @@ package mcp_v1
import (
"context"
"fmt"
"net/http"
"time"
@@ -13,27 +12,14 @@ import (
"go.probo.inc/probo/pkg/authz"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/probo"
"go.probo.inc/probo/pkg/server/api/mcp/mcputils"
"go.probo.inc/probo/pkg/server/api/mcp/v1/server"
serverauth "go.probo.inc/probo/pkg/server/auth"
)
func (r *Resolver) ProboService(ctx context.Context, tenantID gid.TenantID) *probo.TenantService {
validateTenantAccess(ctx, tenantID)
return r.proboSvc.WithTenant(tenantID)
}
func validateTenantAccess(ctx context.Context, tenantID gid.TenantID) {
mcpCtx := MCPContextFromContext(ctx)
if mcpCtx == nil {
panic(fmt.Errorf("authentication context not found"))
}
for _, tid := range mcpCtx.TenantIDs {
if tid == tenantID {
return
}
}
panic(fmt.Errorf("access denied: user does not have access to tenant %s", tenantID.String()))
func (r *Resolver) ProboService(ctx context.Context, objectID gid.GID) *probo.TenantService {
serverauth.RequireTenantAccess(ctx, objectID.TenantID())
return r.proboSvc.WithTenant(objectID.TenantID())
}
func NewMux(logger *log.Logger, proboSvc *probo.Service, authSvc *auth.Service, authzSvc *authz.Service, cfg Config) *chi.Mux {
@@ -54,6 +40,10 @@ func NewMux(logger *log.Logger, proboSvc *probo.Service, authSvc *auth.Service,
mcpServer := server.New(resolver)
// Add panic recovery middleware to handle panics in goroutines spawned by MCP SDK
mcpServer.AddReceivingMiddleware(mcputils.LoggingMiddleware(logger))
mcpServer.AddReceivingMiddleware(mcputils.RecoveryMiddleware(logger))
getServer := func(r *http.Request) *mcp.Server { return mcpServer }
eventStore := mcp.NewMemoryEventStore(nil)