Filesystem MCP Server

local-only server

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

Integrations

  • Included in development dependencies for code linting within the file system operations.

  • Included in development dependencies for running tests on the file system operations and analysis capabilities.

  • Used for visualizing the architecture of the MCP server in documentation.

ファイルシステムMCPサーバー

標準化されたツール インターフェイスを通じてファイル システムの操作、分析、および操作機能を提供するモデル コンテキスト プロトコル (MCP) サーバー実装。

建築

サーバーは MCP SDK 上に構築され、明確なレイヤーに編成されています。

コンポーネント

  • サーバー層: MCPプロトコル通信とツールディスパッチを処理する
  • ツールレジストリ: ツールの登録と実行を管理します
  • 運用層: コア機能を実装する
  • ファイルシステムインターフェース:安全なファイルシステムアクセスを提供する

インストール

  1. リポジトリをクローンします。
git clone <repository-url> cd filesystem-server
  1. 依存関係をインストールします:
npm install
  1. サーバーを構築します。
npm run build
  1. MCP 設定を構成します (cline_mcp_settings.json):
{ "mcpServers": { "filesystem": { "command": "node", "args": ["path/to/filesystem-server/build/index.js"] } } }

ツールリファレンス

ディレクトリ操作

リストディレクトリ

メタデータとともにディレクトリの内容を一覧表示します。

interface ListDirectoryParams { path: string; // Directory path recursive?: boolean; // List recursively (default: false) } interface ListDirectoryResult { entries: { name: string; path: string; isDirectory: boolean; size: number; created: string; modified: string; accessed: string; mode: string; }[]; }

ディレクトリの作成

新しいディレクトリを作成します。

interface CreateDirectoryParams { path: string; // Directory path recursive?: boolean; // Create parent directories (default: true) }

ファイル操作

読み取りファイル

エンコード サポートを使用してファイルの内容を読み取ります。

interface ReadFileParams { path: string; // File path encoding?: string; // File encoding (default: 'utf8') }

書き込みファイル

コンテンツをファイルに書き込みます。

interface WriteFileParams { path: string; // File path content: string; // Content to write encoding?: string; // File encoding (default: 'utf8') }

ファイル追加

ファイルにコンテンツを追加します。

interface AppendFileParams { path: string; // File path content: string; // Content to append encoding?: string; // File encoding (default: 'utf8') }

分析操作

テキスト分析

テキスト ファイルのプロパティを分析します。

interface AnalyzeTextParams { path: string; // File path } interface AnalyzeTextResult { lineCount: number; wordCount: number; charCount: number; encoding: string; mimeType: string; }

ハッシュを計算する

指定されたアルゴリズムを使用してファイル ハッシュを計算します。

interface CalculateHashParams { path: string; // File path algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'; // Hash algorithm } interface CalculateHashResult { hash: string; algorithm: string; }

重複を見つける

ディレクトリ内の重複ファイルを識別します。

interface FindDuplicatesParams { path: string; // Directory path } interface FindDuplicatesResult { duplicates: { hash: string; size: number; files: string[]; }[]; }

圧縮操作

作成_zip

ZIP アーカイブを作成します。

interface CreateZipParams { files: string[]; // Files to include output: string; // Output ZIP path }

抽出_zip

ZIP アーカイブを抽出します。

interface ExtractZipParams { path: string; // ZIP file path output: string; // Output directory }

エラー処理

サーバーは標準の MCP エラー コードを使用します。

enum ErrorCode { ParseError = -32700, InvalidRequest = -32600, MethodNotFound = -32601, InvalidParams = -32602, InternalError = -32603 }

エラー応答には次のものがあります:

  • エラーコード
  • 人間が読めるメッセージ
  • 利用可能な場合の追加コンテキスト

エラー例:

{ "code": -32602, "message": "File not found: /path/to/file.txt" }

発達

プロジェクト構造

src/ ├── operations/ # Core operations implementation ├── tools/ # MCP tool definitions and handlers ├── __tests__/ # Test suites ├── index.ts # Entry point ├── server.ts # MCP server setup ├── types.ts # Type definitions └── utils.ts # Utility functions

テストの実行

テスト スイートを実行します。

npm test

カバレッジ付きで実行:

npm run test:coverage

開発モード

ウォッチモードで実行:

npm run watch

コード品質

コードベースをリントする:

npm run lint

型チェック:

npm run type-check

依存関係

コア依存関係:

  • @modelcontextprotocol/sdk: MCP サーバーの実装
  • ファイルタイプ: ファイルタイプの検出
  • mime-types: MIMEタイプの検索
  • crypto-js: ファイルハッシュ
  • アーカイバ:ZIP作成
  • extract-zip: ZIP抽出
  • iconv-lite: テキストエンコーディング
  • chardet: エンコーディング検出

開発依存関係:

  • Typescript: 型システム
  • jest: テスト
  • eslint: リンティング
  • prettier: フォーマット
  • ts-node: TypeScriptの実行
  • nodemon: 開発サーバー

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成する
  3. 新機能のテストを書く
  4. すべてのテストに合格することを確認する
  5. プルリクエストを送信する

ライセンス

マサチューセッツ工科大学

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

標準化されたツール インターフェイスを通じてファイル システムの操作、分析、および操作機能を提供するモデル コンテキスト プロトコル サーバー。

  1. Architecture
    1. Components
  2. Installation
    1. Tool Reference
      1. Directory Operations
      2. File Operations
      3. Analysis Operations
      4. Compression Operations
    2. Error Handling
      1. Development
        1. Project Structure
        2. Running Tests
        3. Development Mode
        4. Code Quality
      2. Dependencies
        1. Contributing
          1. License
            ID: hfidyfcfcx