analyze_code_architecture
Analyze source code architecture to evaluate design patterns, SOLID principles, scalability, and security while 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/index.ts:155-170 (handler)MCP tool handler for 'analyze_code_architecture' that extracts input arguments (code, language, question) and delegates execution to GLMClient.analyzeCodeArchitecture method.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, }, ], }; }
- src/index.ts:43-64 (registration)Tool registration entry in the MCP tools array, defining name, description, and input schema for validation.{ 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/glm-client.ts:124-141 (helper)Helper method implementing the core logic: constructs a specific prompt with code snippet and question, then calls consultArchitecture to invoke GLM-4.6 API for 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); }