feat: add embedded MCP server and Makefile
Add an MCP (Model Context Protocol) server that starts on 127.0.0.1:9427 at app launch, sharing connection pools with the Tauri IPC layer. This lets Claude (or any MCP client) query PostgreSQL through Tusk's existing connections. MCP tools: list_connections, execute_query, list_schemas, list_tables, describe_table. Also add a Makefile with targets for dev, build (cross-platform), install/uninstall, lint, and formatting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,16 +1,37 @@
|
||||
mod commands;
|
||||
mod error;
|
||||
mod mcp;
|
||||
mod models;
|
||||
mod state;
|
||||
mod utils;
|
||||
|
||||
use state::AppState;
|
||||
use std::sync::Arc;
|
||||
use tauri::Manager;
|
||||
|
||||
pub fn run() {
|
||||
let shared_state = Arc::new(AppState::new());
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.manage(AppState::new())
|
||||
.manage(shared_state)
|
||||
.setup(|app| {
|
||||
let state = app.state::<Arc<AppState>>().inner().clone();
|
||||
let connections_path = app
|
||||
.path()
|
||||
.app_data_dir()
|
||||
.expect("failed to resolve app data dir")
|
||||
.join("connections.json");
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = mcp::start_mcp_server(state, connections_path, 9427).await {
|
||||
log::error!("MCP server error: {}", e);
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
// connections
|
||||
commands::connections::get_connections,
|
||||
|
||||
Reference in New Issue
Block a user