analyze_project_context
Examine project structure and dependencies to generate an intelligent context summary. Supports code complexity analysis and targeted file focus for detailed insights.
Instructions
Analyze the project structure and provide intelligent context summary
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| focus_files | No | Specific files to focus analysis on | |
| include_code_analysis | No | Include code complexity and dependency analysis |
Implementation Reference
- server.js:141-155 (schema)Input schema for the analyze_project_context tool defining parameters include_code_analysis (boolean, default true) and focus_files (array of strings)inputSchema: { type: 'object', properties: { include_code_analysis: { type: 'boolean', description: 'Include code complexity and dependency analysis', default: true, }, focus_files: { type: 'array', description: 'Specific files to focus analysis on', items: { type: 'string' }, }, }, },
- server.js:138-156 (registration)Registration of analyze_project_context tool in the ListToolsRequestSchema handler, including name, description, and input schema{ name: 'analyze_project_context', description: 'Analyze the project structure and provide intelligent context summary', inputSchema: { type: 'object', properties: { include_code_analysis: { type: 'boolean', description: 'Include code complexity and dependency analysis', default: true, }, focus_files: { type: 'array', description: 'Specific files to focus analysis on', items: { type: 'string' }, }, }, }, },
- server.js:466-467 (registration)Dispatch registration in CallToolRequestSchema switch statementcase 'analyze_project_context': return await this.handleAnalyzeProjectContext(args);
- server.js:921-933 (handler)Handler wrapper: extracts tool arguments, calls core analysis, returns MCP-formatted text responseasync handleAnalyzeProjectContext(args) { const { include_code_analysis = true, focus_files } = args; const analysis = await this.analyzeProjectContext(include_code_analysis, focus_files); return { content: [ { type: 'text', text: analysis, }, ], }; }
- server.js:1076-1132 (helper)Core implementation: analyzes directory structure, detects project type, parses package.json and README, computes file stats and important files, generates markdown summary (note: parameters includeCodeAnalysis and focusFiles not yet utilized)async analyzeProjectContext(includeCodeAnalysis, focusFiles) { const structure = await this.getDirectoryStructure(this.workingDirectory, 5); const packageJsonPath = path.join(this.workingDirectory, 'package.json'); const readmePath = path.join(this.workingDirectory, 'README.md'); let analysis = `# Project Context Analysis\n\n`; analysis += `**Working Directory:** ${this.workingDirectory}\n\n`; // Project type detection const projectType = await this.detectProjectType(); analysis += `**Project Type:** ${projectType}\n\n`; // Package.json analysis try { const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8')); analysis += `**Project Name:** ${packageJson.name || 'Unnamed'}\n`; analysis += `**Version:** ${packageJson.version || 'No version'}\n`; analysis += `**Description:** ${packageJson.description || 'No description'}\n\n`; if (packageJson.dependencies) { analysis += `**Dependencies:** ${Object.keys(packageJson.dependencies).length}\n`; } if (packageJson.devDependencies) { analysis += `**Dev Dependencies:** ${Object.keys(packageJson.devDependencies).length}\n`; } analysis += '\n'; } catch (error) { // No package.json found } // README analysis try { const readme = await fs.readFile(readmePath, 'utf8'); const lines = readme.split('\n').slice(0, 10); analysis += `**README Preview:**\n${lines.join('\n')}\n\n`; } catch (error) { // No README found } // File statistics const stats = this.calculateFileStats(structure); analysis += `**File Statistics:**\n`; analysis += `- Total Files: ${stats.totalFiles}\n`; analysis += `- Total Directories: ${stats.totalDirectories}\n`; analysis += `- File Types: ${Object.keys(stats.fileTypes).join(', ')}\n\n`; // Important files const importantFiles = this.identifyImportantFiles(structure); if (importantFiles.length > 0) { analysis += `**Important Files:**\n`; importantFiles.slice(0, 10).forEach(file => { analysis += `- ${file.path}\n`; }); analysis += '\n'; } return analysis;