Thank you for considering contributing to mcphub.nvim! This document provides guidelines and information to help you get started contributing to the project.
mcphub.nvim acts as a frontend to the mcp-hub backend, which provides core functionality like watching the servers.json file, starting/stopping servers and hosting an express server for client connections.
The express server provides several key endpoints:
/api/health- Server health and status checks/api/events- SSE endpoint for real-time events (logs, server updates, etc.)/api/servers/*- Endpoints for tools, resources, prompts
- Neovim 0.8.0+
- Node.js 18.0+
- lua-language-server
- stylua
- plenary.nvim
- tmux (recommended for development)
- Clone the mcp-hub repository:
git clone https://github.com/ravitemer/mcp-hub.git
cd mcp-hub- Configure mcphub.nvim to use local mcp-hub:
local mcphub = require("mcphub")
-- First clear the log file
local file = io.open(vim.fn.expand("~/mcphub.log"), "w")
if file then
file:write("")
file:close()
end
mcphub.setup({
-- Use local mcp-hub during development
cmd = "node",
cmdArgs = {
"/path/to/mcp-hub/src/utils/cli.js", -- Point to local mcp-hub
},
shutdown_delay = 0, -- During development, stop immediately when neovim exits
-- Enhanced logging for development
log = {
to_file = true,
file_path = vim.fn.expand("~/mcphub.log"),
level = vim.log.levels.DEBUG,
},
})For effective development, use a tmux-based setup with multiple panes:
- Main editor pane with mcphub.nvim code
- Second pane showing real-time mcp-hub logs:
tail -f ~/.mcp-hub/logs/mcp-hub.log- Third pane watching mcphub.nvim plugin logs:
tail -f ~/mcphub.logThis setup allows you to:
- Monitor both frontend (plugin) and backend (mcp-hub) logs in real-time
- See how changes affect the communication between components
- Debug issues more effectively by correlating events
lua/mcphub/- Main plugin codeinit.lua- Plugin entry point and setupstate.lua- Global state managementhub.lua- Core MCP Hub functionalityextensions/- Chat plugin integrationsnative/- Native MCP server implementationsui/- User interface componentsutils/- Shared utility functions
- mcphub.nvim (plugin)
- Fork mcp-hub (backend) - If your changes need to update the mcp-hub
- See the above Development Environment Setup for details
- Follow existing code patterns
- Update relevant documentation
- Follow existing patterns for:
- Error handling
- Logging
- Add tests for new functionality
- Run
make formatto format code using stylua - Run
make docsto generate documentation
- Use stylua for code formatting
- Configuration is in
stylua.toml - Run
make formatbefore submitting PRs - Follow existing code patterns and naming conventions
Documentation is built using panvimdoc:
make docs # Generate plugin documentation- mcphub.nvim uses Mini.Test for testing:
make test # Run all tests
make test_file FILE=path/to/test_file.lua # Run specific test file- Ensure mcphub.nvim tests pass
- When adding new features, please include tests in the appropriate test file under
tests/. - Verify logs show expected behavior
- Test with different chat plugins if relevant
- Update documentation if behavior changes
- Add tests for new features
- Format code:
make format - Generate docs:
make docs - Include:
- Clear description
- Related issue references
- Screenshots/gifs if UI changes
- Log examples if relevant
- Join our Discord server
- Check detailed Wiki
- Read announcements in Discussions for feature details
By contributing to mcphub.nvim, you agree that your contributions will be licensed under the MIT License.
