Skip to main content
Glama
elyasbromand

mcp-file-manager

by elyasbromand

MCP File Manager

A local Model Context Protocol (MCP) project that lets you manage files on your machine through natural language, powered by the Gemini API (free tier) as the client-side LLM.

The project has two halves that talk to each other over stdio (standard input/output pipes) — no network involved:

  • server.py — an MCP server exposing file-manipulation tools, read-only resources, and reusable prompts.

  • client.py — a terminal chat client that launches the server as a subprocess, connects to Gemini, and bridges the two: Gemini decides what to do, the server does it.

flowchart LR
    U([User]) -->|types message| C[MCP Client<br/>chat loop]
    C -->|conversation + tool schema| G[(Gemini API<br/>function calling)]
    G -->|final text| C
    G -.->|requests a tool call| C
    C <-->|JSON-RPC over stdio| S[MCP Server]
    S --- T[Tools<br/>list_directory, read_file,<br/>write_file, delete_file, update_file]
    S --- R[Resources<br/>file:// attachments via @]
    S --- P[Prompts<br/>summarize_file, clean_up_code via /]

    style G fill:#4285F4,color:#fff
    style S fill:#34A853,color:#fff
    style C fill:#111,color:#fff

Features

  • Tools (model-controlled — Gemini decides when to call these):

    • list_directory — list files/folders in a given path

    • read_file — read a file's contents

    • write_file — create or overwrite a file

    • delete_file — delete a file

    • update_file — find-and-replace text inside a file (supports replacing all occurrences or just the first)

  • Resources (user-controlled — attach a file to the conversation with @):

    • file:///{path} — exposes any file's content for direct attachment, no LLM tool call needed

  • Prompts (user-controlled — reusable instruction templates with /):

    • summarize_file — summarize a file's contents

    • clean_up_code — review and clean up a code file

  • Interactive chat client:

    • Type / alone to see a numbered picker of available prompts

    • Type @ alone to see a numbered picker of files in the current directory to attach

    • Or use them inline: /summarize_file report.txt, tell me about @report.txt

    • Full multi-step tool-calling loop — Gemini can chain multiple tool calls per turn

Related MCP server: File Operations MCP Server

Requirements

Setup

git clone <your-repo-url>
cd mcp_project

uv venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate

uv sync

Create a .env file in the project root (never commit this file — it's already covered by .gitignore):

GEMINI_API_KEY=add-your-api-key

Usage

Run the client

uv run client.py

You'll see the list of tools the server exposes, then a You: prompt. Try:

You: list files in the current directory
You: create a file called notes.txt with the content "hello world"
You: change hello to goodbye in notes.txt
You: /
  1. /summarize_file - Ask the assistant to summarize the contents of a file.
  2. /clean_up_code - Ask the assistant to review and clean up a code file.
Pick a number: 1
  path: notes.txt
You: @
  1. notes.txt
  2. server.py
Pick a number: 1
Your message about this file: what's in here?

Type quit or exit to end the session.

Inspect the server directly (debugging)

The MCP Python SDK ships a visual inspector for testing tools/resources/prompts without involving an LLM at all:

uv run mcp dev server.py

Minimal Project structure

mcp-file-manager/
├── .env                # your Gemini API key (not committed)
├── pyproject.toml       # uv-managed dependencies
├── server.py            # MCP server: tools, resources, prompts
├── client.py            # MCP client: chat loop + Gemini integration
└── README.md

How it works (short version)

  1. client.py launches server.py as a subprocess and opens an MCP session over stdio.

  2. On startup, the client fetches the server's tool list and converts it into Gemini's function-calling schema.

  3. On each user message, the client sends the conversation + tool list to Gemini.

  4. If Gemini responds with a function call, the client executes it against the MCP server and feeds the result back to Gemini — repeating until Gemini returns a final text answer.

  5. / and @ are handled entirely on the client side (never sent to Gemini as-is) — they fetch a prompt or resource directly from the MCP server and inject the result into the conversation before the normal flow above runs.

Notes & limitations

  • This is a local, single-user learning project — the file tools operate with the same permissions as whatever account runs client.py, so be mindful of what directory you run it from.

  • update_file's find-and-replace is a plain read-modify-write; it isn't safe against concurrent edits to the same file.

  • The / command only supports single-argument prompts out of the box; extend _handle_prompt if you add multi-argument prompts.

Learn more

License

MIT License.

Available Tools

5 tools
delete_fileB

Delete the file at the given path.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully explain the behavior. It merely states the action without disclosing that deletion is typically permanent, what happens if the path does not exist, whether directory deletion is supported, or if special permissions are required. This is a destructive operation with minimal behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, brief sentence with no wasted words. It is front-loaded and direct, making it easy to parse and immediately understand the tool's core function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

As a destructive mutation tool with no annotations, the description should provide more context. While an output schema exists, the description omits critical behavioral details such as irreversibility, error handling, and whether directories can be deleted. The side effects of the operation are not fully conveyed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has one parameter, path, with 0% description coverage. The description only mentions 'the given path' without adding guidance on path format (absolute vs relative), type constraints, or error conditions. The description fails to compensate for the lack of schema-level parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'delete' and identifies the resource 'the file at the given path', clearly distinguishing it from sibling tools like read_file, write_file, and update_file. The scope is precise and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as write_file or update_file, nor are any scenarios or prerequisites mentioned. The tool could be used for permanent file removal, but the description does not indicate when that is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_directoryA

List all files and folders in the given directory path.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathNo.

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the burden of behavioral disclosure. The verb 'list' implies a read-only operation, and 'all files and folders' conveys the scope. However, it does not disclose edge cases (e.g., hidden files, recursion, or error handling), which is a notable gap for unannotated tools.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that directly states the tool's action and target. No unnecessary words or information, achieving maximum conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-parameter tool with an output schema, the description is functional but minimal. It does not clarify whether listing is recursive, how directories vs. files are represented, or any behavior beyond the basic 'list all'. Given the presence of an output schema, return values are covered, but other contextual details remain vague.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It introduces 'given directory path', clarifying that the 'path' parameter should point to a directory. However, it adds no format details (absolute vs relative, supported types), and the single parameter's name is already fairly self-explanatory.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('List') and resource ('all files and folders in the given directory path'), clearly distinguishing this directory-listing tool from sibling file operations like read_file or delete_file.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage: use this when you need to list directory contents. However, it does not explicitly mention when not to use it or provide alternatives. Sibling tools operate on files, so context is present but not spelled out.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_fileA

Read and return the full text content of a file at the given path.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the core behavior (return full text content) and implies a read-only operation, but it does not disclose potential errors (e.g., permission issues, file not found), encoding details, or whether the operation is non-destructive. With no annotations, more behavioral context would be beneficial.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that front-loads the main action ('Read and return the full text content') and follows with the target ('a file at the given path'). Every word contributes value, with no redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with only one parameter, and an output schema exists (though not shown), which may cover return value details. The description is concise and adequate for a basic read operation. It lacks error handling or edge-case context, but given the low complexity, this is not a critical shortcoming.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has a single required parameter 'path' with zero description coverage. The description adds minimal meaning by referencing 'the given path,' clarifying that the path is used to locate the file. However, it does not specify path format, whether relative or absolute, or any constraints. Since schema coverage is 0%, the description only partially compensates.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function with a specific verb and resource: 'read and return the full text content of a file at the given path.' It distinguishes itself from sibling tools like write_file, delete_file, and update_file, which perform different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage (when you need to read a file, use this tool), but it does not explicitly state when to use this over alternatives or mention any prerequisites. It lacks guidance on scenarios like handling directories or non-existent files.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

update_fileA

Find and replace text inside a file.

Use this when the user asks to change, replace, or update specific text within an existing file (e.g. "change X to Y in report.txt").

Args: path: Path to the file to modify. old_text: The exact existing text to search for. new_text: The text to replace it with. replace_all: If True (default), replace every occurrence. If False, replace only the first occurrence.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
new_textYes
old_textYes
replace_allNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden for behavioral disclosure. It discloses the replace_all semantics (default true vs. false) which is valuable context. However, it does not mention error handling (e.g., what happens if old_text is not found) or whether the file must already exist, which would enhance transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured: starting with a clear summary, then usage context, then parameter details. Each sentence contributes value, and the front-loaded opening ensures the core purpose is immediately clear.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters and an output schema, the description covers the essential purpose, usage, and parameter details. It is quite complete, though it omits error behavior (e.g., non-existent path or missing old_text), which would make it fully comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates by explicitly explaining each parameter in an Args block, including the replace_all default behavior. This adds meaning beyond the bare schema, making parameter semantics exceptionally clear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb+resource combination: "Find and replace text inside a file." It clearly distinguishes from siblings like write_file (which likely overwrites entire files) by noting it operates "within an existing file."

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description delivers explicit when-to-use guidance: "Use this when the user asks to change, replace, or update specific text within an existing file." It stops short of naming sibling tools as alternatives (e.g., write_file for full overwrites), so it lacks explicit when-not-to-use direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

write_fileA

Create a file (or overwrite it if it exists) with the given text content.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
contentYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It explicitly states that the tool will overwrite an existing file, which is a critical destructive behavior. However, it does not disclose other potentially relevant details such as whether parent directories are created or what happens on invalid paths.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, frontloaded with the core action. It includes the important overwrite caveat without unnecessary eloquence, earning its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (two string parameters) and the presence of an output schema, the description is sufficiently complete for an agent to use it correctly. It explains the primary action and the destructive edge case without needing excessive detail.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has zero description coverage for its two parameters (path, content), so the description must compensate. It adds meaning by specifying 'text content,' which clarifies the content parameter, and the phrase 'Create a file' implies the path parameter is the target file location. However, it does not provide details on expected path formats or content encoding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Create a file (or overwrite it if it exists) with the given text content.' This uses the specific verb 'Create' and resource 'file,' and explicitly differentiates from sibling tools like delete_file, read_file, and update_file by noting the overwrite behavior.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool should be used to create or overwrite files with text content, but it does not explicitly provide guidance on when to use write_file versus sibling tools like update_file. No alternatives are mentioned, so the usage context is only implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.1.0
    • First observeddelete_file
    • First observedlist_directory
    • First observedread_file
    • First observedupdate_file
    • First observedwrite_file

TDQS

A3.8/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a distinct purpose: listing, reading, writing, deleting, and updating files. The update_file tool's find/replace behavior is clearly differentiated from write_file's full-content overwrite, so there is no ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern: list_directory, read_file, write_file, delete_file, update_file. This makes the API predictable and easy to navigate.

Tool Count5/5

With 5 tools, the server is well-scoped for a file manager. Each tool covers a core file operation without unnecessary redundancy or bloat.

Completeness3/5

The set covers file content CRUD (create, read, update, delete) and directory listing, but lacks directory management operations such as create/delete directory and rename/move. This leaves notable gaps for a full file manager, though the core file operations are solid.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers