File Operations MCP Server

File Operations MCP Server

A Model Context Protocol server that enables enhanced file system operations including reading, writing, copying, moving files with streaming capabilities, directory management, file watching, and change tracking.

bsmi021

File Systems
Local
TypeScript
Visit Server

Tools

copy_file

Copy a file to a new location

read_file

Read the contents of a file

write_file

Write content to a file

make_directory

Create a new directory

remove_directory

Remove a directory

list_directory

List contents of a directory with detailed metadata

copy_directory

Copy a directory and its contents to a new location

watch_directory

Watch a directory for changes

unwatch_directory

Stop watching a directory

is_watching

Check if a path is currently being watched

get_changes

Get list of tracked changes

clear_changes

Clear all tracked changes

README

File Operations MCP Server

smithery badge

A Model Context Protocol (MCP) server that provides enhanced file operation capabilities with streaming, patching, and change tracking support.

<a href="https://glama.ai/mcp/servers/7b750si00d"> <img width="380" height="200" src="https://glama.ai/mcp/servers/7b750si00d/badge" alt="File Operations Server MCP server" /> </a>

Features

  • Basic File Operations: Copy, read, write, move, and delete files
  • Directory Operations: Create, remove, and copy directories
  • File Watching: Monitor files and directories for changes
  • Change Tracking: Track and query file operation history
  • Streaming Support: Handle large files efficiently with streaming
  • Resource Support: Access files and directories through MCP resources
  • Progress Reporting: Real-time progress updates for long operations
  • Rate Limiting: Protection against excessive requests
  • Enhanced Security: Path validation and input sanitization
  • Robust Error Handling: Comprehensive error handling and reporting
  • Type Safety: Full TypeScript support with strict type checking

Installation

Installing via Smithery

To install File Operations Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @bsmi021/mcp-file-operations-server --client claude

Manual Installation

npm install

Usage

Starting the Server

npm start

For development with auto-reloading:

npm run dev

Available Tools

Basic File Operations

  • copy_file: Copy a file to a new location
  • read_file: Read content from a file
  • write_file: Write content to a file
  • move_file: Move/rename a file
  • delete_file: Delete a file
  • append_file: Append content to a file

Directory Operations

  • make_directory: Create a directory
  • remove_directory: Remove a directory
  • copy_directory: Copy a directory recursively (with progress reporting)

Watch Operations

  • watch_directory: Start watching a directory for changes
  • unwatch_directory: Stop watching a directory

Change Tracking

  • get_changes: Get the list of recorded changes
  • clear_changes: Clear all recorded changes

Available Resources

Static Resources

  • file:///recent-changes: List of recent file system changes

Resource Templates

  • file://{path}: Access file contents
  • metadata://{path}: Access file metadata
  • directory://{path}: List directory contents

Example Usage

// Copy a file
await fileOperations.copyFile({
    source: 'source.txt',
    destination: 'destination.txt',
    overwrite: false
});

// Watch a directory
await fileOperations.watchDirectory({
    path: './watched-dir',
    recursive: true
});

// Access file contents through resource
const resource = await mcp.readResource('file:///path/to/file.txt');
console.log(resource.contents[0].text);

// Copy directory with progress tracking
const result = await fileOperations.copyDirectory({
    source: './source-dir',
    destination: './dest-dir',
    overwrite: false
});
// Progress token in result can be used to track progress
console.log(result.progressToken);

Rate Limits

The server implements rate limiting to prevent abuse:

  • Tools: 100 requests per minute
  • Resources: 200 requests per minute
  • Watch Operations: 20 operations per minute

Rate limit errors include a retry-after period in the error message.

Security Features

Path Validation

All file paths are validated to prevent directory traversal attacks:

  • No parent directory references (../)
  • Proper path normalization
  • Input sanitization

Resource Protection

  • Rate limiting on all operations
  • Proper error handling and logging
  • Input validation on all parameters
  • Safe resource cleanup

Progress Reporting

Long-running operations like directory copying provide progress updates:

interface ProgressUpdate {
    token: string | number;
    message: string;
    percentage: number;
}

Progress can be tracked through the progress token returned in the operation result.

Development

Building

npm run build

Linting

npm run lint

Formatting

npm run format

Testing

npm test

Configuration

The server can be configured through various settings:

  • Rate Limiting: Configure request limits and windows
  • Progress Reporting: Control update frequency and detail level
  • Resource Access: Configure resource permissions and limits
  • Security Settings: Configure path validation rules
  • Change Tracking: Set retention periods and storage options
  • Watch Settings: Configure debounce times and recursive watching

Error Handling

The server provides detailed error information through the FileOperationError class and MCP error codes:

Standard MCP Error Codes

  • InvalidRequest: Invalid parameters or request format
  • MethodNotFound: Unknown tool or resource requested
  • InvalidParams: Invalid parameters (e.g., path validation failure)
  • InternalError: Server-side errors

Custom Error Types

  • File operation failures
  • Rate limit exceeded
  • Path validation errors
  • Resource access errors

Each error includes:

  • Specific error code
  • Detailed error message
  • Relevant metadata (file paths, limits, etc.)
  • Stack traces in development mode

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Recommended Servers

Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Excel MCP Server

Excel MCP Server

A Model Context Protocol server that enables AI assistants to read from and write to Microsoft Excel files, supporting formats like xlsx, xlsm, xltx, and xltm.

Featured
Local
Go
Playwright MCP Server

Playwright MCP Server

Provides a server utilizing Model Context Protocol to enable human-like browser automation with Playwright, allowing control over browser actions such as navigation, element interaction, and scrolling.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
Apple MCP Server

Apple MCP Server

Enables interaction with Apple apps like Messages, Notes, and Contacts through the MCP protocol to send messages, search, and open app content using natural language.

Featured
Local
TypeScript
contentful-mcp

contentful-mcp

Update, create, delete content, content-models and assets in your Contentful Space

Featured
TypeScript
serper-search-scrape-mcp-server

serper-search-scrape-mcp-server

This Serper MCP Server supports search and webpage scraping, and all the most recent parameters introduced by the Serper API, like location.

Featured
TypeScript
The Verge News MCP Server

The Verge News MCP Server

Provides tools to fetch and search news from The Verge's RSS feed, allowing users to get today's news, retrieve random articles from the past week, and search for specific keywords in recent Verge content.

Featured
TypeScript
MCP Server Trello

MCP Server Trello

Facilitates interaction with Trello boards via the Trello API, offering features like rate limiting, type safety, input validation, and error handling for seamless management of cards, lists, and board activities.

Featured
TypeScript