Skip to main content
Glama

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 requests

https://ollama.com からOllamaをインストールし、モデルをプルします:

ollama pull mistral

🚀 使用方法

Ollamaが実行されていることを確認し(インストール後に自動起動します)、以下を実行します:

python client.py

クライアントは以下の動作を行います:

  1. MCPサーバーをサブプロセスとして起動

  2. list_files を呼び出して my_files/ 内のファイルを探索

  3. 見つかった各ファイルに対して read_file を呼び出し

  4. 実際のコンテンツを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.pyuser_question を編集して、ファイルについて何でも質問できます

  • モデルを入れ替え: client.pyMODEL = "mistral" を、Ollamaでプル済みの任意のモデルに変更してください

📋 要件

  • Python 3.9以上

  • Ollamaのインストール (ollama.com)

  • Mistralモデルのプル (ollama pull mistral)

  • mcp および requests Pythonパッケージ

-
security - not tested
F
license - not found
-
quality - not tested

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