Enhanced Directory Context MCP Server
Detects PHP Composer projects through composer.json files for project type identification and dependency analysis
Detects and analyzes Docker configurations including Dockerfile and docker-compose.yml files as part of project type detection
Automatically identifies and prioritizes .env environment files as important configuration files in project analysis
Provides Git repository integration including commit history, branch information, working directory status, and diff visualization for project analysis
Identifies Java/Android projects through build.gradle files for project type detection and build configuration analysis
Provides Node.js project detection and analysis through package.json files, enabling project type identification and dependency management understanding
Detects PHP projects through composer.json files and provides PHP-specific project analysis
Detects Python projects through requirements.txt files and provides Python-specific project analysis capabilities
Identifies Ruby projects through Gemfile detection and provides Ruby-specific project context
Identifies Rust projects through Cargo.toml files and provides Rust-specific project context analysis
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Enhanced Directory Context MCP Server show me the project structure of the current directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Enhanced Directory Context MCP Server
TL;DR: A powerful MCP server that gives AI assistants full directory analysis and file editing capabilities.
What It Does
📁 Analyze directories - Get project structure, find files, search content
✏️ Edit files - Create, update, delete, rename files and folders
🔍 Smart search - Find code/text across multiple files with regex support
🔄 Git integration - View commits, branches, and changes
🛡️ Safe operations - Auto-backups and transaction rollback
Related MCP server: AI FileSystem MCP
Quick Setup
Install dependencies:
npm installAdd to your Claude Desktop config:
{
"mcpServers": {
"directory-context": {
"command": "node",
"args": ["path/to/server.js"]
}
}
}Main Tools
Tool | What It Does |
| Set the folder to work in |
| Show folder/file tree |
| Find text in files |
| Make new files |
| Edit existing files |
| Remove files (with backup) |
| Do multiple operations at once |
Enhanced Directory Context MCP Server
A comprehensive Model Context Protocol (MCP) server that provides advanced directory analysis and file management capabilities for AI assistants like Claude. This server combines directory context extraction with full file editing capabilities, making it a powerful tool for code analysis, project management, and file operations.
Features
🔍 Directory Analysis
Complete Directory Structure: Get detailed tree views of any directory with metadata
Intelligent Project Analysis: Automatic project type detection and context summary
Smart File Search: Regex and text-based search across multiple file types
Git Integration: Extract repository context, commit history, and working directory status
File Statistics: Comprehensive analysis of file types, sizes, and modification dates
📝 File Operations
Create Files: Generate new files with specified content
Update Files: Sophisticated search-and-replace operations with regex support
Append Content: Add content to existing files with formatting options
Delete Files: Remove files with optional backup creation
Rename/Move Files: Relocate and rename files with collision detection
Directory Management: Create directory structures recursively
🔄 Advanced Features
Batch Operations: Execute multiple file operations in a single transaction
Automatic Backups: Optional backup creation for destructive operations
Transaction Rollback: Rollback capability for failed batch operations
Resource Exposure: Automatic exposure of important project files as MCP resources
Error Handling: Comprehensive error handling with detailed feedback
Installation
Prerequisites
Node.js 18.0.0 or higher
npm or yarn package manager
Setup
Clone or download the MCP server files
Install dependencies:
npm installConfigure your MCP client (Claude Desktop, etc.) to use this server:
Claude Desktop Configuration:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"directory-context": {
"command": "node",
"args": ["path/to/your/server.js"],
"cwd": "your-default-working-directory"
}
}
}Alternative Configuration:
Use the provided mcp-json-config.json as a template and update the paths accordingly.
Usage
Setting Up Your Working Directory
Before using any features, set your working directory:
set_working_directory(directory="/path/to/your/project")Directory Analysis Tools
Get Directory Structure
get_directory_structure(
max_depth=10, // Maximum traversal depth
include_hidden=false, // Include hidden files/directories
file_types=[".js", ".py", ".md"] // Filter by extensions
)Analyze Project Context
analyze_project_context(
include_code_analysis=true, // Include complexity analysis
focus_files=["specific_file.js"] // Focus on specific files
)Search Files
search_files(
query="function myFunction", // Search query
file_types=[".js", ".ts"], // File types to search
is_regex=false, // Use regex matching
max_results=50 // Maximum results
)Git Context
get_git_context(
include_diff=true, // Include working directory changes
commit_count=10 // Number of recent commits
)File Management Tools
Create Files
create_file(
path="src/new-component.js",
content="const MyComponent = () => { ... }",
encoding="utf8",
overwrite=false
)Update Files
update_file(
path="src/config.js",
updates=[
{
search: "oldValue: 'old'",
replace: "newValue: 'new'",
regex: false,
all: true
}
],
backup=true
)Append to Files
append_to_file(
path="README.md",
content="## New Section\nContent here...",
newline_before=true
)Delete Files
delete_file(
path="old-file.js",
backup=true // Creates .deleted backup
)Rename/Move Files
rename_file(
old_path="old-name.js",
new_path="new-name.js",
overwrite=false
)Create Directories
create_directory(
path="src/components/new-feature",
recursive=true
)Batch Operations
Execute multiple operations atomically:
batch_file_operations(
operations=[
{
operation: "create",
params: {
path: "src/component.js",
content: "export default () => {}"
}
},
{
operation: "update",
params: {
path: "src/index.js",
updates: [...]
}
}
],
rollback_on_error=true
)Project Type Detection
The server automatically detects project types based on configuration files:
Node.js/JavaScript:
package.jsonPython:
requirements.txtRust:
Cargo.tomlGo:
go.modJava:
pom.xml,build.gradlePHP:
composer.jsonRuby:
GemfileDocker:
Dockerfile,docker-compose.ymlAnd more...
File Priority Detection
The server identifies important files automatically:
Configuration files (
package.json,config.js, etc.)Entry points (
index.js,main.py,app.js)Documentation (
README.md, docs)Docker files
Environment files (
.env)
Resource Exposure
Important files are automatically exposed as MCP resources, making them easily accessible to AI assistants without explicit file reading requests.
Error Handling and Safety Features
Backup Creation: Automatic backups for destructive operations
Collision Detection: Prevents accidental overwrites
Transaction Rollback: Batch operations can be fully rolled back on error
Path Validation: Ensures operations stay within working directory bounds
Detailed Error Messages: Comprehensive error reporting for debugging
API Reference
Core Tools
Tool | Description | Required Parameters |
| Set the working directory |
|
| Get directory tree | None |
| Read multiple files |
|
| Search within files |
|
| Analyze project | None |
| Git repository info | None |
File Operations
Tool | Description | Required Parameters |
| Create new file |
|
| Update existing file |
|
| Append to file |
|
| Delete file |
|
| Rename/move file |
|
| Create directory |
|
| Multiple operations |
|
Configuration Options
Server Configuration
Working Directory: Set via
set_working_directoryor during initializationFile Type Filters: Configurable file extension filtering
Search Limits: Configurable maximum search results
Backup Policies: Optional backup creation for destructive operations
MCP Client Configuration
Configure the server in your MCP client with appropriate command and arguments. The server communicates via stdio and requires no additional network configuration.
Development and Contribution
Project Structure
enhanced-directory-context-mcp/
├── server.js # Main MCP server implementation
├── package.json # Node.js package configuration
├── mcp-json-config.json # Example MCP client configuration
└── README.md # This documentationDependencies
@modelcontextprotocol/sdk: Core MCP functionalityNode.js built-in modules:
fs,path,child_process
Running in Development Mode
npm run devThis starts the server with Node.js inspector enabled for debugging.
License
MIT License - See package.json for details.
Support and Issues
For issues, feature requests, or contributions, please refer to the repository's issue tracker.
Note: This MCP server provides powerful file system access. Ensure you trust the AI assistant and understand the operations being performed, especially destructive operations like file deletion or modification.
Available Tools
13 toolsanalyze_project_contextC
Analyze the project structure and provide intelligent context summary
Inputs: include_code_analysis, focus_files.
append_to_fileC
Append content to the end of a file
Inputs: path (required), content (required), newline_before.
batch_file_operationsB
Perform multiple file operations in a single transaction
Inputs: operations (required), rollback_on_error.
create_directoryC
Create a new directory
Inputs: path (required), recursive.
create_fileC
Create a new file with specified content
Inputs: path (required), content (required), encoding, overwrite.
delete_fileC
Delete a file
Inputs: path (required), backup.
get_directory_structureC
Get the complete directory structure with file metadata
Inputs: max_depth, include_hidden, file_types.
get_file_contentsC
Read contents of specific files
Inputs: files (required), encoding.
get_git_contextC
Extract Git repository context (branch, recent commits, status)
Inputs: include_diff, commit_count.
rename_fileC
Rename or move a file
Inputs: old_path (required), new_path (required), overwrite.
search_filesC
Search for content within files using regex or text matching
Inputs: query (required), file_types, is_regex, max_results.
set_working_directoryC
Set the working directory for context extraction
Inputs: directory (required).
update_fileB
Update specific parts of a file using search and replace
Inputs: path (required), updates (required), backup.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Most tools have distinct purposes targeting specific file/directory operations, but some overlap exists: 'update_file' and 'append_to_file' both modify file content, and 'get_directory_structure' and 'analyze_project_context' both provide structural insights, though descriptions help differentiate them.
All tools follow a consistent verb_noun pattern with clear, descriptive names (e.g., 'create_file', 'delete_file', 'get_file_contents'). There are no deviations in naming conventions, making the set predictable and readable.
With 13 tools, this server is well-scoped for directory and file management, covering essential operations like create, read, update, delete, search, and context extraction. Each tool serves a clear purpose without bloat.
The toolset provides comprehensive coverage for file system operations, including CRUD for files/directories, content manipulation, searching, and context extraction (e.g., Git, project analysis). There are no obvious gaps that would hinder agent workflows in this domain.
Related MCP Connectors
Manage files and folders directly from your workspace. Read and write files, list directories, cre…
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables comprehensive filesystem operations including reading/writing files, directory management, file searching, editing with diff preview, compression, hashing, and merging with dynamic directory access control.1,222,611 npm-
- AlicenseAqualityDmaintenanceProvides intelligent file system operations with advanced features including code analysis and modification across multiple languages, version control (Git/GitHub), file compression, encryption, semantic search, batch operations, and secure shell command execution.15MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI-driven development tools including file system operations, multi-language code analysis with tree-sitter, Git operations, code execution, and system information retrieval.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage project analysis, code metrics, documentation, Git operations, code quality, and file organization through natural language commands.2MIT