analyze_code_architecture
Analyze code architecture to assess design patterns, SOLID principles, scalability, and security. Submit your code, language, and specific question to receive tailored improvement recommendations.
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
| 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 actual handler function that executes the 'analyze_code_architecture' tool logic. It builds a query prompt with the code, language, and architectural question, then delegates to consultArchitecture() which calls the GLM-4.6 API.
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:43-63 (schema)Input schema for the 'analyze_code_architecture' tool. Defines required 'code', 'language', and 'question' string properties with descriptions.
{ 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:24-118 (registration)The tool is registered in the 'tools' array (line 44) which is returned via ListToolsRequestSchema handler (line 133). The array is defined at line 24.
const tools: Tool[] = [ { name: 'consult_architecture', description: 'Consult GLM-4.6 for expert software architecture guidance, system design patterns, scalability strategies, and technical decision-making. Use this for high-level architectural questions requiring deep technical expertise.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The architectural question or problem requiring expert consultation', }, context: { type: 'string', description: 'Optional additional context about the system, requirements, or constraints', }, }, required: ['query'], }, }, { 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'], }, }, { name: 'design_system_architecture', description: 'Design a complete system architecture based on requirements using GLM-4.6. Provides component breakdown, data flow patterns, technology recommendations, and deployment strategies.', inputSchema: { type: 'object', properties: { requirements: { type: 'string', description: 'Detailed system requirements, constraints, and objectives', }, }, required: ['requirements'], }, }, { name: 'review_technical_decision', description: 'Review and evaluate a technical decision using GLM-4.6 architectural expertise. Assesses impact, trade-offs, alternatives, risks, and provides recommendations.', inputSchema: { type: 'object', properties: { decision: { type: 'string', description: 'The technical decision to review', }, context: { type: 'string', description: 'Context including current architecture, constraints, and objectives', }, }, required: ['decision', 'context'], }, }, { name: 'advanced_reasoning', description: 'Consult GLM-4.6 for advanced mathematical, algorithmic, and scientific reasoning tasks. Delivers world-class innovative solutions with rigorous methodology, optimal algorithms, and enterprise-grade quality. Use for: complex algorithms, mathematical proofs, performance optimization, advanced data structures, computational problems, scientific analysis. Response optimized for Claude 4.5 Sonnet with XML structure.', inputSchema: { type: 'object', properties: { task: { type: 'string', description: 'The specific mathematical, algorithmic, or scientific task requiring advanced reasoning', }, context: { type: 'string', description: 'Comprehensive context including: problem domain, constraints, requirements, current approach (if any), performance requirements, business logic', }, expected_outcome: { type: 'string', description: 'Detailed description of expected outcome: solution characteristics, performance targets, quality metrics, innovation requirements', }, }, required: ['task', 'context', 'expected_outcome'], }, }, - src/index.ts:155-169 (handler)The MCP request handler case for 'analyze_code_architecture'. It destructures args (code, language, question), calls glmClient.analyzeCodeArchitecture(), and returns the response.
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, }, ], };