MCP File Operations Agent
About
A working example of your own agents from the scratch and using it with the mcp servers from scratch
Explore
- 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:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP File Operations AgentCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
- Python ≥3.12
- mcp[cli]>=1.6.0
- google-genai>=1.12.1
- python-dotenv
app = FastMCP(name="SSE Echo Server", host=HOST, port=PORT, sse_path=SSE_PATH)
@file_agent.tool()
def read_file(file_path: str) -> str:
"""Read the contents of a file."""
try:
with open(file_path, 'r', encoding='utf-8') as f:
return f.read()
except Exception as e:
return f"Error reading file: {str(e)}"
list_tools_result = await session.list_tools()
print("Available tools:", list_tools_result.tools)
call_result = await session.call_tool("read_file", {"file_path": "README.md"})
if call_result.content and isinstance(call_result.content[0], mcp_types.TextContent):
print("Read file result:", call_result.content[0].text[:100] + "...")
else:
print("Error or unexpected result:", call_result)
except Exception as e:
print(f"Client error: {e}")
if __name__ == "__main__":
asyncio.run(run_client())
```
@app.tool()
async def echo(text: str) -> list[TextContent]:
"""Echoes the input text back."""
print(f"Server received: {text}")
return [TextContent(type="text", text=f"Echo: {text}")]
message = "Hello via SSE!"
response: CallToolResult = await session.call_tool("echo", {"text": message})
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"
]
}
}
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
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



