Skip to main content
Glama
PWalaGov

Enhanced Directory Context MCP Server

by PWalaGov

analyze_project_context

Analyze project structure to generate intelligent context summaries, including code complexity and dependency analysis.

Instructions

Analyze the project structure and provide intelligent context summary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_code_analysisNoInclude code complexity and dependency analysis
focus_filesNoSpecific files to focus analysis on

Implementation Reference

  • Main handler function that executes the core logic of analyzing the project context, including directory structure, package.json parsing, README preview, file statistics, and listing important files.
    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;
  • Input schema defining parameters for the tool: 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)
    Tool registration object defining name, description, and input schema, added to the tools list for MCP server.
    { 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 case in the CallToolRequestSchema handler that routes tool calls to handleAnalyzeProjectContext.
    case 'analyze_project_context': return await this.handleAnalyzeProjectContext(args);
  • Wrapper handler that parses tool arguments and formats the response from the core analyzeProjectContext function.
    async 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, }, ], }; }

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/PWalaGov/File-Control-MCP'

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