MCP File Operations Agent

by dynstat

232 downloads
Not rated
GitHub

About

A working example of your own agents from the scratch and using it with the mcp servers from scratch

Details

Author
dynstat
Downloads
232
Categories
AI

- Read file contents and return them as text.
- Write content to specified files.
- List directory contents.
- Supports Stdio and SSE transport layers.
- Includes a client that integrates with Google's Gemini API.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP File Operations Agent
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install the package with pip install -e ., then create a .env file with your API keys. Run the server with python file_agent_server.py and the client with python file_agent_client.py. The server supports both Stdio and SSE transports; see the provided code examples for tool definition and client connection.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp file operations agent": {
            "File Operations Agent": {
                "command": "python",
                "args": [
                    "file_agent_server.py"
                ]
            }
        }
    }
}

McpServers

{
    "File Operations Agent": {
        "command": "python",
        "args": [
            "file_agent_server.py"
        ]
    }
}

MCP File Operations Agent

A simple Model Context Protocol (MCP) implementation providing file system operations through a server-client architecture.

Components

- file_agent_server.py: MCP server exposing file system operations as tools
- file_agent_client.py: Client implementation using Google's Gemini API

Features

- Read file contents
- Write content to files
- List directory contents

Requirements

- Python ≥3.12
- mcp[cli]>=1.6.0
- google-genai>=1.12.1
- python-dotenv

Setup

1. Install dependencies: pip install -e .
2. Create a .env file with your API keys (see .env-sample)
3. Run server: python file_agent_server.py
4. Run client: python file_agent_client.py
5. For SSE example: python sse_echo.py

Implementing MCP Agents

Here's how to set up MCP servers and clients using different transport layers:

Stdio Transport (Standard Input/Output)

Stdio transport is useful for local inter-process communication, often used when a client application spawns a server process.

Server (file_agent_server.py example):

```python

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.