Skip to content

Commit 2ed2131

Browse files
committed
feat(mcp): persist MCP server configurations to local data directory
- Add mcps_dir() method to AppDirs in cortex-common for cross-platform MCP storage directory path (Linux/macOS/Windows) - Create new mcp_storage module in cortex-tui for MCP server config persistence as JSON files - Add StoredMcpServer struct with support for stdio and HTTP transports - Integrate storage into event_loop: save on add, remove on delete - Load persisted MCP servers at app startup in app_runner - Servers are stored in the platform-specific data directory: - Linux: ~/.local/share/cortex/mcps/ - macOS: ~/.local/share/cortex/mcps/ - Windows: %APPDATA%\cortex\mcps\
1 parent 093bfb8 commit 2ed2131

File tree

5 files changed

+528
-4
lines changed

5 files changed

+528
-4
lines changed

cortex-common/src/dirs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ impl AppDirs {
130130
self.cache_dir.join("logs")
131131
}
132132

133+
/// Get the MCP servers directory
134+
pub fn mcps_dir(&self) -> PathBuf {
135+
self.data_dir.join("mcps")
136+
}
137+
133138
/// Ensure all directories exist with proper permissions
134139
pub fn ensure_dirs(&self) -> std::io::Result<()> {
135140
for dir in [&self.config_dir, &self.data_dir, &self.cache_dir] {

cortex-tui/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ pub mod collaboration_modes;
114114
// TUI capture and debugging (enabled via CORTEX_TUI_CAPTURE=1)
115115
pub mod capture;
116116

117+
// MCP server storage (persistent storage for MCP configurations)
118+
pub mod mcp_storage;
119+
117120
// Re-export main types
118121
pub use actions::{ActionContext, ActionMapper, KeyAction, KeyBinding};
119122
pub use app::{
@@ -163,6 +166,9 @@ pub use external_editor::{
163166
// TUI capture re-exports
164167
pub use capture::{TuiCapture, capture_enabled};
165168

169+
// MCP storage re-exports
170+
pub use mcp_storage::{McpStorage, McpTransport, StoredMcpServer};
171+
166172
// Re-export cortex-core for downstream users
167173
pub use cortex_engine;
168174

0 commit comments

Comments
 (0)