Skip to main content
Glama
niaproject

local-file-reader

by niaproject

local-file-reader

ローカルファイルを安全に読み取り、検索できるMCPサーバーです。

機能

  • list_files: ベースディレクトリ配下のファイル/フォルダ一覧を取得

  • read_file: テキストファイルの内容を読み取る

  • search_text: キーワードでテキストを検索

Related MCP server: MCP File Browser Server

セットアップ

1. 依存関係をインストール

pip install -r requirements.txt

2. ベースディレクトリを準備

デフォルトでは D:\MCP_Server をベースディレクトリとして使用します。必要に応じて、このディレクトリを作成し、読み取りたいファイルを配置してください。

mkdir D:\MCP_Server

3. サーバーを起動

python file_reader_mcp.py

使用例

Claude に以下のようにリクエストできます:

list_files で D:\MCP_Server のファイル一覧を表示してください
read_file で sample.txt の内容を読み取ってください
search_text で "error" キーワードを検索してください

設定

file_reader_mcp.py の以下の場所でベースディレクトリを変更できます:

BASE_DIR = Path(r"D:\MCP_Server").resolve()

許可されるファイル拡張子

  • .txt

  • .md

  • .log

  • .json

  • .yaml, .yml

  • .ini

  • .csv

新しい拡張子を追加する場合は、ALLOWED_EXTENSIONS を編集してください:

ALLOWED_EXTENSIONS = {
    ".txt", ".md", ".log", ".json", ".yaml", ".yml", ".ini", ".csv", ".yourext"
}

セキュリティ機能

  • BASE_DIR外へのアクセス禁止

  • ファイルサイズ上限:1MB(MAX_FILE_SIZE で変更可能)

  • 許可された拡張子のみ読み取り可能

  • 検索結果は最大100件まで

ツール仕様

list_files

list_files(relative_dir: str = "", pattern: str = "*") -> list[str]

パラメータ:

  • relative_dir: ベースディレクトリからの相対パス(デフォルト: ルート)

  • pattern: ファイル名パターン(fnmatchで評価)

例:

list_files("docs", "*.md")  # docs フォルダの .md ファイル一覧

read_file

read_file(relative_path: str) -> str

パラメータ:

  • relative_path: ベースディレクトリからの相対パス

例:

read_file("config.json")  # ルートの config.json を読み取る
read_file("docs/readme.md")  # docs/readme.md を読み取る

search_text

search_text(keyword: str, relative_dir: str = "") -> list[dict]

パラメータ:

  • keyword: 検索キーワード

  • relative_dir: 検索対象ディレクトリ(デフォルト: ルート全体)

戻り値:

[
  {
    "path": "folder/file.txt",
    "line": 42,
    "text": "マッチした行の内容(最初の300文字)"
  }
]

例:

search_text("error", "logs")  # logs フォルダで "error" を検索

トラブルシューティング

BaseDir が見つからない

BASE_DIR に指定したディレクトリが存在することを確認してください。

ファイルが読み取り不可

  • ファイルの拡張子が ALLOWED_EXTENSIONS に含まれているか確認してください

  • ファイルサイズが 1MB を超えていないか確認してください

  • ファイルが UTF-8 でエンコードされていることを確認してください(そうでない場合は自動的に置換エラーで処理されます)

ACCESS_DENIED エラー

relative_path が BASE_DIR 外のファイルを指していないか確認してください。

Claude Code で local-file-reader が認識されない

  1. .mcp.json がプロジェクトルートまたは ~/.claude/ に配置されているか確認

  2. .mcp.json の JSON 構文が正しいか確認(オンラインJSONバリデータで検証)

  3. args のパスが正しく設定されているか確認:

    "args": ["d:/VSCode/mcpserver-sample/file_reader_mcp.py"]
  4. Claude Code(VSCode拡張)を再起動、またはウィンドウをリロード(Ctrl+Shift+P → "Reload Window")

  5. CLI の場合は claude mcp list で登録状況を確認

local-file-reader に接続テスト

サーバーが正しく起動しているか確認:

# テストスクリプトを実行
python test_server.py

よくある問題

Claude Code で local-file-reader が認識されない

  • .mcp.jsonargs のパスが正しいか確認してください

  • command に指定した python が PATH に通っているか確認してください

Claude から接続できない

  • .mcp.json の JSON 構文が正しいか確認してください

  • Claude Code(VSCode拡張)を再起動、またはウィンドウをリロードしてください

F
license - not found
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    Enables secure filesystem operations with directory sandboxing and optional read-only mode. Supports file reading/writing, directory management, file searching, and text operations while restricting access to specified directories.
    Last updated
    12
  • F
    license
    -
    quality
    D
    maintenance
    Enables Large Language Models to safely browse and interact with local file systems through secure directory listing, file reading, and content search capabilities. Built with comprehensive security controls and high-performance handling of large directories and files.
    Last updated
  • F
    license
    -
    quality
    D
    maintenance
    Provides sandboxed access to local filesystem operations including directory and file management, content search with glob and regex patterns, and binary file support with configurable safety limits.
    Last updated
  • F
    license
    -
    quality
    D
    maintenance
    Enables LLMs to securely read, search, and analyze local file systems through the Model Context Protocol. Provides tools for listing files, pattern-based searching, and reading file contents with built-in security validation.
    Last updated
    6

View all related MCP servers

Related MCP Connectors

  • Search, browse, and read your Dropbox files. Find documents by name or content, list folders, and…

  • Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.

  • File uploads for AI agents. Upload, list, and manage files. No signup required.

View all MCP Connectors

Latest Blog Posts

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/niaproject/mcpserver-sample'

If you have feedback or need assistance with the MCP directory API, please join our Discord server