MCP File Reader
MCPファイルリーダー
MCP (Model Context Protocol) を使用して、PythonツールサーバーとローカルLLM (Ollama + Mistral) を接続する、完全にローカルで無料のAIファイルリーダーです。APIキー不要、クラウド不要、コストゼロで、すべてお使いのPC上で動作します。
🧾 機能
カスタムツール (
list_files,read_file) を備えたMCPサーバーOllama経由のローカルLLM統合 (Mistral / Llama3.2)
自動ファイル探索とコンテンツ読み取り
AIによるファイル内容の要約
パストラバーサル保護 (セキュリティ内蔵)
コストゼロ — APIキーやサブスクリプションは不要
Related MCP server: mcp-ollama-python
🛠️ 技術スタック
技術 | 説明 |
Python | サーバーおよびクライアントのコア言語 |
MCP | Model Context Protocol (ツールサーバー) |
Ollama | ローカルLLMランタイム (無料、オフライン) |
Mistral | 要約用ローカルAIモデル |
asyncio | クライアント/サーバー間の非同期通信 |
requests | Ollama APIへのHTTP呼び出し |
📦 インストール
git clone https://github.com/JaneKarunyaJ/MCP-File-Reader.git
cd MCP-File-Reader
pip install mcp requestshttps://ollama.com からOllamaをインストールし、モデルをプルします:
ollama pull mistral🚀 使用方法
Ollamaが実行されていることを確認し(インストール後に自動起動します)、以下を実行します:
python client.pyクライアントは以下の動作を行います:
MCPサーバーをサブプロセスとして起動
list_filesを呼び出してmy_files/内のファイルを探索見つかった各ファイルに対して
read_fileを呼び出し実際のコンテンツをMistralに送信して要約
📁 プロジェクト構造
MCP-File-Reader/
│
├── server.py # MCP server — exposes list_files and read_file tools
├── client.py # MCP client — calls tools and queries Ollama
├── requirements.txt # Python dependencies
└── my_files/ # Folder the AI is allowed to read
├── project_ideas.txt
└── wishlist.txt🔐 セキュリティ
MCPサーバーは
my_files/ディレクトリからの読み取りのみを許可しますパストラバーサル攻撃 (例:
../../etc/passwd) は自動的にブロックされますデータはPC外へ送信されません — セットアップ後は完全にオフラインです
🧠 仕組み
client.py
│
├── Step 1: Calls MCP tool → list_files()
│ ↓
│ Returns filenames from my_files/
│
├── Step 2: Calls MCP tool → read_file(filename)
│ ↓
│ Returns actual file contents
│
└── Step 3: Sends real content to Ollama (Mistral)
↓
Returns AI summary➕ プロジェクトの拡張
独自のファイルを追加:
.txtファイルをmy_files/に入れて再度実行してください新しいツールを追加:
server.pyに新しいツールハンドラーを追加してください (例:search_in_file,write_file)質問を変更:
client.pyのuser_questionを編集して、ファイルについて何でも質問できますモデルを入れ替え:
client.pyのMODEL = "mistral"を、Ollamaでプル済みの任意のモデルに変更してください
📋 要件
Python 3.9以上
Ollamaのインストール (ollama.com)
Mistralモデルのプル (
ollama pull mistral)mcpおよびrequestsPythonパッケージ
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
An MCP server that gives your AI access to the source code and docs of all public github repos
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA beginner MCP server that enables Claude to read local text, CSV, and Markdown files. Built as a learning project to understand how to connect AI to local file systems using the MCP protocol.-
- AlicenseNot gradedqualityAmaintenanceA Python MCP server that exposes local Ollama models as tools for AI assistants, enabling chat, generation, embeddings, and model management without cloud APIs.62 PyPI5MIT
- FlicenseNot gradedqualityCmaintenanceA local, read-only MCP server that analyzes Python backend projects by providing tools to scan, map, and selectively read files, reducing token usage for AI clients.-
- FlicenseNot gradedqualityBmaintenanceMCP server that enables AI to read, search, and edit local files securely without external data exposure, using local LLMs via Ollama and integrating with Open WebUI or Claude Desktop.-