Add Dynamic Tool System with Lua Integration#58
Merged
Conversation
* Add Lua dynamic tools system for connection-specific tool registration - Add jsonschema dependency for tool parameter validation - Implement lua_tools.rs module with LuaToolDefinition struct - Add Lua tool registration/unregistration in HybridToolRouter - Create comprehensive PRP documentation for feature design - Extend nvim-mcp Lua plugin with custom_tools configuration - Add MCP helper functions for creating tool responses - Include JSON schema validation for tool parameters - Support connection-scoped cleanup of Lua tools - Fix unused variable warnings in integration tests * Refactor Lua dynamic tools system to use trait-based architecture - Replace function-based DynamicTool with trait-based implementation - Implement DynamicTool trait for LuaToolConfig with cleaner async methods - Remove unused handler creation functions and type aliases - Simplify tool execution with direct trait method calls - Clean up integration tests by removing complex multi-connection scenarios - Update type aliases for better clarity (DynamicToolBox, ConnectionToolMap) - Improve error handling in Lua tool execution - Remove dead code and unused imports for cleaner codebase * Upgrade jsonschema dependency to 0.32.1 and add input validation for dynamic tools - Update jsonschema from 0.18.3 to 0.32.1 for improved JSON schema validation - Add validate_input method to DynamicTool trait with automatic schema validation - Integrate input validation into HybridToolRouter execution flow - Add comprehensive tests for dynamic tool input validation scenarios - Clean up Cargo.lock dependencies (remove unused anyhow, update bit-set/bit-vec) * Update documentation for comprehensive Lua dynamic tools system - Enhanced CLAUDE.md with detailed Lua tool integration documentation - Added lua_tools.rs module overview and architecture details - Updated dynamic tool system documentation with user-extensible features - Added MCP helper functions and tool lifecycle management details - Updated PRPs/README.md with Phase 6 development status - Documented custom tool registration through Neovim configuration * Enhance Lua dynamic tools validation and refactor trait implementation - Make DynamicTool::validate_input method abstract for implementation-specific validation - Add LuaToolValidator with comprehensive JSON schema validation and error handling - Implement validator initialization in LuaToolConfig with proper error propagation - Add enhanced validation in LuaToolConfig::validate_input with fallback support - Remove generic validation logic from DynamicTool trait to allow custom implementations - Add comprehensive test coverage for validation scenarios and edge cases - Remove outdated HybridToolRouter tests that are now covered by integration tests * Add tool list change notifications for MCP client updates Enable tool_list_changed capability in server capabilities and implement notification system for dynamic tool registration. When new Neovim connections are established via connect or connect_tcp tools, the MCP client is notified of tool list changes to update available tools. This ensures MCP clients stay synchronized with dynamically registered connection-specific tools and improves the user experience by providing real-time tool availability updates.
Resolved merge conflicts by combining: - Dynamic tool system features from feat/dynamic_tools - Automatic connection and HTTP server features from main - Updated dependencies and documentation to include both feature sets
- Store connection IDs from auto-connection process - Add discover_and_register_lua_tools method to NeovimMcpServer - Call Lua tool discovery after successful auto-connections - Improve error handling for Lua tool setup failures
Modify HybridToolRouter's list_tools implementation to properly inject connection_id parameter into dynamic tool schemas, ensuring dynamic tools display correct parameter requirements in MCP clients. Changes: - Clone tool schema before modification to avoid shared state issues - Inject connection_id parameter into schema properties - Maintain proper schema structure for MCP protocol compliance
- Add From<&dyn DynamicTool> for Tool trait implementation with automatic connection_id injection - Add From<&DynamicToolBox> for Tool trait implementation for boxed tools - Replace manual Tool construction with trait-based conversion in list_tools methods - Implement comprehensive test suite covering schema injection and edge cases - Ensure connection_id parameter is properly injected without overwriting existing definitions
- Add experimental warnings to dynamic tool features across documentation - Clarify stability guarantees for production use - Update architecture notes to indicate experimental status - Add warnings to tool registration resources and Lua integration - Maintain existing functionality while setting proper expectations - Fix markdownlint line length violations
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.
Summary
This PR introduces a comprehensive dynamic tool system for the nvim-mcp server, enabling users to define custom tools through Neovim Lua configuration. The system is marked as experimental due to its evolving nature.
Key Features
Architecture Changes
hybrid_router.rsfor dynamic tool routing with lock-free concurrent accesslua_tools.rsfor Lua custom tool discovery and executioncore.rswith dynamic tool registration APIExperimental Warning