Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: implement MCP client
Nathan08d1d3602ebb
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lockindex 60d65be5cc..4d19fb2c2f 100644--- a/frontend/rust-lib/Cargo.lock+++ b/frontend/rust-lib/Cargo.lock@@ -154,6 +154,55 @@ dependencies = ["libc",]+[[package]]+name = "anstream"+version = "0.6.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"+dependencies = [+ "anstyle",+ "anstyle-parse",+ "anstyle-query",+ "anstyle-wincon",+ "colorchoice",+ "is_terminal_polyfill",+ "utf8parse",+]++[[package]]+name = "anstyle"+version = "1.0.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"++[[package]]+name = "anstyle-parse"+version = "0.2.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"+dependencies = [+ "utf8parse",+]++[[package]]+name = "anstyle-query"+version = "1.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"+dependencies = [+ "windows-sys 0.59.0",+]++[[package]]+name = "anstyle-wincon"+version = "3.0.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"+dependencies = [+ "anstyle",+ "windows-sys 0.59.0",+]+[[package]]name = "anyhow"version = "1.0.94"@@ -257,6 +306,12 @@ version = "0.7.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"+[[package]]+name = "ascii"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"+[[package]]name = "assert-json-diff"version = "2.0.2"@@ -764,6 +819,12 @@ dependencies = ["phf_codegen 0.11.2",]+[[package]]+name = "chunked_transfer"+version = "1.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901"+[[package]]name = "cipher"version = "0.4.4"@@ -785,6 +846,46 @@ dependencies = ["libloading",]+[[package]]+name = "clap"+version = "4.5.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83"+dependencies = [+ "clap_builder",+ "clap_derive",+]++[[package]]+name = "clap_builder"+version = "4.5.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8"+dependencies = [+ "anstream",+ "anstyle",+ "clap_lex",+ "strsim 0.11.0",+]++[[package]]+name = "clap_derive"+version = "4.5.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"+dependencies = [+ "heck 0.5.0",+ "proc-macro2",+ "quote",+ "syn 2.0.94",+]++[[package]]+name = "clap_lex"+version = "0.7.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"+[[package]]name = "client-api"version = "0.2.0"@@ -1181,6 +1282,12 @@ dependencies = ["tracing",]+[[package]]+name = "colorchoice"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"+[[package]]name = "concurrent-queue"version = "2.5.0"@@ -2041,6 +2148,7 @@ dependencies = ["lib-dispatch","lib-infra","log",+ "mcpr","md5","notify","pin-project",@@ -3088,6 +3196,12 @@ version = "0.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"+[[package]]+name = "heck"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"+[[package]]name = "hermit-abi"version = "0.3.2"@@ -3681,6 +3795,12 @@ dependencies = ["windows-sys 0.59.0",]+[[package]]+name = "is_terminal_polyfill"+version = "1.70.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"+[[package]]name = "itertools"version = "0.10.5"@@ -4088,6 +4208,25 @@ version = "0.7.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ed1202b2a6f884ae56f04cff409ab315c5ce26b5e58d7412e484f01fd52f52ef"+[[package]]+name = "mcpr"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9a434a4b9dfa1c5dcef97ee84fdf4c600bab479df9a24259b9e5474e26f6cd47"+dependencies = [+ "anyhow",+ "clap",+ "log",+ "rand 0.8.5",+ "reqwest 0.12.9",+ "serde",+ "serde_json",+ "thiserror 1.0.64",+ "tiny_http",+ "tungstenite",+ "url",+]+[[package]]name = "md-5"version = "0.10.5"@@ -5609,6 +5748,7 @@ dependencies = ["cookie","cookie_store","encoding_rs",+ "futures-channel","futures-core","futures-util","h2 0.4.7",@@ -6879,6 +7019,18 @@ dependencies = ["time-core",]+[[package]]+name = "tiny_http"+version = "0.12.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "389915df6413a2e74fb181895f933386023c71110878cd0825588928e64cdc82"+dependencies = [+ "ascii",+ "chunked_transfer",+ "httpdate",+ "log",+]+[[package]]name = "tinystr"version = "0.7.6"@@ -7525,6 +7677,12 @@ version = "1.0.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"+[[package]]+name = "utf8parse"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"+[[package]]name = "uuid"version = "1.10.0"diff --git a/frontend/rust-lib/flowy-ai/Cargo.toml b/frontend/rust-lib/flowy-ai/Cargo.tomlindex 2db562aa0d..1aa8fcbdb3 100644--- a/frontend/rust-lib/flowy-ai/Cargo.toml+++ b/frontend/rust-lib/flowy-ai/Cargo.toml@@ -50,6 +50,7 @@ collab-integrate.workspace = true[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]notify = "6.1.1"+mcpr = "0.2.3"[target.'cfg(target_os = "windows")'.dependencies]winreg = "0.55"diff --git a/frontend/rust-lib/flowy-ai/src/lib.rs b/frontend/rust-lib/flowy-ai/src/lib.rsindex be6c743d86..7b26dc1b1d 100644--- a/frontend/rust-lib/flowy-ai/src/lib.rs+++ b/frontend/rust-lib/flowy-ai/src/lib.rs@@ -6,6 +6,7 @@ mod chat;mod completion;pub mod entities;mod local_ai;+mod mcp;mod middleware;pub mod notification;mod persistence;diff --git a/frontend/rust-lib/flowy-ai/src/mcp/client_manager.rs b/frontend/rust-lib/flowy-ai/src/mcp/client_manager.rsnew file mode 100644index 0000000000..80eae6a9bd--- /dev/null+++ b/frontend/rust-lib/flowy-ai/src/mcp/client_manager.rs@@ -0,0 +1,11 @@+use dashmap::DashMap;+use mcpr::transport::Transport;+use mcpr::{client::Client, transport::sse::SSETransport, transport::stdio::StdioTransport};+use std::sync::Arc;++pub struct MCPClientManager {+ stdio_clients: Arc<DashMap<String, Client<StdioTransport>>>,+ http_client: Arc<DashMap<String, Client<SSETransport>>>,+}++impl MCPClientManager {}diff --git a/frontend/rust-lib/flowy-ai/src/mcp/mod.rs b/frontend/rust-lib/flowy-ai/src/mcp/mod.rsnew file mode 100644index 0000000000..62badbf1f9--- /dev/null+++ b/frontend/rust-lib/flowy-ai/src/mcp/mod.rs@@ -0,0 +1 @@+mod client_manager;