Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/fanout/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func main() {
}
mcpAuthorization.Register(e)
e.Any("/mcp", echo.WrapHandler(mcpAuthorization.ProtectMCP(mcpServer.HTTPHandler())))
e.Any("/api/mcp", api.ProtectBrowserMCP(browserSessions, mcpServer.HTTPHandler()))
e.Any("/api/mcp", mcpAuthorization.ProtectBrowserMCP(browserSessions, mcpServer.HTTPHandler()))
slog.Info("MCP server enabled", "path", "/mcp", "auth", "oauth", "resource", mcpResourceURL)
slog.Info("browser MCP server enabled", "path", "/api/mcp", "auth", "session")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewToolRegistry(ctx context.Context, server *mcp.Server) (*ToolRegistry, er
mcpUIExtension: map[string]any{"mimeTypes": []string{mcpAppMIME}},
}},
})
session, err := client.Connect(ctx, clientTransport, nil)
session, err := client.Connect(ctx, clientTransport, &mcp.ClientSessionOptions{ProtocolVersion: fanoutmcp.ProtocolVersion})
if err != nil {
serverSession.Close()
return nil, fmt.Errorf("connect internal MCP client: %w", err)
Expand Down
11 changes: 11 additions & 0 deletions internal/api/auth_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ func RegisterAuthMiddleware(e *echo.Echo, users *auth.UserStore, sessions *auth.
if users == nil || sessions == nil || audit == nil {
panic("api: auth middleware dependencies are required")
}
// Pre-routing middleware runs before session loading and authentication,
// including on the browser MCP mount and methods other than POST.
publicOrigin := serializedMCPOrigin(cfg.PublicURL)
e.Pre(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c *echo.Context) error {
if path := c.Request().URL.Path; (path == "/mcp" || path == "/api/mcp") && !trustedMCPOrigin(c.Request(), publicOrigin) {
return echo.NewHTTPError(http.StatusForbidden, "untrusted MCP origin")
}
return next(c)
}
})
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c *echo.Context) error {
c.Set(authAuditKey, audit)
Expand Down
Loading
Loading