Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
Your own AI agent, running 24/7 with QwikClaw logoYour own AI agent, running 24/7 with QwikClaw

QwikClaw sets up and runs an always-on OpenClaw agent for you. One click, no config files, no server setup.

Deploy now
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 47,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

A professional MCP server that provides filesystem operations while automatically respecting .gitignore patterns, enabling efficient and token-friendly file access for Claude.

README.md

🗂️ MCP Filesystem Server

![Python 3.10+](https://www.python.org/downloads/) ![License: MIT](https://opensource.org/licenses/MIT) ![Code style: black](https://github.com/psf/black)

Un servidor MCP (Model Context Protocol) profesional que proporciona operaciones de sistema de archivos mientras respeta automáticamente los patrones de .gitignore.

🎯 ¿Qué problema resuelve?

Cuando Claude trabaja con proyectos que tienen venv/, node_modules/, o .git/, intentar leer todo el directorio puede:

  • ⚠️ Agotar el límite de tokens leyendo 50k+ archivos innecesarios
  • ⏱️ Ser extremadamente lento al procesar directorios gigantes
  • 🤯 Ser confuso mezclando código fuente con dependencias

Este servidor resuelve eso respetando .gitignore automáticamente, igual que Git. Claude solo ve lo que realmente importa: tu código.

✨ Características

  • Respeta .gitignore automáticamente: Excluye venv/, node_modules/, __pycache__/, etc.
  • Optimizado para tokens: Solo lee archivos relevantes de tu proyecto
  • Operaciones completas: Leer, escribir, listar, buscar, y crear archivos/directorios
  • Seguridad por diseño: Solo accede a directorios explícitamente permitidos
  • Caracteres especiales: Maneja espacios, #, @, y otros caracteres en nombres
  • Cache inteligente: Cachea patrones .gitignore con invalidación automática
  • Type-safe: Completamente tipado con dataclasses y type hints
  • Production-ready: Tests, logging, manejo de errores robusto

🏗️ Arquitectura

┌─────────────────────────────────────────────────────────────┐
│                    MCP Protocol Layer                       │
│  (server.py - Adaptador que traduce MCP ↔ FileSystemService)│
└────────────────────┬────────────────────────────────────────┘
                     │
┌───────────────────▼────────────────────────────────────────┐
│             Business Logic Layer                           │
│(filesystem_service.py - Orquesta validación + operaciones) │
└──────┬──────────────────────────────┬──────────────────────┘
       │                              │
       ▼                              ▼
┌──────────────────┐         ┌──────────────────────┐
│ Path Validation  │         │  .gitignore Manager  │
│ (path_validator) │         │  (ignore_manager)    │
│                  │         │                      │
│ - URL decoding   │         │ - Pattern matching   │
│ - Security check │         │ - Intelligent cache  │
└──────────────────┘         └──────────────────────┘
       │                              │
       └──────────────┬───────────────┘
                      │
       ┌──────────────▼──────────────────┐
       │    Data Access Layer            │
       │  (filesystem_operations.py)     │
       │                                 │
       │  - Pure I/O operations          │
       │  - No business logic            │
       └─────────────────────────────────┘

Responsabilidades por capa:

  1. MCP Protocol Layer (server.py):
  • Traduce requests MCP a llamadas del service
  • Serializa responses a JSON
  • Maneja el protocolo stdio
  1. Business Logic Layer (filesystem_service.py):
  • Orquesta validación + filtering + operaciones
  • Punto de entrada público del sistema
  • Combina múltiples componentes para cada operación
  1. Support Components:
  • path_validator: Normaliza y valida paths (seguridad)
  • ignore_manager: Cache y matching de .gitignore
  • filesystem_operations: I/O puro, sin lógica de negocio
  1. Foundation:
  • config.py: Configuración centralizada
  • errors.py: Excepciones tipadas
  • models.py: Dataclasses para type safety

Beneficios de esta arquitectura:

  • ✅ Cada capa es testeable independientemente
  • ✅ Fácil cambiar implementación de una capa sin afectar otras
  • ✅ Separación clara de responsabilidades
  • ✅ Código reutilizable (el service puede usarse fuera de MCP)

📋 Requisitos

  • Python 3.10+
  • Compatible con clientes MCP como Claude Desktop, Zed, Sourcegraph Cody y otros que implementen el estándar Model Context Protocol.

🚀 Instalación Rápida

# 1. Clonar y navegar al proyecto
cd "C:\DesarrolloPython\MCP FileSystem"

# 2. Instalar dependencias de desarrollo
make.bat install-dev

# 3. Ejecutar tests para verificar
make.bat test

Configurar Claude Desktop

Edita el archivo de configuración:

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "filesystem-gitignore": {
      "command": "python",
      "args": [
        "-m",
        "mcp_filesystem"
      ],
      "env": {
        "ALLOWED_DIRECTORIES": "C:\\DesarrolloPython;C:\\MisProyectos"
      }
    }
  }
}

Notas:

  • Usa paths absolutos
  • Windows: separa directorios con ;
  • Unix/Mac: separa directorios con :

Reinicia Claude Desktop para aplicar cambios.

🔧 Uso

Herramientas Disponibles

1. read_file - Leer archivo de texto

read_file(path="C:\\DesarrolloPython\\proyecto\\src\\main.py")

2. write_file - Escribir archivo

write_file(
    path="C:\\DesarrolloPython\\nuevo_archivo.py",
    content="print('Hello, World!')"
)

3. list_directory - Listar contenido (no recursivo)

# Por defecto respeta .gitignore
list_directory(path="C:\\DesarrolloPython\\proyecto")

# Forzar mostrar TODO (incluso venv)
list_directory(path="C:\\DesarrolloPython\\proyecto", respect_gitignore=False)

4. directory_tree - Árbol recursivo

directory_tree(
    path="C:\\DesarrolloPython\\proyecto",
    max_depth=5,
    respect_gitignore=True  # Default
)

5. search_files - Buscar archivos

search_files(
    path="C:\\DesarrolloPython",
    pattern="config",  # Case-insensitive
    respect_gitignore=True
)

6. get_file_info - Información detallada

get_file_info(path="C:\\DesarrolloPython\\proyecto\\README.md")

7. create_directory - Crear directorio

create_directory(path="C:\\DesarrolloPython\\nuevo_proyecto\\src")

📝 Decisiones de Diseño

¿Cómo se maneja .gitignore?

  1. Parseo con pathspec: Usamos la librería pathspec que implementa el mismo algoritmo que Git
  2. Cache inteligente:
  • Cada .gitignore se parsea una sola vez y se cachea
  • El cache se invalida automáticamente cuando el .gitignore cambia (detecta por mtime)
  • Cache por directorio (cada dir tiene su propio .gitignore)
  1. Matching preciso:
  • Convierte paths a formato POSIX (forward slashes)
  • Agrega / al final de directorios (convención de Git)
  • Usa gitwildmatch para matching exacto

¿Cómo se optimiza el consumo de tokens?

  1. Filtrado temprano: Los archivos ignorados ni siquiera se listan
  2. Control de profundidad: directory_tree limita profundidad máxima (default: 5)
  3. Sin lectura de contenido: Solo lista nombres, no lee contenidos
  4. Respeto opcional: Todas las herramientas tienen respect_gitignore flag (default: True)

Comparación:

# ❌ Sin .gitignore (50k+ archivos en venv):
directory_tree("C:\\proyecto")  # 🔥 Consume 100k+ tokens

# ✅ Con .gitignore (solo archivos de proyecto):
directory_tree("C:\\proyecto")  # ✅ ~2k tokens

Seguridad: ¿Por qué directorios permitidos?

  • Previene acceso a archivos sensibles del sistema
  • Claude solo puede trabajar en tus proyectos
  • Validación en cada operación (no se puede "escapar" con ../../../)

🧪 Testing

# Ejecutar todos los tests
make.bat test

# Solo tests unitarios
make.bat test-unit

# Solo tests de integración
make.bat test-integration

# Con reporte de coverage
make.bat test-cov

🛠️ Desarrollo

# Formatear código
make.bat format

# Linters
make.bat lint

# Limpiar archivos generados
make.bat clean

🐛 Troubleshooting

"ALLOWED_DIRECTORIES environment variable must be set"

Solución: Configura la variable de entorno en Claude Desktop config.

"Access denied"

Causa: El path no está en ALLOWED_DIRECTORIES

Solución: Agrega el directorio a la lista.

No respeta .gitignore

Verifica:

  1. ¿Existe .gitignore en el directorio?
  2. ¿Los patrones están bien escritos?
  3. ¿Estás usando respect_gitignore=True? (es el default)

Consume muchos tokens

Solución:

  1. Crea/mejora tu .gitignore
  2. Reduce max_depth en directory_tree
# .gitignore recomendado para Python:
venv/
env/
__pycache__/
*.pyc
.git/
.pytest_cache/
.mypy_cache/
htmlcov/

📚 Referencias

🤝 Contribuciones

¡Las contribuciones son bienvenidas!

Antes de hacer PR:

  • ✅ Ejecuta make.bat test (todos los tests deben pasar)
  • ✅ Ejecuta make.bat lint (sin warnings)
  • ✅ Ejecuta make.bat format (código formateado)
  • ✅ Agrega tests para nueva funcionalidad

📄 Licencia

MIT License - Úsalo libremente.

---

Desarrollado con ❤️ para optimizar la interacción de Claude con proyectos reales

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Files & Docs servers.