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キーやサブスクリプションは不要
🛠️ 技術スタック
技術 | 説明 |
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 installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/JaneKarunyaJ/MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server