t8y2/dbx · error

Invalid DBX Web MCP configuration

Error message

Invalid DBX Web MCP configuration

What it means

During router construction, dbx-web calls web_mcp_router(&web_state) and expects the MCP configuration to be valid. An Err here means the Model Context Protocol router could not be built from the current state/config, so startup panics.

Source

Thrown at crates/dbx-web/src/main.rs:1103

        .route("/cloud-sync/snippet/download", post(routes::cloud_sync::snippet_sync_download));

    // Do not expose DuckDB-only handlers from builds that omit DuckDB sidecar support.
    #[cfg(feature = "duckdb-sidecar")]
    let api =
        api.route("/query/build-duckdb-attach-database-sql", post(routes::query::build_duckdb_attach_database_sql));

    let api = add_mq_routes(api)
        .layer(middleware::from_fn_with_state(web_state.clone(), auth::auth_middleware))
        .with_state(web_state.clone());

    // Build app
    let mut app = Router::new()
        .nest("/api", api)
        .layer(DefaultBodyLimit::max(web_body_limit_bytes()))
        .layer(CompressionLayer::new().compress_when(web_compression_predicate()))
        .layer(tower_http::trace::TraceLayer::new_for_http());

    if let Some(mcp_router) = web_mcp_router(&web_state).expect("Invalid DBX Web MCP configuration") {
        app = app.merge(mcp_router);
        tracing::info!("DBX Web MCP is enabled at /mcp");
    }

    let static_dir = std::env::var_os("DBX_STATIC_DIR").map(std::path::PathBuf::from);
    app = mount_public_base_path(app, &public_base_path, static_dir.as_deref());

    // Bind address
    let port: u16 = std::env::var("DBX_PORT").ok().and_then(|p| p.parse().ok()).unwrap_or(4224);
    let addr = SocketAddr::from(([0, 0, 0, 0], port));

    tracing::info!("DBX Web server starting on http://{}", addr);
    if public_base_path != "/" {
        tracing::info!("Serving DBX Web under context path {}", public_base_path);
    }
    if password_disabled {
        tracing::info!("Password protection is disabled");
    } else if std::env::var("DBX_PASSWORD").is_ok() {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Review and correct MCP-related environment variables/config feeding web_state.
  2. Check the plugin/dialect directories (data_dir/plugins/dialects) for invalid plugins and remove them, then restart.
  3. Run web_mcp_router with the same state in a test to surface the underlying Err message.
  4. Downgrade/revert to a dbx-web version compatible with your MCP configuration, or update the config to the new format.
  5. Change expect() to log the error and start without the MCP router merged.

Example fix

// before
if let Some(mcp_router) = web_mcp_router(&web_state).expect("Invalid DBX Web MCP configuration") {
// after
match web_mcp_router(&web_state) {
    Ok(Some(mcp_router)) => { app = app.merge(mcp_router); }
    Ok(None) => {}
    Err(e) => tracing::error!("MCP disabled, invalid configuration: {e}"),
}
Defensive patterns

Strategy: try-catch

Validate before calling

// validate MCP config inputs before building state
let mcp_enabled = std::env::var("DBX_MCP_ENABLED").map(|v| v != "0").unwrap_or(true);
// verify plugin dir contains loadable plugins
let plugins_ok = std::path::Path::new(&data_dir).join("plugins/dialects")
    .read_dir().map(|mut d| d.next().is_none() || true).unwrap_or(true);

Try / catch

match web_mcp_router(&web_state) {
    Ok(Some(mcp_router)) => { app = app.merge(mcp_router); tracing::info!("DBX Web MCP enabled at /mcp"); }
    Ok(None) => {}
    Err(e) => tracing::error!("MCP disabled, invalid configuration: {e}"),
}

Prevention

When it happens

Trigger: web_mcp_router(&web_state) returns Err because MCP settings (env-derived config, AI/dialect plugin state, or route registration) are inconsistent — e.g., an invalid MCP config value or a failure assembling the MCP sub-router.

Common situations: Misconfigured MCP-related environment variables; an incompatible or broken dialect/plugin loaded from the plugins directory corrupting the state the MCP router depends on; code changes where the MCP router builder now returns Err for a previously accepted config.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/0e2b1353d3bdd1d8. Report an issue: GitHub.