MCP Debug Options
3 minute read
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
| Tool | Enabled by | Input | Description |
|---|---|---|---|
runtime_stats | WithMCPDebugRuntime() | none | Goroutine count, memory, GC, uptime, AI signals |
goroutine_profile | WithMCPDebugRuntime() | state (running/waiting/idle/all) | Goroutine stack dump with state summary and optional state filter |
gc_analysis | WithMCPDebugRuntime() | none | GC statistics with pause time analysis |
memory_profile | WithMCPDebugRuntime() | top_n (default 20) | Top N heap allocation sites by in-use bytes |
health_status | WithMCPDebugHealth() | none | Runs liveness and readiness checks, returns per-check status |
Built-in Resources
| Resource URI | Enabled by | Description |
|---|---|---|
rivaas://runtime/overview | WithMCPDebugRuntime() | Live runtime stats snapshot |
rivaas://config | WithMCPDebugConfig() | Sanitized app configuration |
rivaas://build | WithMCPDebugBuild() | Go build info and dependencies |
rivaas://routes | WithMCPDebugRoutes() | Registered HTTP route table |
rivaas://openapi | WithMCPDebugOpenAPI() | Generated OpenAPI specification (JSON) |
Endpoints Registered
| Method | Path | Description |
|---|---|---|
GET | /_internal/debug/mcp | MCP Streamable HTTP (listen for notifications) |
POST | /_internal/debug/mcp | MCP Streamable HTTP (send requests) |
DELETE | /_internal/debug/mcp | MCP 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(),
),
)
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.