Skip to content

fix(mcp): resolve saved-but-inactive connections in bridge - #132

Merged
Blankll merged 4 commits into
masterfrom
fix/mcp-connection-resolution
Aug 7, 2026
Merged

fix(mcp): resolve saved-but-inactive connections in bridge#132
Blankll merged 4 commits into
masterfrom
fix/mcp-connection-resolution

Conversation

@Blankll

@Blankll Blankll commented Aug 7, 2026

Copy link
Copy Markdown
Member

fix + feat: MCP connection resolution and SQL write tool split

What

Four commits on this branch:

  1. fix(mcp): resolve saved-but-inactive connections in bridgemcp_bridge::resolve_connection now reuses capabilities::sql::resolve_adapter, which reads .store.dat in-process and connects, instead of only checking in-memory active connections. Credentials never leave the app; McpPolicy authorization still runs upstream in invoke_with_policy. Error messages from get_connection_id are now actionable.

  2. chore: sync Cargo.lock sqlkit version to 0.8.4 — lock was stale at 0.8.1 while Cargo.toml is 0.8.4.

  3. fix(mcp): remove get_store_value stub capability — the handler always returned {"value": null} without reading the store; MCP should not expose internal app store data.

  4. feat(mcp): split SQL write tools by risk levelsqlkit__execute_query was a single Elevated capability carrying all SQL (INSERT/UPDATE/DELETE/DDL ran with no Destructive gate). Split by statement class:

    • sqlkit__execute_query: read-only (SELECT/SHOW/EXPLAIN) → Safe, parallel_ok=true
    • sqlkit__execute_write: INSERT/UPDATE/MERGE → Elevated
    • sqlkit__execute_delete: DELETE/TRUNCATE → Destructive (Confirm Destructive gate)
    • sqlkit__execute_ddl: CREATE/ALTER/DROP → Destructive

    classify_sql parses with sqlparser (dialect-aware). execute_query rejects write/delete/ddl with actionable guidance to the split tools. New module sql_write.rs shares resolve_adapter/execute_on_adapter from sql.rs.

Why

  • MCP clients could only reach connections activated in the current UI session, with misleading errors (Missing connectionId in connection config / Connection not found).
  • SQL writes had no Destructive gate — any agent with Elevated access could DELETE/DROP freely.
  • get_store_value was a dead stub misleading agents.

Checklist

  • cargo check passes
  • cargo test --lib passes (317 tests, incl. 10 new sql_write classification tests)
  • Real Postgres round-trip verified (BEGIN/CREATE/INSERT/SELECT/ROLLBACK)

Blankll and others added 4 commits August 7, 2026 20:11
MCP bridge resolve_connection only checked in-memory connections, so
connections saved in .store.dat but not yet activated in the UI session
failed with misleading errors. Reuse capabilities::sql::resolve_adapter,
which reads the store in-process and connects — credentials never leave
the app. McpPolicy authorization still runs upstream in invoke_with_policy.

Also make get_connection_id errors actionable: distinguish 'no connection
provided' (point to sqlkit__list_connections / Settings → MCP Bridge)
from a malformed internal config.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
The handler always returned {"value": null} without reading the store —
dead code that misleads agents. MCP should not expose internal app store
data, so remove the capability and its registration.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
sqlkit__execute_query was a single Elevated capability carrying all SQL —
INSERT/UPDATE/DELETE/DDL ran with no Destructive gate, and parallel_ok
blocked concurrent reads. Split by statement class so McpPolicy can gate
each risk level:

- sqlkit__execute_query: read-only (SELECT/SHOW/EXPLAIN) → Safe, parallel
- sqlkit__execute_write: INSERT/UPDATE/MERGE → Elevated
- sqlkit__execute_delete: DELETE/TRUNCATE → Destructive
- sqlkit__execute_ddl: CREATE/ALTER/DROP → Destructive

classify_sql parses with sqlparser (dialect-aware). execute_query now
rejects write/delete/ddl statements with actionable guidance pointing to
the split tools. New module sql_write.rs shares resolve_adapter and
execute_on_adapter from sql.rs.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@Blankll
Blankll merged commit bcc756d into master Aug 7, 2026
3 checks passed
@Blankll
Blankll deleted the fix/mcp-connection-resolution branch August 7, 2026 16:37
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.

1 participant