analyze_code_architecture
Analyze code architecture to evaluate design patterns, SOLID principles, scalability, and security, providing improvement recommendations for better system design.
Instructions
Analyze code from an architectural perspective using GLM-4.6. Evaluates design patterns, SOLID principles, scalability, security implications, and provides improvement recommendations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The source code to analyze | |
| language | Yes | Programming language of the code (e.g., typescript, python, go, java) | |
| question | Yes | Specific architectural question about the code |
Implementation Reference
- src/glm-client.ts:124-141 (handler)The core handler function that implements the tool logic. It constructs a specialized prompt including the code snippet, language, and question, then delegates to the GLMClient's consultArchitecture method for AI-powered analysis.async analyzeCodeArchitecture(code: string, language: string, question: string): Promise<string> { const query = `Analyze the following ${language} code from an architectural perspective: \`\`\`${language} ${code} \`\`\` Architectural Question: ${question} Provide analysis covering: 1. Architectural patterns used 2. Design principles adherence (SOLID, DRY, KISS) 3. Scalability considerations 4. Security implications 5. Recommended improvements`; return this.consultArchitecture(query); }
- src/index.ts:46-63 (schema)Defines the input validation schema for the tool, requiring code, language, and question parameters.inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'The source code to analyze', }, language: { type: 'string', description: 'Programming language of the code (e.g., typescript, python, go, java)', }, question: { type: 'string', description: 'Specific architectural question about the code', }, }, required: ['code', 'language', 'question'], },
- src/index.ts:43-64 (registration)Registers the tool in the MCP tools list with name, description, and schema.{ name: 'analyze_code_architecture', description: 'Analyze code from an architectural perspective using GLM-4.6. Evaluates design patterns, SOLID principles, scalability, security implications, and provides improvement recommendations.', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'The source code to analyze', }, language: { type: 'string', description: 'Programming language of the code (e.g., typescript, python, go, java)', }, question: { type: 'string', description: 'Specific architectural question about the code', }, }, required: ['code', 'language', 'question'], }, },
- src/index.ts:155-170 (registration)Dispatches tool calls in the MCP CallToolRequestHandler by matching the tool name and invoking the handler with parsed arguments.case 'analyze_code_architecture': { const { code, language, question } = args as { code: string; language: string; question: string; }; const response = await glmClient.analyzeCodeArchitecture(code, language, question); return { content: [ { type: 'text', text: response, }, ], }; }