Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions docs/technical-designs/AIR-9961.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Technical Design: AIR-9961

## Overview
The MCP Tools Code Generator is a system designed to automate code generation for MCP tools. It will provide a flexible, template-based approach to generate consistent and maintainable code across the MCP toolset.
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overview lacks clarity about what 'MCP tools' are and what specific problem this code generator solves. Consider adding a brief explanation of MCP and the current pain points this system addresses.

Suggested change
The MCP Tools Code Generator is a system designed to automate code generation for MCP tools. It will provide a flexible, template-based approach to generate consistent and maintainable code across the MCP toolset.
MCP (Modular Control Platform) tools are a suite of internal utilities used to manage, configure, and automate various aspects of our software infrastructure. Historically, developing and maintaining code for these tools has involved significant manual effort, leading to issues such as code duplication, inconsistency across tools, and increased maintenance overhead. The MCP Tools Code Generator is a system designed to automate code generation for MCP tools, addressing these pain points by providing a flexible, template-based approach to generate consistent and maintainable code across the MCP toolset.

Copilot uses AI. Check for mistakes.

## Architecture
The system follows a modular architecture with three main layers: Input Processing, Template Engine, and Code Generation. It uses the Template Method pattern for code generation workflows and the Strategy pattern for different output formats.

## Components


### ConfigurationManager
Handles all configuration aspects of the code generator

**Responsibilities:**
- Load and validate configuration files
- Manage template paths
- Store generation settings

**Interfaces:**
- loadConfig(path: string): Config
- getTemplatePath(): string
- getOutputSettings(): OutputSettings


### TemplateEngine
Core template processing and rendering engine

**Responsibilities:**
- Load template files
- Parse template syntax
- Render templates with data

**Interfaces:**
- loadTemplate(name: string): Template
- render(template: Template, data: object): string


### CodeGenerator
Main code generation orchestrator

**Responsibilities:**
- Coordinate generation process
- Apply transformations
- Write output files

**Interfaces:**
- generate(spec: GeneratorSpec): void
- validateOutput(code: string): boolean


## Data Flow

```mermaid
flowchart TD
Input[Input Files] --> Parser[Parser]
Parser --> DataModel[Data Model]
DataModel --> TemplateEngine[Template Engine]
Templates[Templates] --> TemplateEngine
TemplateEngine --> Generator[Code Generator]
Generator --> Output[Generated Code]
```

## Sequence Diagram

```mermaid
sequenceDiagram
participant User
participant Parser
participant TemplateEngine
participant Generator
User->>Parser: Parse Input
Parser->>TemplateEngine: Provide Data Model
TemplateEngine->>Generator: Render Template
Generator->>User: Return Generated Code
```

## Class Structure

```mermaid
classDiagram
class ConfigurationManager {
+loadConfig(path: string)
+getSettings(): Settings
}
class TemplateEngine {
+render(template: Template, data: object)
}
class CodeGenerator {
+generate(spec: GeneratorSpec)
}
CodeGenerator --> TemplateEngine
CodeGenerator --> ConfigurationManager
```

## Affected Areas

- MCP tools infrastructure
- Build system integration
- CI/CD pipelines
- Development workflows

## Dependencies

- Template engine library (e.g., Handlebars, EJS)
- File system access library
- YAML/JSON parser
- Code formatting tools
Comment on lines +105 to +108
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependencies section is too generic. Consider specifying exact library names and versions, or at least provide evaluation criteria for selecting between the mentioned options (e.g., why Handlebars vs EJS).

Suggested change
- Template engine library (e.g., Handlebars, EJS)
- File system access library
- YAML/JSON parser
- Code formatting tools
- Template engine library: **Handlebars v4.x** (chosen for its logic-less templates, wide adoption, and strong community support). If more advanced logic or custom tags are required, consider **EJS v3.x**. Criteria for selection: template syntax simplicity, extensibility, performance, and community support.
- File system access library: **Node.js fs/promises** (native, no external dependency).
- YAML/JSON parser: **js-yaml v4.x** for YAML, **JSON.parse** for JSON (native).
- Code formatting tools: **Prettier v3.x** (for consistent code formatting across generated files).

Copilot uses AI. Check for mistakes.

## Implementation Steps

1. Set up basic project structure and build system
2. Implement ConfigurationManager for settings handling
3. Create core TemplateEngine implementation
4. Develop CodeGenerator orchestrator
5. Add template loading and validation
6. Implement code generation pipeline
7. Add output validation and formatting
8. Create CLI interface
9. Add documentation and examples
10. Set up testing infrastructure

## Risks & Mitigation

- Template maintenance complexity as the number of templates grows
- Performance impact with large-scale code generation
- Integration challenges with existing build processes
- Potential for generated code conflicts
- Learning curve for template development

Comment on lines +126 to +130
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The risks section identifies potential issues but lacks mitigation strategies. Each risk should include specific mitigation approaches to make this section actionable for implementers.

Suggested change
- Performance impact with large-scale code generation
- Integration challenges with existing build processes
- Potential for generated code conflicts
- Learning curve for template development
- **Mitigation:** Establish template versioning, enforce template review processes, and automate template validation to catch errors early.
- Performance impact with large-scale code generation
- **Mitigation:** Optimize template rendering logic, implement caching for frequently used templates, and profile code generation to identify bottlenecks.
- Integration challenges with existing build processes
- **Mitigation:** Provide integration guides, maintain compatibility layers, and offer configurable output formats to ease adoption.
- Potential for generated code conflicts
- **Mitigation:** Implement output validation, use unique naming conventions, and provide conflict detection tools during generation.
- Learning curve for template development
- **Mitigation:** Offer comprehensive documentation, example templates, and training sessions for new developers.

Copilot uses AI. Check for mistakes.
## Testing Strategy

Testing will be implemented at multiple levels:
1. Unit tests for each component
2. Integration tests for the complete generation pipeline
3. Snapshot testing for generated code
4. Performance tests for large-scale generation
5. Template validation tests
6. End-to-end tests with actual MCP tools scenarios

---

*Generated automatically by Jira Technical Design Agent*
*Date: 2025-10-05T20:38:03.081Z*