Skip to content

fix(mcp): dispatch plugin drivers via the registry + harden the --mcp subprocess#256

Merged
debba merged 1 commit into
TabularisDB:mainfrom
ymadd:fix/mcp-plugin-drivers
May 27, 2026
Merged

fix(mcp): dispatch plugin drivers via the registry + harden the --mcp subprocess#256
debba merged 1 commit into
TabularisDB:mainfrom
ymadd:fix/mcp-plugin-drivers

Conversation

@ymadd
Copy link
Copy Markdown
Contributor

@ymadd ymadd commented May 26, 2026

Summary

MCP could only reach built-in mysql/postgres/sqlite connections — every plugin-driven connection (Hacker News, Redis, …) failed with Unsupported driver. This routes all MCP driver operations through the shared driver registry (the same path the GUI uses) and registers the built-in + installed plugin drivers when the standalone --mcp subprocess starts.

Closes #255.

What changed

  • Registry dispatch: schema resource, list_tables, describe_table, run_query, and pre-flight EXPLAIN now resolve the driver via registry::get_driver instead of a hardcoded match.
  • Subprocess driver registration: --mcp mode registers the three built-ins + installed plugins (load_plugins_with_configs), honoring active_external_drivers.

Hardening surfaced by reaching plugins from MCP

  • Bound plugin RPC calls with a timeout (120 s call / 15 s initialize) so a wedged plugin can't block the single-threaded request loop forever, and cancel the pending entry on timeout so it doesn't leak.
  • kill_on_drop the plugin child so it isn't orphaned when the subprocess exits on stdin EOF.
  • Refuse plugins that claim a built-in driver id (mysql/postgres/sqlite).
  • Resolve resources/read through the keychain/SSH-aware path.
  • Initialize the logger in --mcp mode (stderr only) so plugin-load errors are visible.
  • Stop cleanly instead of panicking when a stdout write fails (BrokenPipe).
  • Run describe_table's column/FK/index fetches concurrently.

Test plan

  • cargo build clean (no warnings) on latest main
  • cargo test --lib plugins passes
  • Verified end-to-end against a Hacker News plugin connection via the --mcp binary: list_tables["stories"], run_query → real rows, resources/read → schema (previously all Unsupported driver)
  • Confirmed no orphaned plugin process remains after the --mcp subprocess exits

…ocess

The MCP server hardcoded mysql/postgres/sqlite dispatch, so every plugin
driver (e.g. hackernews) failed with "Unsupported driver". Route schema,
list/describe table, query and EXPLAIN through the shared driver registry,
and register the built-in + installed plugin drivers when the --mcp
subprocess starts (it has no Tauri AppHandle).

Hardening surfaced by reaching plugins from MCP:
- Bound plugin RPC calls with a timeout (120s call, 15s initialize) so a
  wedged plugin can't block the single-threaded request loop forever, and
  cancel the pending entry on timeout so it doesn't leak.
- kill_on_drop the plugin child so it isn't orphaned when the subprocess
  exits on stdin EOF.
- Refuse plugins that claim a built-in driver id (mysql/postgres/sqlite).
- Resolve resources/read through the keychain/SSH-aware path.
- Initialize the logger in --mcp mode (stderr only) so plugin-load errors
  are visible.
- Stop cleanly instead of panicking when a stdout write fails (BrokenPipe).
- Run describe_table's column/FK/index fetches concurrently.
@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented May 26, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • src-tauri/src/lib.rs — Initialize logger in --mcp mode before starting the MCP server
  • src-tauri/src/mcp/mod.rs — Registry dispatch for all MCP driver operations; adds register_drivers_for_mcp and resolve_db_driver; refactors handle_read_resource, tool_list_tables, tool_describe_table, and tool_run_query to use the shared driver registry instead of hardcoded match arms; runs metadata fetches concurrently in describe_table; handles BrokenPipe gracefully on stdout writes
  • src-tauri/src/mcp/preflight.rs — Uses driver_registry::get_driver for EXPLAIN dispatch instead of hardcoded driver match
  • src-tauri/src/plugins/driver.rs — Adds PluginCommand enum with Call/Cancel; introduces call_with_timeout with 120s call / 15s init ceilings; sends Cancel on timeout to prevent orphaned pending entries; adds kill_on_drop(true) to prevent orphaned plugin processes on subprocess exit
  • src-tauri/src/plugins/manager.rs — Extracts load_plugins_with_configs for non-Tauri MCP use; adds collision guard to refuse plugins claiming built-in driver IDs

Reviewed by kimi-k2.6 · 435,773 tokens

@debba
Copy link
Copy Markdown
Collaborator

debba commented May 26, 2026

Good catch! I will check it ASAP

@debba debba merged commit 259f089 into TabularisDB:main May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: MCP tools fail with "Unsupported driver" for plugin-based connections

2 participants