Skip to content

feat: MCP bridge + settings UI — unified capability types (Phase 1+2) - #127

Merged
Blankll merged 7 commits into
masterfrom
feat/unified-capability-types
Aug 2, 2026
Merged

feat: MCP bridge + settings UI — unified capability types (Phase 1+2)#127
Blankll merged 7 commits into
masterfrom
feat/unified-capability-types

Conversation

@Blankll

@Blankll Blankll commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

Phase 1 + Phase 2 of the unified Data Studio MCP architecture: migrate capability types to data-studio-agent, add an axum-based HTTP bridge, and ship the MCP Bridge settings UI.

Phase 1 — Unified capability types

  • Replace local types.rs/registry.rs with data_studio_agent::capabilities crate (single source of truth)
  • SourceKind::SqlKit -> AppLocal; SQL-generic tools use SourceKind::SqlDatabase (matches any SQL type)
  • No duplicated capability definitions across repos

Phase 2 — HTTP bridge (mcp_bridge.rs)

  • axum server on port 9121 (configurable), auto-fallback to random port if busy
  • POST /tools — lists Safe capabilities as OpenAI-compatible tool definitions
  • POST /invoke — executes a capability by name; rejects Elevated/Destructive (403)
  • GET /health — app version + actual port
  • Port file (mcp-port) for zero-config discovery by the MCP server
  • McpServerHandle Tauri managed state with graceful shutdown + restart
  • Tauri commands: get_mcp_status, save_mcp_config

MCP Bridge settings UI

  • New MCP Bridge tab in Settings (mcp-bridge.vue)
  • Status indicator (running port / stopped), port config with restart button, auto-start toggle
  • i18n keys (enUS/zhCN)

Fixes included

  • Port-file deletion race on restart — await JoinHandle instead of heuristic sleep
  • Risk level filtering at bridge level
  • Write port file before spawning server task (no orphaned server)
  • Stale port file liveness check in status

Verification

  • cargo check / tests pass
  • vue-tsc --noEmit + lint:check pass

Closes part of geek-fun/data-studio-agent#9 (Phase 1, Phase 2, MCP UI).

Blankll and others added 7 commits July 31, 2026 00:21
- Remove duplicate capabilities/types.rs and capabilities/registry.rs
- Import types and registry from data-studio-agent
- Replace SourceKind::SqlKit with SourceKind::AppLocal
- Update init_registry() call to pass registration function array
- Update agent/executor.rs and agent_adapters.rs to use data-studio-agent paths
Introduces an embedded HTTP bridge (axum, port 9121) that exposes the
capability system over HTTP for the external data-studio-mcp server.

Endpoints:
  POST /tools   — list all agent-tagged capabilities
  POST /invoke  — execute a capability by name with connection resolution
  GET  /health  — health check

Port auto-fallback via portpicker.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Integrates the MCP bridge into sqlkit's app lifecycle:
- Initialize McpServerHandle as managed Tauri state
- Read mcp-config.json and auto-start bridge in setup hook
- Register get_mcp_status and save_mcp_config Tauri commands

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- Security: reject Elevated/Destructive capabilities on bridge (403)
- Lifecycle: save_mcp_config now stops server when autoStart=false
- Stale port file: liveness-test (TCP connect) before reporting running
- Write port file BEFORE spawning server to avoid orphaned task
- app_version: use real version from package_info()
- McpConfig::load: log warning on corrupt/parse error
- TOCTOU: remove port_available check, bind directly with fallback

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…lity-types

# Conflicts:
#	src-tauri/src/mcp_bridge.rs
@Blankll Blankll changed the title feat: MCP bridge — HTTP server for data-studio-mcp integration feat: MCP bridge + settings UI — unified capability types (Phase 1+2) Aug 2, 2026
@Blankll
Blankll merged commit ab48a97 into master Aug 2, 2026
3 checks passed
@Blankll
Blankll deleted the feat/unified-capability-types branch August 2, 2026 09:36
Blankll added a commit to geek-fun/dockit that referenced this pull request Aug 2, 2026
…#471)

## Summary

Phase 1 + Phase 2 of the unified Data Studio MCP architecture: migrate
capability types to `data-studio-agent`, add an axum-based HTTP bridge,
and ship the MCP Bridge settings UI.

### Phase 1 — Unified capability types
- Delete duplicate `types.rs` + `registry.rs` from dockit, imports now
from `data_studio_agent::capabilities`
- `SourceKind::DocKit` -> `AppLocal`
- No duplicated capability definitions across repos

### Phase 2 — HTTP bridge (`mcp_bridge.rs`)
- axum server on port 9120 (configurable), auto-fallback to random port
if busy
- `POST /tools` — lists Safe capabilities as OpenAI-compatible tool
definitions + connections
- `POST /invoke` — executes a capability with connection resolution +
SSH tunnel support; rejects Elevated/Destructive (403)
- `GET /health` — app version + actual port
- Port file (`mcp-port`) for zero-config discovery by the MCP server
- Config at `{app_data_dir}/mcp-config.json` (separate from
`.store.dat`)
- `McpServerHandle` Tauri managed state with graceful shutdown/restart
- Tauri commands: `get_mcp_status`, `save_mcp_config`

### MCP Bridge settings UI
- New **MCP Bridge** settings tab (`mcp-bridge.vue`)
- Green/red status indicator with port number
- Port input (1024-65535, optional auto), restart button, auto-start
toggle
- i18n: enUS + zhCN

### Fixes included
- Port-file deletion race on restart — await JoinHandle instead of
heuristic sleep
- Risk level filtering at bridge level
- Write port file before spawning server task (no orphaned server)
- Stale port file liveness check in status

### Verification
- ✅ `cargo check` — clean
- ✅ `npx tsc --noEmit` — clean
- ✅ `npm run lint:check` — clean

Part of geek-fun/data-studio-agent#9 (Phase 1, Phase 2, MCP UI).
Companion PR: geek-fun/sqlkit#127.

---------

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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