Terminal MCP server

Enables secure interaction with specified directories on a user's system through a command-line interface for file management and system automation tasks.
Back to servers
Provider
Alex Man
Release date
Jan 16, 2025
Language
TypeScript

This MCP server for terminal access enables Claude to interact with specified directories on your system via the Model Context Protocol (MCP). The server provides a secure way to give Claude limited filesystem access while maintaining control over which directories it can view and modify.

Installation

To get started with the MCP terminal server, follow these steps:

Prerequisites

  • Node.js installed on your system
  • Claude Desktop application

Setup Process

  1. Clone the repository or download the source code:

    git clone https://github.com/anthropic-labs/mcp-terminal-use.git
    
  2. Navigate to the project directory:

    cd mcp-terminal-use
    
  3. Install dependencies:

    npm install
    
  4. Build the project:

    npm run build
    

Configuration

Setting Allowed Directory

You must specify which directory Claude is allowed to access. This can be done in three ways:

  1. Using a .env file in the project root:

    ALLOWED_DIRECTORY=/path/to/your/allowed/directory
    
  2. Setting environment variables in your system:

    export ALLOWED_DIRECTORY=/path/to/your/allowed/directory
    
  3. Configuring directly in claude_desktop_config.json (recommended)

Claude Desktop Integration

Add the MCP server to your Claude Desktop configuration file:

  1. Open or create claude_desktop_config.json (typically located in your home directory)

  2. Add the following configuration:

    {
      "mcpServers": {
        "terminal": {
          "command": "node",
          "args": [
            "${HOME}/path/to/mcp-terminal-use/dist/index.js"
          ],
          "env": {
            "ALLOWED_DIRECTORY": "${HOME}/your/allowed/directory"
          }
        }
      }
    }
    
  3. Replace ${HOME}/path/to/mcp-terminal-use with the actual path to where you installed the project

  4. Replace ${HOME}/your/allowed/directory with the directory you want Claude to access

Usage

Starting the Server

The server will start automatically when Claude Desktop launches. You don't need to start it manually.

Interacting with Claude

Once configured, you can ask Claude to perform file operations within your allowed directory:

  • View directory contents: "Please list the files in my allowed directory"
  • Read file contents: "Show me the contents of file.txt"
  • Create or modify files: "Create a new file called example.txt with the following content..."
  • Execute commands: "Run 'ls -la' in my directory"

Security Considerations

  • Claude can only access the directory specified in your configuration
  • All operations are restricted to that directory and its subdirectories
  • File system operations outside the allowed directory will be rejected

Troubleshooting

Common Issues

  • If Claude reports it cannot access files, check that your ALLOWED_DIRECTORY path is correct
  • Ensure the MCP server is properly configured in claude_desktop_config.json
  • Verify that the built files exist in the dist directory after running npm run build

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later