Refactor tools: implement auto-discovery registry and modular architecture#7
Draft
Refactor tools: implement auto-discovery registry and modular architecture#7
Conversation
Co-authored-by: exekerey <104984914+exekerey@users.noreply.github.com>
…regate file Co-authored-by: exekerey <104984914+exekerey@users.noreply.github.com>
Co-authored-by: exekerey <104984914+exekerey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] refactor tools
Refactor tools: implement auto-discovery registry and modular architecture
Sep 13, 2025
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.
This PR comprehensively refactors the tools system to improve maintainability, organization, and safety while preserving all existing functionality.
Problem
The original tools system had several maintenance and scalability issues:
__init__.pyevery time a new tool was addedaggregate.pycontained 309 lines with 5 different tools[str]instead oflist[str]Solution
🎯 Auto-Discovery System
Replaced manual tool registration with automatic discovery using decorators:
🏗️ Modular Architecture
Split the large
aggregate.pyfile into focused modules:address_aggregates.py- Address-related aggregations (3 tools)block_aggregates.py- Block-related aggregations (1 tool)transaction_aggregates.py- Transaction-related aggregations (1 tool)aggregate_schemas.py- Shared schema definitionsvalidation.py- Input validation utilitiesregistry.py- Auto-discovery system🔒 Safety & Validation
Added comprehensive input validation:
📊 Quality Improvements
[str]→list[str])Testing
All functionality has been verified:
Benefits
For Developers
@mcp_tooldecoratorFor Security
For Maintainability
Files Changed
New Files:
src/tools/registry.py- Auto-discovery systemsrc/tools/validation.py- Input validation utilitiessrc/tools/aggregate_schemas.py- Shared schema definitionssrc/tools/address_aggregates.py- Address aggregation toolssrc/tools/block_aggregates.py- Block aggregation toolssrc/tools/transaction_aggregates.py- Transaction aggregation toolssrc/tools/__all__.py- Tool categorizationREFACTORING.md- Detailed migration guidedemo_refactored_tools.py- Functionality demonstrationModified Files:
src/tools/__init__.py- Simplified to use auto-discovery@mcp_tooldecorators and improved type hintstests/main.py- Updated imports for new structure.gitignore- Added build artifacts exclusionRemoved Files:
src/tools/aggregate.py- Split into focused modulessrc/tools/rates.py- Removed empty placeholderBackward Compatibility
This refactoring maintains 100% backward compatibility:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.