Skip to main content
Glama
jibixn

MCP File System Agent

by jibixn

{"type": "text"}# MCP File System Agent

Ein lokaler agentischer Dateisystem-Assistent, erstellt mit LangChain, Ollama, FastMCP und MCP.

Das Projekt zeigt, wie ein LLM autonom Werkzeuge auswählen und nutzen kann, die von einem MCP-Server bereitgestellt werden, um dateibezogene Vorgänge wie Lesen, Auflisten, Schreiben und Durchsuchen von Dateien auszuführen.

Architektur

                         User
                           │
                           ▼
                  ┌─────────────────┐
                  │  LangChain      │
                  │     Agent       │
                  └────────┬────────┘
                           │
                           ▼
                  ┌─────────────────┐
                  │   Ollama LLM    │
                  │   Qwen3 1.7B    │
                  └────────┬────────┘
                           │
                    Tool selection
                           │
                           ▼
                ┌──────────────────────┐
                │ LangChain MCP Adapter│
                └──────────┬───────────┘
                           │
                       MCP / HTTP
                           │
                           ▼
                ┌──────────────────────┐
                │     FastMCP Server   │
                │   localhost:8000/mcp │
                └──────────┬───────────┘
                           │
             ┌─────────────┼─────────────┐
             ▼             ▼             ▼
        read_file     list_files    write_file
             │
             ▼
       Local File System

Related MCP server: OmniMCP-Container

Funktionen

  • MCP-basierte Werkzeugarchitektur

  • Lokaler FastMCP-Server mit HTTP-Transport

  • LangChain-Agent mit Werkzeugaufrufen

  • Lokale LLM-Inferenz über Ollama

  • Lesen von PDF-Dateien

  • Lesen und Schreiben von DOCX-Dateien

  • Dateiauflistung mit Erweiterungsfilterung

  • Durchsuchen von PDF- und DOCX-Dateien

  • Gesprächszustand mithilfe von LangGraph-Checkpointing

  • Automatische Werkzeugauswahl durch das LLM

Technologie-Stack

  • Python

  • LangChain

  • LangGraph

  • Ollama

  • Qwen3 1.7B

  • FastMCP

  • Model Context Protocol (MCP)

  • langchain-mcp-adapters

  • PyPDF

  • python-docx

Projektstruktur

MCP/
│
├── tests/
│   └── sample.docx
│
├── fs_mcp.py
├── main.py
├── requirements.txt
└── README.md

Installation

1. Repository klonen

git clone https://github.com/jibixn/File-System-Tools-MCP
cd MCP

2. Python-Abhängigkeiten installieren

pip install -r requirements.txt

3. Ollama installieren

Installieren Sie Ollama von der offiziellen Website und stellen Sie sicher, dass es lokal ausgeführt wird.

Ziehen Sie dann das Modell:

ollama pull qwen3:1.7b

Sie können überprüfen, ob das Modell verfügbar ist mit:

ollama list

Projekt ausführen

Das Projekt verwendet zwei Prozesse, da der MCP-Server über HTTP mit dem Client kommuniziert.

Terminal 1 – MCP-Server starten

Führen Sie diesen Befehl im Projektstammverzeichnis aus:

python fs_mcp.py

Der Server sollte verfügbar sein unter:

http://127.0.0.1:8000/mcp

Terminal 2 – Agenten starten

Öffnen Sie ein weiteres Terminal im Projektstammverzeichnis:

python main.py

Sie können dann Anfragen wie die folgenden eingeben:

Read the file in tests folder named sample.docx and provide me the summary.

oder:

List all PDF files in the tests folder.

oder:

Write "Hello, World!" to tests/output.docx.

Beispielhafter Agentenablauf

Für eine Anfrage wie:

Read the file in tests folder named sample.docx and provide me the summary.

führt der Agent Folgendes aus:

User request
     │
     ▼
LLM analyzes request
     │
     ▼
LLM selects read_file
     │
     ▼
LangChain MCP Adapter
     │
     ▼
MCP HTTP request
     │
     ▼
FastMCP read_file()
     │
     ▼
python-docx reads file
     │
     ▼
Tool result returned to agent
     │
     ▼
LLM summarizes content
     │
     ▼
Final response

Anforderungen

Python 3.11+ wird empfohlen.

Ollama muss installiert sein und lokal ausgeführt werden.

Das Qwen-Modell muss verfügbar sein:

ollama pull qwen3:1.7b

Sie können auch ein Modell über einen Inferenzanbieter verwenden.

Abhängigkeiten

Die direkten Abhängigkeiten des Projekts sind:

fastmcp==3.4.7
langchain==1.3.14
langchain-mcp-adapters==0.3.2
langchain-ollama==1.1.0
langgraph-checkpoint==4.2.0
pypdf==6.14.2
python-docx==1.2.0

Zukünftige Verbesserungen

  • Unterstützung für weitere Dateiformate hinzufügen

  • Werkzeuge zum Löschen von Dateien und Erstellen von Verzeichnissen hinzufügen

  • Stärkere Pfadvalidierung und Sandboxing hinzufügen

  • Authentifizierung für entfernte MCP-Server hinzufügen

  • Streaming-Antworten hinzufügen

  • Umfangreicheres Dokument-Parsing hinzufügen

  • Dauerhafte Speicherung von Gesprächen hinzufügen

  • Zusätzliche MCP-Server für Datenbanken, GitHub oder Websuche hinzufügen

  • Zuverlässigkeit der Werkzeugauswahl mit größeren lokalen Modellen verbessern

Lernziele

Dieses Projekt demonstriert die Interaktion zwischen:

LLM
 ↓
LangChain Agent
 ↓
Tool Calling
 ↓
MCP Client
 ↓
MCP Protocol
 ↓
FastMCP Server
 ↓
Python Functions

Es ist als praktisches Beispiel für die Entwicklung einer agentischen Anwendung mit Model Context Protocol (MCP) und lokal gehosteten LLMs gedacht.

Related MCP Connectors

  • Persistent file storage for AI agents via MCP and curl. Upload, download, and version files.

  • A real-time, multiplayer filesystem for agents and humans: shared files, live edits, history.

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

  • Fastio gives your team and AI agents a workspace for each project, bringing source files, comments and new work together. Connect a compatible MCP client to find files, answer questions from project material, and save results where the team can review and use them. \ Sign in through Fastio and choose the workspaces the connection can reach. Read Only connections expose read tools; Read & Write connections also allow changes. \ • **Files and folders:** browse, read, upload, and organize files, with version history and trash. • **Search:** find files by keyword; search file content and meaning when Deep Indexing is enabled and files have been processed. • **Metadata:** read, set, and search metadata fields, including extracted fields where available. • **Shares:** create and manage shares for sending or collecting files. • **Comments and members:** read and add comments, and manage workspace membership within your permissions. • **Activity:** search workspace events to see what changed. \ Hosted by Fastio, with no server installation required. \ • **Claude and most MCP clients:** https://mcp.fast.io/mcp/tools • **ChatGPT:** https://mcp.fast.io/mcp/operations • **ChatGPT and Codex:** Fastio plugin • **Claude Code, Cursor and similar coding agents:** https://mcp.fast.io/mcp/code • **Setup and client-specific capabilities:** https://mcp.fast.io/docs \ Paid plans. Monthly plans include a trial of up to 30 days. A card is required, and billing begins when the trial ends or trial credits run out, whichever comes first. No free plan.

Related MCP Servers