Skip to main content
Glama
jibixn

MCP File System Agent

by jibixn

MCP File System Agent

Локальный агентный файловый ассистент, созданный с использованием LangChain, Ollama, FastMCP и MCP.

Проект демонстрирует, как LLM может автономно выбирать и использовать инструменты, предоставляемые MCP-сервером, для выполнения файловых операций, таких как чтение, просмотр списка, запись и поиск файлов.

Архитектура

                         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

Возможности

  • Архитектура инструментов на основе MCP

  • Локальный FastMCP-сервер с HTTP-транспортом

  • Агент LangChain с вызовом инструментов

  • Локальный вывод LLM через Ollama

  • Чтение PDF-файлов

  • Чтение и запись DOCX-файлов

  • Просмотр списка файлов с фильтрацией по расширению

  • Поиск внутри PDF- и DOCX-файлов

  • Состояние диалога с использованием контрольных точек LangGraph

  • Автоматический выбор инструментов LLM

Технологический стек

  • Python

  • LangChain

  • LangGraph

  • Ollama

  • Qwen3 1.7B

  • FastMCP

  • Model Context Protocol (MCP)

  • langchain-mcp-adapters

  • PyPDF

  • python-docx

Структура проекта

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

Установка

1. Клонируйте репозиторий

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

2. Установите зависимости Python

pip install -r requirements.txt

3. Установите Ollama

Установите Ollama с официального сайта и убедитесь, что он запущен локально.

Затем загрузите модель:

ollama pull qwen3:1.7b

Вы можете проверить, что модель доступна, с помощью:

ollama list

Запуск проекта

Проект использует два процесса, поскольку MCP-сервер взаимодействует с клиентом по HTTP.

Терминал 1 — Запустите MCP-сервер

Выполните эту команду из корня проекта:

python fs_mcp.py

Сервер должен быть доступен по адресу:

http://127.0.0.1:8000/mcp

Терминал 2 — Запустите агента

Откройте другой терминал в корне проекта:

python main.py

Затем вы можете вводить запросы, например:

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

или:

List all PDF files in the tests folder.

или:

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

Пример потока работы агента

Для такого запроса, как:

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

агент выполняет следующее:

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

Требования

Рекомендуется Python 3.11+.

Ollama должен быть установлен и запущен локально.

Модель Qwen должна быть доступна:

ollama pull qwen3:1.7b

Вы также можете использовать модель через провайдера вывода.

Зависимости

Прямые зависимости проекта:

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

Будущие улучшения

  • Добавить поддержку дополнительных форматов файлов

  • Добавить инструменты удаления файлов и создания каталогов

  • Добавить более строгую проверку путей и песочницу

  • Добавить аутентификацию для удаленных MCP-серверов

  • Добавить потоковые ответы

  • Добавить более полный разбор документов

  • Добавить постоянное хранение диалогов

  • Добавить дополнительные MCP-серверы для баз данных, GitHub или веб-поиска

  • Повысить надежность выбора инструментов с помощью более крупных локальных моделей

Учебные цели

Этот проект демонстрирует взаимодействие между:

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

Он задуман как практический пример создания агентного приложения с Model Context Protocol (MCP) и локально размещенными LLM.

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