Add Workspace-Aware Support#200
Merged
Merged
Conversation
1429f74 to
a6b7073
Compare
aa51f47 to
94a5072
Compare
45dd23a to
a9f5fb2
Compare
b38eb9c to
195e5ed
Compare
ravitemer
added a commit
that referenced
this pull request
Jul 18, 2025
### Added - ** Workspace-Aware MCP Hub**: project-local configuration support (#148, #183, #196, #200) - **Smart Project Detection**: Automatically detects project boundaries using `.mcphub/servers.json`, `.vscode/mcp.json`, `.cursor/mcp.json` - **Isolated Hub Instances**: Each workspace gets its own mcp-hub process with unique ports (40000-41000 range) - **Configuration Merging**: Project configs automatically override global settings while preserving global servers - **Automatic Switching**: Seamlessly switches between workspace hubs on directory changes (`DirChanged` events) - **Dynamic Port Allocation**: Hash-based port generation with conflict resolution and custom port assignment support - ** Global Environment Variables**: Universal environment injection for all MCP servers (#183) - **Flexible Configuration**: Support for both table and function-based global_env configuration - **Context-Aware Variables**: Function receives workspace context (port, config files, workspace mode) - **Mixed Format Support**: Array-style (`"VAR"`) and hash-style (`KEY = "value"`) entries - **Automatic Resolution**: Environment variables resolved when hub starts with project context - **ƒÄ¿ Enhanced UI Experience**: Complete workspace management interface - **Active Hubs Section**: View and manage all running workspace hub instances - **Grouped Server Display**: Servers organized by config source (Global vs Project) with visual indicators - **Multi-Config Editor**: Tab-based interface for editing different config files (global and project) - **Workspace Actions**: Expand/collapse details, kill processes, change directories, view configuration files ### Enhanced - **Directory Change Handling**: Proper hub switching when changing directories in Neovim - **Config File Watching**: Enhanced file watching to handle multiple configuration sources - Some common expected keymaps like `<Cr>`, `o` and `<Esc>` work along with the `l` and `k` keys ### Fixed - **Multi-Project Isolation**: Solves the fundamental issue of MCP servers working in wrong project directories - **Environment Variable Access**: Addresses user session variables (like `DBUS_SESSION_BUS_ADDRESS`) not being available to MCP servers ### Migration Guide Existing configurations work without changes. To enable workspace features: ```lua require("mcphub").setup({ workspace = { enabled = true, -- Default: true look_for = { ".mcphub/servers.json", ".vscode/mcp.json", ".cursor/mcp.json" }, reload_on_dir_changed = true, port_range = { min = 40000, max = 41000 }, get_port = nil, -- Optional custom port function }, global_env = { "DBUS_SESSION_BUS_ADDRESS", -- Array-style: uses os.getenv() API_KEY = os.getenv("API_KEY"), -- Hash-style: explicit value } }) ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces workspace-aware MCP Hub functionality, enabling project-specific MCP server configurations. This addresses several key issues including project-local configs, variable interpolation, and multi-project isolation.
Main View
Config View
Related issues:
#148
#183
#196
🏠 Workspace Detection
.vscode/mcp.json,.cursor/mcp.json,mcp.json,.mcphub/servers.json🎨 UI Improvements
Configuration
Server Launch Flow
global→project)Config Merging Strategy
config_sourcefieldRelated Issue(s)
Screenshots
Checklist
make testto ensure all tests passmake formatto format the codemake docsto update the vimdoc pages