MCP Debug Options

MCP debug endpoint configuration options reference.

MCP Debug Options

These options are used with WithMCPDebug() inside WithDebugEndpoints():

app.WithDebugEndpoints(
    app.WithMCPDebug(
        app.WithMCPDebugRuntime(),
        app.WithMCPDebugConfig(),
        app.WithMCPDebugBuild(),
        app.WithMCPDebugRoutes(),
        app.WithMCPDebugHealth(),
        app.WithMCPDebugOpenAPI(),
    ),
)

Option Functions

WithMCPDebug

func WithMCPDebug(opts ...MCPDebugOption) DebugOption

Enables the debug MCP server and applies the given options. The server is mounted at {debug.prefix}/mcp (default: /_internal/debug/mcp).

When called without sub-options, all features are enabled. This means WithMCPDebug() is equivalent to passing every WithMCPDebug*() option.

The mount point follows the debug prefix — when you use WithDebugPrefix("/custom"), the debug MCP server moves to /custom/mcp.

Nil options produce a configuration error at init (not silently ignored).

WithMCPDebugIf

func WithMCPDebugIf(cond bool, opts ...MCPDebugOption) DebugOption

Conditionally enables the debug MCP server. When cond is false, the option is a no-op.

app.WithDebugEndpoints(
    app.WithMCPDebugIf(os.Getenv("MCP_DEBUG") == "true",
        app.WithMCPDebugRuntime(),
    ),
)

WithMCPDebugRuntime

func WithMCPDebugRuntime() MCPDebugOption

Enables runtime introspection tools (runtime_stats, goroutine_profile, gc_analysis, memory_profile) and the rivaas://runtime/overview resource.

WithMCPDebugConfig

func WithMCPDebugConfig() MCPDebugOption

Enables the application configuration resource. The configuration is sanitized — no secrets are exposed.

WithMCPDebugBuild

func WithMCPDebugBuild() MCPDebugOption

Enables the build information resource using runtime/debug.ReadBuildInfo().

WithMCPDebugRoutes

func WithMCPDebugRoutes() MCPDebugOption

Enables the rivaas://routes resource, which lists all registered HTTP routes with methods, paths, handlers, middleware, and constraints.

WithMCPDebugHealth

func WithMCPDebugHealth() MCPDebugOption

Enables the health_status tool, which runs all registered liveness and readiness checks and returns per-check pass/fail status. If health endpoints are not configured on the app, the tool returns an informative signal.

WithMCPDebugOpenAPI

func WithMCPDebugOpenAPI() MCPDebugOption

Enables the rivaas://openapi resource, which returns the generated OpenAPI specification (JSON). If OpenAPI is not enabled on the app (app.WithOpenAPI()), the resource returns an informative error.

Built-in Tools

ToolEnabled byInputDescription
runtime_statsWithMCPDebugRuntime()noneGoroutine count, memory, GC, uptime, AI signals
goroutine_profileWithMCPDebugRuntime()state (running/waiting/idle/all)Goroutine stack dump with state summary and optional state filter
gc_analysisWithMCPDebugRuntime()noneGC statistics with pause time analysis
memory_profileWithMCPDebugRuntime()top_n (default 20)Top N heap allocation sites by in-use bytes
health_statusWithMCPDebugHealth()noneRuns liveness and readiness checks, returns per-check status

Built-in Resources

Resource URIEnabled byDescription
rivaas://runtime/overviewWithMCPDebugRuntime()Live runtime stats snapshot
rivaas://configWithMCPDebugConfig()Sanitized app configuration
rivaas://buildWithMCPDebugBuild()Go build info and dependencies
rivaas://routesWithMCPDebugRoutes()Registered HTTP route table
rivaas://openapiWithMCPDebugOpenAPI()Generated OpenAPI specification (JSON)

Endpoints Registered

MethodPathDescription
GET/_internal/debug/mcpMCP Streamable HTTP (listen for notifications)
POST/_internal/debug/mcpMCP Streamable HTTP (send requests)
DELETE/_internal/debug/mcpMCP Streamable HTTP (close session)

The path changes when WithDebugPrefix is used.

Security Warning

⚠️ Never enable debug MCP in production without proper authentication. These endpoints expose sensitive runtime information including goroutine stacks, memory contents, and configuration details.

Example

// Development: enable all debug features (bare WithMCPDebug enables all)
app.WithDebugEndpoints(
    app.WithPprof(),
    app.WithMCPDebug(),
)

// Production: enable only runtime and health, behind authentication
app.WithDebugEndpoints(
    app.WithMCPDebugIf(cfg.EnableDebugMCP,
        app.WithMCPDebugRuntime(),
        app.WithMCPDebugHealth(),
    ),
)