Skip to main content
Glama

Enhanced Directory Context MCP Server

by PWalaGov

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

Quick Setup

  1. Install dependencies: npm install

  2. Add to your Claude Desktop config:

{ "mcpServers": { "directory-context": { "command": "node", "args": ["path/to/server.js"] } } }

Main Tools

Tool

What It Does

set_working_directory

Set the folder to work in

get_directory_structure

Show folder/file tree

search_files

Find text in files

create_file

Make new files

update_file

Edit existing files

delete_file

Remove files (with backup)

batch_file_operations

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

  1. Clone or download the MCP server files

  2. Install dependencies:

npm install
  1. Configure 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.json

  • Python: requirements.txt

  • Rust: Cargo.toml

  • Go: go.mod

  • Java: pom.xml, build.gradle

  • PHP: composer.json

  • Ruby: Gemfile

  • Docker: Dockerfile, docker-compose.yml

  • And 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_working_directory

Set the working directory

directory

get_directory_structure

Get directory tree

None

get_file_contents

Read multiple files

files

search_files

Search within files

query

analyze_project_context

Analyze project

None

get_git_context

Git repository info

None

File Operations

Tool

Description

Required Parameters

create_file

Create new file

path

,

content

update_file

Update existing file

path

,

updates

append_to_file

Append to file

path

,

content

delete_file

Delete file

path

rename_file

Rename/move file

old_path

,

new_path

create_directory

Create directory

path

batch_file_operations

Multiple operations

operations

Configuration Options

Server Configuration

  • Working Directory: Set via set_working_directory or during initialization

  • File 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 documentation

Dependencies

  • @modelcontextprotocol/sdk: Core MCP functionality

  • Node.js built-in modules: fs, path, child_process

Running in Development Mode

npm run dev

This 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.

Deploy Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

Enables comprehensive directory analysis and file management operations including project structure exploration, intelligent file search, full CRUD operations on files and directories, batch operations with rollback capabilities, and Git integration.

  1. What It Does
    1. Quick Setup
      1. Main Tools
        1. Enhanced Directory Context MCP Server
          1. Features
          2. Installation
          3. Usage
          4. Project Type Detection
          5. File Priority Detection
          6. Resource Exposure
          7. Error Handling and Safety Features
          8. API Reference
          9. Configuration Options
          10. Development and Contribution
          11. License
          12. Support and Issues

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          Provides tools for collecting and documenting code from directories.
          Last updated -
          4
          25
          15
          MIT License
          • Apple
          • Linux
        • -
          security
          A
          license
          -
          quality
          Enables integration with Google Drive for listing, reading, and searching over files, supporting various file types with automatic export for Google Workspace files.
          Last updated -
          714
          48
          MIT License
        • A
          security
          F
          license
          A
          quality
          Enables comprehensive GitHub operations through natural language including file management, repository administration, issue tracking, and advanced code searching.
          Last updated -
          47
          0
          1
        • A
          security
          A
          license
          A
          quality
          Provides tools for analyzing project structures, searching through codebases, managing dependencies, and performing file operations with advanced filtering capabilities.
          Last updated -
          6
          17
          1
          MIT License

        View all related MCP servers

        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