abhisvakil/mcp-terminal-server
If you are the rightful owner of mcp-terminal-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Terminal Server is a secure bridge that allows Claude AI to manage local files and directories through terminal commands.
MCP Terminal Server ๐
My first Model Context Protocol (MCP) server that enables Claude AI to manage local files and directories through terminal commands. This project demonstrates how to create a secure bridge between AI assistants and your local development environment.
๐ What is MCP?
Model Context Protocol (MCP) is a protocol that allows AI assistants like Claude to communicate with external tools and services on your local machine. It's like a secure bridge between the AI and your system, enabling powerful local development workflows.
๐ฏ Project Overview
This MCP server provides Claude with the ability to:
- Execute terminal commands in a controlled workspace
- Manage files and directories
- Run development tools and scripts
- Install packages and dependencies
- All while maintaining security through isolated execution
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ MCP Protocol โโโโโโโโโโโโโโโโโโโโ Shell Commands โโโโโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโโโโโโโบโ โโโโโโโโโโโโโโโโโโโโโโโบโ โ
โ Claude AI โ โ Terminal Server โ โ Terminal โ
โ โ โ (Python Script) โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ ~/mcp/ โ
โ workspace/ โ
โโโโโโโโโโโโโโโ
๐ Features
- Secure Command Execution: All commands run in an isolated workspace directory
- Error Handling: Comprehensive error capture and reporting
- MCP Protocol Compliance: Full compatibility with Claude Desktop
- Easy Configuration: Simple setup with clear documentation
๐ฆ Installation
Prerequisites
- Python 3.9+
- Claude Desktop application
- MCP library (
pip install mcp>=1.0.0
)
Setup
-
Clone the repository:
git clone https://github.com/yourusername/mcp-terminal-server.git cd mcp-terminal-server
-
Install dependencies:
cd servers/terminal_server pip install -e .
-
Configure Claude Desktop:
Open your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Linux:
~/.config/Claude/claude_desktop_config.json
Add the following configuration:
{ "mcpServers": { "terminal": { "command": "/path/to/your/python", "args": [ "/path/to/mcp-terminal-server/servers/terminal_server/terminal_server.py" ] } } }
- macOS:
-
Restart Claude Desktop to load the new configuration.
๐ ๏ธ Usage
Once configured, you can ask Claude to perform terminal operations:
- "Create a new Python project in the workspace"
- "List all files in the workspace"
- "Install the requests package"
- "Run the test suite"
- "Create a backup of the current project"
๐ง Development
Project Structure
mcp-terminal-server/
โโโ servers/
โ โโโ terminal_server/
โ โโโ terminal_server.py # Main MCP server implementation
โ โโโ pyproject.toml # Python project configuration
โ โโโ README.md # Server-specific documentation
โโโ workspace/ # Default working directory for commands
โโโ .vscode/ # VS Code configuration
โโโ README.md # This file
Key Components
terminal_server.py
The main MCP server that:
- Defines the
run_command
tool for Claude - Handles command execution in the workspace
- Provides error handling and output capture
pyproject.toml
Python project configuration with:
- MCP dependency specification
- Build system configuration
- Project metadata
๐ Security Features
- Isolated Workspace: All commands run in
~/mcp/workspace
- Controlled Access: Only specific tools are exposed to Claude
- Error Handling: Safe error capture and reporting
- No System Access: Commands cannot access your entire filesystem
๐งช Testing
Test your MCP server:
cd servers/terminal_server
python -c "import terminal_server; print('Server imports successfully')"
๐ Configuration Examples
Different Python Interpreters
Anaconda/Miniconda:
{
"command": "/opt/anaconda3/bin/python",
"args": ["/path/to/terminal_server.py"]
}
System Python:
{
"command": "/usr/bin/python3",
"args": ["/path/to/terminal_server.py"]
}
Virtual Environment:
{
"command": "/path/to/venv/bin/python",
"args": ["/path/to/terminal_server.py"]
}
๐ค Contributing
This is my first MCP project! Feel free to:
- Report issues
- Suggest improvements
- Share your own MCP server creations
๐ Learning Resources
๐ My MCP Journey
This project marks the beginning of my exploration into Model Context Protocol. MCP opens up incredible possibilities for AI-assisted development, allowing Claude to become a true development partner that can interact with your local environment safely and effectively.
Key Learnings:
- Understanding the MCP protocol and its capabilities
- Building secure bridges between AI and local systems
- Creating tools that enhance AI assistant functionality
- The power of controlled, isolated command execution
๐ License
MIT License - feel free to use this project as a starting point for your own MCP servers!
Built with โค๏ธ and MCP | My first step into the future of AI-assisted development