Skip to main content
Glama

analyze_project

Analyze project structure, code quality, and architecture to help understand existing codebases. Provides deep insights into directory organization and technical implementation details.

Instructions

【项目分析】深度分析项目结构、代码质量和架构,帮助AI快速理解老项目

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_contentNo是否包含文件内容(默认 true)
max_depthNo目录树最大深度(默认 5)
project_pathNo项目路径(默认当前目录)

Implementation Reference

  • Main handler function for the 'analyze_project' tool. Performs comprehensive project analysis including structure, dependencies, code metrics, and generates a detailed Markdown report.
    export async function analyzeProject(args: any): Promise<any> { const projectPath = args.project_path || process.cwd(); const maxDepth = args.max_depth || 5; const includeContent = args.include_content !== false; try { console.error(`开始分析项目: ${projectPath}`); const analysis = await performProjectAnalysis(projectPath, maxDepth, includeContent); return { content: [ { type: "text", text: `# 📊 项目分析报告 ## 🏗️ 项目概览 - **项目名称**: ${analysis.projectStructure.name} - **项目类型**: ${analysis.projectStructure.type} - **技术栈**: ${analysis.projectStructure.framework} - **主要语言**: ${analysis.projectStructure.language} - **包管理器**: ${analysis.projectStructure.packageManager} ## 📁 目录结构 \`\`\` ${analysis.directoryTree} \`\`\` ## 🔑 关键文件 ${analysis.keyFiles.map(file => `### ${file.path} **用途**: ${file.purpose} ${includeContent ? `\`\`\`${getFileExtension(file.path)} ${file.content.substring(0, 500)}${file.content.length > 500 ? '\n...' : ''} \`\`\`` : ''}`).join('\n\n')} ## 📦 依赖分析 - **生产依赖**: ${analysis.dependencies.production.length} 个 - **开发依赖**: ${analysis.dependencies.development.length} 个 - **总依赖数**: ${analysis.dependencies.total} 个 ### 主要依赖 ${analysis.dependencies.production.slice(0, 10).map(dep => `- ${dep}`).join('\n')} ## 📈 代码指标 - **总文件数**: ${analysis.codeMetrics.totalFiles} - **总行数**: ${analysis.codeMetrics.totalLines} ${analysis.codeMetrics.skippedFiles > 0 ? `- **跳过文件**: ${analysis.codeMetrics.skippedFiles} 个(过大或无法读取)` : ''} - **文件类型分布**: ${Object.entries(analysis.codeMetrics.fileTypes) .sort(([, a], [, b]) => (b as number) - (a as number)) .slice(0, 10) .map(([type, count]) => ` - ${type}: ${count} 个文件`) .join('\n')} ${Object.keys(analysis.codeMetrics.fileTypes).length > 10 ? ' - ... (更多类型已省略)' : ''} ### 最大文件 ${analysis.codeMetrics.largestFiles.slice(0, 5).map(file => `- ${file.path} (${file.lines} 行)` ).join('\n')} ## 🏛️ 架构分析 - **设计模式**: ${analysis.architecture.patterns.join(', ')} - **入口文件**: ${analysis.architecture.entryPoints.join(', ')} - **核心模块**: ${analysis.architecture.mainModules.join(', ')} ## 📋 项目总结 **项目目的**: ${analysis.summary.purpose} **复杂度**: ${analysis.summary.complexity} **建议**: ${analysis.summary.recommendations.map(rec => `- ${rec}`).join('\n')} --- *分析完成时间: ${new Date().toLocaleString('zh-CN')}* *分析工具: MCP Probe Kit v${VERSION}* **分析说明**: - 大型项目会自动采样分析,限制最多扫描 5000 个文件 - 已自动忽略以下目录: \`node_modules\`, \`dist\`, \`build\`, \`.git\`, \`coverage\`, \`.next\`, \`.nuxt\`, \`vendor\` 等 - 单个文件大小限制: 1MB,超过则跳过`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `❌ 项目分析失败: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Input schema definition for the 'analyze_project' tool, registered in the ListToolsRequestHandler.
    name: "analyze_project", description: "【项目分析】深度分析项目结构、代码质量和架构,帮助AI快速理解老项目", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "项目路径(默认当前目录)", }, max_depth: { type: "number", description: "目录树最大深度(默认 5)", }, include_content: { type: "boolean", description: "是否包含文件内容(默认 true)", }, }, required: [], }, },
  • src/index.ts:525-526 (registration)
    Tool dispatch registration in the CallToolRequestHandler switch statement.
    case "analyze_project": return await analyzeProject(args);
  • Re-export of the analyzeProject handler from tools/index.ts, imported by src/index.ts.
    export { analyzeProject } from "./analyze_project.js";
  • Helper function to analyze basic project structure from package.json.
    function analyzeProjectStructure(packageJson: any) { const name = packageJson.name || 'unknown'; const type = detectProjectType(packageJson); const framework = detectFramework(packageJson); const language = detectLanguage(packageJson); const packageManager = detectPackageManager(); return { name, type, framework, language, packageManager }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mybolide/mcp-probe-kit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server