terminal

MCP.Pizza Chef: stat-guy

The Terminal MCP Server is a powerful tool that allows execution of terminal commands through Claude Desktop, supporting command arguments, options, and directory navigation while maintaining state. It captures full output including stdout, stderr, and exit codes, ensuring robust error handling and formatting. Designed for developers and power users, it requires Node.js v18+, TypeScript, and Claude Desktop for setup. This server facilitates seamless integration of terminal operations into AI workflows, enhancing automation and command-line interaction within the MCP ecosystem.

Use This MCP server To

Execute shell commands remotely via Claude Desktop Automate terminal workflows with AI assistance Capture and analyze command output programmatically Navigate and manage filesystem directories interactively Integrate terminal command execution into AI-driven tools

README

Terminal MCP Server

A Model Context Protocol (MCP) server that enables execution of terminal commands through Claude Desktop.

Features

  • Execute any terminal command with arguments and options
  • Navigate between directories while maintaining state
  • Get terminal environment information
  • Full output capture (stdout, stderr, exit codes)
  • Proper error handling and formatting

Prerequisites

  • Node.js v18 or higher
  • TypeScript
  • Claude Desktop

Installation

  1. Clone the repository:
git clone https://github.com/stat-guy/terminal.git
cd terminal
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Local Development Setup

  1. Create or edit your Claude Desktop configuration file:

    • On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • On Windows: %APPDATA%\\Claude\\claude_desktop_config.json

Add the following configuration:

{
  "mcpServers": {
    "terminal": {
      "command": "node",
      "args": [
        "[PATH_TO_REPO]/dist/index.js"
      ],
      "env": {
        "PERMISSION_REQUIRED": "true"
      }
    }
  }
}

Replace [PATH_TO_REPO] with the actual path to your cloned repository.

  1. Restart Claude Desktop

Available Tools

execute_command

  • Execute any terminal command
  • Supports command arguments and options
  • Captures full output and exit codes

change_directory

  • Change the current working directory
  • Maintains state between commands
  • Supports relative and absolute paths

get_current_directory

  • Get the current working directory path

get_terminal_info

  • Get information about the terminal environment
  • Shows shell, user, platform, and recent command history

Usage Examples

Ask Claude to execute terminal commands like:

Can you check what's in my current directory?
-> Executes: ls -la

Can you tell me the current directory?
-> Executes: pwd

Can you change to the Downloads folder?
-> Executes: cd ~/Downloads

Security Considerations

  • The server requires explicit user permission through Claude Desktop for command execution
  • Environment variables can be controlled through the configuration
  • Command execution includes timeouts and error handling

Development

  1. Watch for changes:
npm run watch
  1. Test changes:
  • Make changes to source files in src/
  • Rebuild using npm run build
  • Restart Claude Desktop to load changes

Project Structure

/
├── src/
│   └── index.ts    # Main server implementation
├── package.json    # Project configuration and dependencies
├── tsconfig.json  # TypeScript configuration
└── README.md      # This file

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

terminal FAQ

How do I install the Terminal MCP Server?
Clone the repository, install dependencies with npm, and build the project using 'npm run build'.
What are the prerequisites for running the Terminal MCP Server?
You need Node.js v18 or higher, TypeScript, and Claude Desktop installed.
How does the Terminal MCP Server handle command output?
It captures full output including stdout, stderr, and exit codes with proper error formatting.
Can I navigate directories while using the Terminal MCP Server?
Yes, it supports directory navigation and maintains state between commands.
Where do I configure the Terminal MCP Server for Claude Desktop?
Edit the Claude Desktop config file located at '~/Library/Application Support/Claude/claude_desktop_config.json' on macOS or '%APPDATA%\Claude\claude_desktop_config.json' on Windows.
Is the Terminal MCP Server compatible with other LLM providers?
While designed for Claude Desktop, it can be integrated with other LLMs like OpenAI and Gemini through MCP clients.
How does the server ensure secure command execution?
It includes proper error handling and formatting to safely manage terminal command execution within the MCP framework.
Can I use the Terminal MCP Server for local development?
Yes, it supports local development setups with clear installation and configuration instructions.