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(),
    ),
)

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 (runtime, config, build). This means WithMCPDebug() is equivalent to WithMCPDebug(WithMCPDebugRuntime(), WithMCPDebugConfig(), WithMCPDebugBuild()).

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 and the 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().

Built-in Tools

ToolEnabled byDescription
runtime_statsWithMCPDebugRuntime()Goroutine count, memory, GC, uptime, AI signals
goroutine_profileWithMCPDebugRuntime()Full goroutine stack dump with state summary
gc_analysisWithMCPDebugRuntime()Detailed GC statistics with pause time analysis

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

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, behind authentication
app.WithDebugEndpoints(
    app.WithMCPDebugIf(cfg.EnableDebugMCP,
        app.WithMCPDebugRuntime(),
    ),
)