Terminal MCP Server
local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Enables execution of shell commands in a dedicated workspace directory, returning command output or error messages to the AI
MCP Server for Executing Terminal Commands
Introduction
Hey everyone! Welcome back to The AI Language. In this project, we’re building an MCP server that can execute terminal commands. This allows you to ask Claude for Desktop to run commands on your computer and return the output — like using a terminal, but powered by AI!
🎥 Video tutorials:
If you enjoy learning about AI, coding, and automation, please like and subscribe to the channel — it really helps us make more great content for you!
What is MCP?
MCP (Model Context Protocol) is a system that allows AI models to:
- Store data (like files or API responses)
- Run tools (functions that AI can execute)
- Use prompts (predefined templates for tasks)
In this tutorial, we’re building a tool that takes a command, runs it in the terminal, and sends back the output.
Two Ways to Set Up Your MCP Server
You can run your MCP server with or without Docker:
🔹 Option 1: Run Directly Using Python (no Docker)
This is great for development or local experimentation.
🔹 Option 2: Run Using Docker
Perfect for clean environments and easy distribution — no need to install Python or dependencies globally.
Both methods work with Claude for Desktop, and we’ll walk you through both.
Option 1: Setup Without Docker (Local Python)
Step 1: Install Python and uv
You need Python 3.10 or higher and a tool called uv
:
- Install Python: https://www.python.org/downloads/
- Install
uv
:Copy - Fix permissions if needed:Copy
Step 2: Create Project Structure
Step 3: Initialize and Activate Project
Step 4: Install Required Packages
Step 5: Create Your Server
Create terminal_server.py
and paste this:
Step 6: Start the Server
Option 2: Setup With Docker
Step 1: Create a Dockerfile
In the same folder as terminal_server.py
, create a Dockerfile
:
Make sure you have a requirements.txt
that includes:
Step 2: Build the Docker Image
Step 3: Configure Claude Desktop to Use the Docker Image
Open:
Add:
Replace
<your-username>
with your actual macOS username.
Then restart Claude Desktop.
Testing the MCP Server
In Claude, try these prompts:
Run the command ls in my workspace.
Execute echo Hello from Claude.
You should see the output directly from your terminal server 🎉
Wrapping Up
Congrats! You’ve built a working MCP server that executes terminal commands — and you can run it with or without Docker.
Want to go further?
- Add security checks to block dangerous commands
- Let Claude write to or read from files
- Connect to cloud or remote systems
👉 Let us know in the YouTube comments what you'd like to build next!
Don’t forget to like, subscribe, and share to support more videos like this. See you next time 🚀
This server cannot be installed
An MCP server that allows AI assistants like Claude to execute terminal commands on the user's computer and return the output, functioning like a terminal through AI.