MCP Filesystem Server

by gabrielmaialva33
Verified
MIT License
67
6
  • Linux
  • Apple

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Provides containerized deployment of the MCP server, with support for mounting host directories as read-only or read-write volumes, allowing secure file operations from within Docker containers.

:bookmark: について

**MCPファイルシステムサーバーは、**モデルコンテキストプロトコルを通じてAIモデルに安全なファイルシステムアクセスを提供します。厳格なパス検証を実施し、事前定義されたディレクトリへのアクセスのみを許可します。

:コンピュータ: テクノロジー

:wrench: ツール

:package: インストール

:heavy_check_mark:前提条件

次のソフトウェアをインストールする必要があります:

:arrow_down:リポジトリのクローン

$ git clone https://github.com/gabrielmaialva33/mcp-filesystem.git $ cd mcp-filesystem

:arrow_forward:アプリケーションの実行

地域開発

# Install dependencies $ pnpm install # Build the application $ pnpm build # Run the server (specify directory to allow access to) $ pnpm start /path/to/allowed/directory # Or use configuration file $ pnpm start --config=config.json

NPMパッケージの使用

# Install globally $ npm install -g @gabrielmaialva33/mcp-filesystem # Run the server $ mcp-filesystem /path/to/allowed/directory # Or use with npx (no installation needed) $ npx @gabrielmaialva33/mcp-filesystem /path/to/allowed/directory # Create a sample configuration file $ npx @gabrielmaialva33/mcp-filesystem --create-config=config.json

Dockerの使用

# Build the Docker image $ docker build -t gabrielmaialva33/mcp-filesystem . # Run using Docker $ docker run -i --rm -v /path/to/data:/data:ro gabrielmaialva33/mcp-filesystem /data # Use with config file $ docker run -i --rm -v /path/to/config.json:/app/config.json -v /path/to/data:/data gabrielmaialva33/mcp-filesystem --config=/app/config.json

Docker Composeの使用

# Create a data directory $ mkdir -p data # Start the server $ docker-compose up -d

:gear: 使用方法

Claude Desktopでの使用

Claude Desktop は、ファイルシステムへのアクセスにこの MCP サーバーclaude_desktop_config.json使用するように設定できます。claude_desktop_config.json に以下の行を追加してください。

ローカルインストールの使用(推奨)

{ "mcpServers": { "filesystem": { "command": "mcp-filesystem", "args": [ "/Users/gabrielmaia/Documents", "/Users/gabrielmaia/Desktop", "/Users/gabrielmaia/Downloads" ] } } }

実行可能ファイルがグローバルに利用できるようにしてください。

# Make the binary executable chmod +x /Users/gabrielmaia/.nvm/versions/node/v22.14.0/bin/mcp-filesystem

NPXの使用

{ "mcpServers": { "filesystem": { "command": "npx", "args": [ "-y", "@gabrielmaialva33/mcp-filesystem", "/Users/username/Desktop", "/path/to/other/allowed/dir" ] } } }

Dockerの使用

注: Docker ro使用する場合、すべてのディレクトリはデフォルトで/projectsにマウントされる必要があります。roフラグを追加すると、ディレクトリは読み取り専用になります。

{ "mcpServers": { "filesystem": { "command": "docker", "args": [ "run", "-i", "--rm", "--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop", "--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro", "--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt", "gabrielmaialva33/mcp-filesystem", "/projects" ] } } }

利用可能なツール

MCP ファイルシステム サーバーは次のツールを提供します。

ファイルシステム操作

  • read_file : ファイルの内容を読み取る
  • read_multiple_files : 複数のファイルを一度に読み取る
  • write_file : ファイルを作成または上書きする
  • edit_file : 差分プレビューで正確な編集を行う
  • create_directory : ディレクトリを再帰的に作成する
  • list_directory : ディレクトリの内容を一覧表示する
  • directory_tree : 再帰ツリービューを取得する
  • move_file : ファイルを移動または名前変更する
  • search_files : パターンに一致するファイルを検索する
  • get_file_info : ファイルのメタデータを取得する
  • list_allowed_directories : アクセス可能なディレクトリを表示する

システムおよびネットワーク運用

  • get_metrics : サーバーのパフォーマンスメトリックを表示する (v0.3.0+)
  • execute_command : システムコマンドを安全に実行する (v0.3.1+)
  • curl_request : 外部 API への HTTP リクエストを実行する (v1.2.0 で導入予定)

curl_request ツールの使用 (v1.2.0 で登場)

curl_requestツールを使用すると、外部 API に HTTP リクエストを送信できます。

// Example: Making a GET request with authentication curl_request({ url: 'https://api.example.com/data', method: 'GET', headers: { Authorization: 'Bearer your_token_here', }, }) // Example: POST request with JSON data curl_request({ url: 'https://api.example.com/create', method: 'POST', headers: { 'Content-Type': 'application/json', }, data: '{"name":"Example","value":123}', })

より詳細な例については、 docs/curl-tool-examples.mdファイルを参照してください。

:sparkles: 機能

コア機能

  • セキュアアクセス: 厳格なパス検証により不正アクセスを防止
  • ファイル操作: ファイルの読み取り、書き込み、編集、移動
  • ディレクトリ操作: ディレクトリの作成、一覧表示、ツリービューの取得、検索
  • メタデータ アクセス: ファイルとディレクトリの情報を表示する
  • コマンド実行: 厳格な検証によりシステムコマンドを安全に実行
  • Docker サポート: Docker と Docker Compose による簡単なデプロイ

v0.3.0の新機能

  • 構造化ログ: さまざまなレベル (デバッグ、情報、警告、エラー) での詳細なログ記録
  • パフォーマンス メトリック: 操作数、エラー、実行時間を追跡します
  • 構成管理: JSON 構成ファイルのサポート
  • パスキャッシュ: 頻繁にアクセスされるパスのパフォーマンスが向上
  • エラー処理の改善: 構造化された情報を持つ特殊なエラータイプ
  • ファイルサイズ検証: 過度に大きなファイルの読み込みを防止
  • CLI の改善: ヘルプ コマンド、バージョン情報、構成生成

設定オプション

次のようにして構成ファイルを作成できます。

$ mcp-filesystem --create-config=config.json

構成例:

{ "allowedDirectories": ["/path/to/allowed/dir1", "/path/to/allowed/dir2"], "logLevel": "info", "logFile": "/path/to/logs/mcp-filesystem.log", "serverName": "secure-filesystem-server", "serverVersion": "0.3.0", "cache": { "enabled": true, "maxSize": 1000, "ttlMs": 60000 }, "metrics": { "enabled": true, "reportIntervalMs": 60000 }, "security": { "maxFileSize": 10485760, "allowSymlinks": true, "validateRealPath": true } }

:writing_hand:著者

ガブリエル・マイア

ライセンス

MITライセンス

-
security - not tested
A
license - permissive license
-
quality - not tested

事前定義されたディレクトリ内で制御されたファイルシステム アクセスを提供する安全なモデル コンテキスト プロトコル サーバー。これにより、AI モデルは厳密なパス検証を使用してファイルおよびディレクトリ操作を実行できます。

  1. :computer: Technologies
    1. :wrench: Tools
      1. :package: Installation
        1. :heavy_check_mark: Prerequisites
        2. :arrow_down: Cloning the repository
        3. :arrow_forward: Running the application
      2. :gear: Usage
        1. Using with Claude Desktop
        2. Available Tools
      3. :sparkles: Features
        1. Core Features
        2. New Features in v0.3.0
        3. Configuration Options
        4. :writing_hand: Author
      4. License
        ID: f72blrvat4