-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
🎯 Problem Statement
Currently, the MCP tool system creates new tools to be run on the system, but the code cleaning process is based on regex and relies on direct exec calls. This approach is error-prone and doesn't scale well.
Would be AMAZING if anyone could help out on this!
Current Issues:
- Regex code cleaning: fine but first writing to a file and then checking if it's correct would be better.
- Direct execution: Uses
execwithout proper validation - Error-prone: Little validation of code quality or parameter correctness
- Poor scalability: Difficult to maintain and extend
💡 Proposed Solution
Implement a two-phase approach for MCP tool generation and execution:
Phase 1: Code Generation and Validation
- Generate tool code to separate files (Python/JS scripts)
- Validate and fix code before execution
- Ensure code quality and safety standards
Phase 2: Parameter Generation and Execution
- Generate execution parameters using our schema
- Validate parameters against tool requirements
- Execute scripts with correct parameters
🏗️ Architecture Overview
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ MCP Tool │───▶│ Code Generator │───▶│ File Writer │
│ Request │ │ & Validator │ │ (Python/JS) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Parameter │◀───│ Schema-Based │◀───│ Agent Call │
│ Execution │ │ Parameter Gen │ │ for Params │
└─────────────────┘ └──────────────────┘ └─────────────────┘
🔧 Technical Requirements
Code Generation
# Example structure for generated Python tools
class GeneratedTool:
def __init__(self, schema, parameters):
self.schema = schema
self.parameters = parameters
def validate_parameters(self):
# Schema-based validation
pass
def execute(self):
# Safe execution with validated parameters
passParameter Schema
{
"type": "object",
"properties": {
"tool_name": {"type": "string"},
"parameters": {"type": "object"},
"validation_rules": {"type": "object"}
},
"required": ["tool_name", "parameters"]
}🎯 Benefits
Scalability
- Modular design: Each tool is a separate file
- Easy maintenance: Individual tool updates
- Version control: Track tool changes over time
Reliability
- Code validation: Prevents execution of invalid code
- Parameter validation: Ensures correct parameter types
- Error handling: Comprehensive error management
Security
- Sandboxed execution: Isolated tool execution
- Code review: Generated code can be reviewed before execution
- Access control: Granular permissions for tool execution
Developer Experience
- Debugging: Easier to debug individual tools
- Testing: Isolated testing of tool components
- Documentation: Auto-generated documentation from schemas
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed