MCP Filesystem Assistant

MCP Filesystem Assistant

An AI-powered file manager that enables natural language filesystem operations including reading, writing, organizing, and managing files within a secure sandboxed workspace through a web interface.

Category
Visit Server

README

šŸ—‚ļø MCP Filesystem Assistant

A beautiful AI-powered file manager built with Model Context Protocol (MCP), featuring a modern web interface, OpenAI integration, and secure filesystem operations.

Status Python License


šŸŽÆ What is This?

An AI assistant that can read, write, and manage your files through natural language. Built on the Model Context Protocol (MCP), it demonstrates how to:

  • šŸ¤– Connect AI models to real tools
  • šŸ”’ Safely manage files in a sandboxed environment
  • šŸŽØ Build beautiful interfaces with Streamlit
  • šŸ› ļø Create production-ready MCP servers

Perfect for learning MCP or building your own AI-powered tools!


✨ Features

šŸ’¬ Natural Language Interface

Ask the AI to manage files in plain English:

  • "List all files in the workspace"
  • "Read notes.txt and summarize it"
  • "Create a backup folder and organize my files"
  • "Show me details about data.json"

šŸŽØ Beautiful Web Interface

  • Chat Tab - Talk to the AI assistant
  • File Browser - Visual workspace explorer
  • Quick Actions - Direct file operations without AI

šŸ› ļø 8 Powerful Tools

Tool What it does
read_file Read file contents
write_file Create or overwrite files
append_file Add to existing files
delete_file Remove files safely
list_directory Browse folders
create_directory Make new folders
move_file Rename or relocate files
get_file_info Show file details

šŸ”’ Security First

  • All operations sandboxed to workspace/ folder
  • Path traversal protection
  • Input validation on every operation

šŸ“ Project Structure

filesystem-mcp-project/
ā”œā”€ā”€ host/                      # Streamlit web app
│   ā”œā”€ā”€ app.py                 # Main interface
│   ā”œā”€ā”€ mcp_connector.py       # Connects to MCP server
│   └── ui_components.py       # UI styling
│
ā”œā”€ā”€ server/                    # MCP server
│   ā”œā”€ā”€ filesystem_mcp_server.py  # 8 filesystem tools
│   └── config.py              # Settings
│
ā”œā”€ā”€ workspace/                 # Your files live here
│   ā”œā”€ā”€ notes.txt             
│   └── data.json             
│
ā”œā”€ā”€ requirements.txt           # Python packages
ā”œā”€ā”€ .env.example              # Config template
└── README.md                 # You are here!

šŸš€ Quick Start

1. Install

# Clone or download the project
cd filesystem-mcp-project

# Create virtual environment
python -m venv venv

# Activate it
source venv/bin/activate  # Mac/Linux
# OR
venv\Scripts\activate     # Windows

# Install dependencies
pip install -r requirements.txt

2. Configure

Create a .env file:

OPENAI_API_KEY=sk-your-key-here

Get your OpenAI API key from: https://platform.openai.com/api-keys

3. Run

Terminal 1 - Start MCP Server:

python server/filesystem_mcp_server.py

You should see:

šŸš€ MCP Server starting...
šŸ“ Workspace directory: /path/to/workspace
🌐 Server running on http://127.0.0.1:8000
āœ… Available tools: 8

Terminal 2 - Launch Web Interface:

streamlit run host/app.py

Browser opens at http://localhost:8501 šŸŽ‰


šŸ’” Usage Examples

Example 1: List Files

You: "What files are in the workspace?"

AI: Uses list_directory tool

šŸ“ Directory: .

  šŸ“„ notes.txt (1.2 KB)
  šŸ“„ data.json (856 bytes)

Example 2: Create File

You: "Create a file called hello.txt with 'Hello World!'"

AI: Uses write_file tool

āœ… File written successfully: hello.txt (12 characters)

Example 3: Organize Files

You: "Create a backup folder and move old files into it"

AI: Uses create_directory and move_file tools

āœ… Directory created: backup
āœ… File moved: old_data.txt → backup/old_data.txt

šŸ—ļø How It Works

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   You (User)    │
│  Ask questions  │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
         │
         ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  Streamlit App  │
│  localhost:8501 │  ← Beautiful web interface
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
         │
         ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   OpenAI API    │
│     GPT-4       │  ← AI decides which tools to use
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
         │
         ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   MCP Server    │
│  localhost:8000 │  ← Executes file operations
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
         │
         ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   workspace/    │
│   Your Files    │  ← Safe sandbox folder
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

šŸ”§ Configuration

Basic Settings (.env)

# Required
OPENAI_API_KEY=sk-your-key-here

# Optional (defaults shown)
MCP_SERVER_HOST=127.0.0.1
MCP_SERVER_PORT=8000

Advanced Settings (server/config.py)

# Change workspace location
WORKSPACE_DIR = Path("my_custom_folder")

# Change server port
MCP_SERVER_PORT = 9000

šŸ› Troubleshooting

"Server Not Connected"

  1. Check if MCP server is running (Terminal 1)
  2. Click "Check Connection" button in sidebar
  3. Restart both server and Streamlit

"OpenAI API Key Error"

  1. Make sure .env file exists
  2. Check your API key is correct
  3. Restart Streamlit after updating .env

"Port Already in Use"

# Kill process on port 8000
lsof -i :8000
kill -9 <PID>

# Or change port in .env
MCP_SERVER_PORT=8001

"File Not Found"

Remember: All paths are relative to workspace/

āœ… Correct:   read_file("notes.txt")
āŒ Wrong:     read_file("workspace/notes.txt")
āŒ Wrong:     read_file("/absolute/path/file.txt")

šŸ› ļø Development

Add a New Tool

Edit server/filesystem_mcp_server.py:

@mcp.tool()
def search_files(query: str) -> str:
    """
    Search for files containing text.
    
    Args:
        query: Text to search for
    
    Returns:
        List of matching files
    """
    # Your implementation here
    return "Found 3 files matching 'query'"

Restart the server - that's it! The tool is automatically available.

šŸ¤ Contributing

Contributions welcome! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Make your changes
  4. Test everything works
  5. Submit a pull request

šŸŽ“ Workshop Ready

This project is designed for learning and teaching:

  • āœ… Clear, commented code
  • āœ… Step-by-step setup
  • āœ… Real-world example
  • āœ… Production patterns
  • āœ… Security best practices

Perfect for:

  • Learning MCP architecture
  • Building AI tools
  • Teaching modern Python
  • Prototyping ideas

Happy building! šŸŽ‰

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured