CLI MCP Server
by anjumanraut
A simplified MCP server for terminal command execution
What is CLI MCP Server
Command
This repository contains a Model Context Protocol (MCP) server implementation for executing commands. It allows MCP-compatible AI assistants to execute commands in specified directories.
About the Model Context Protocol (MCP)
The Model Context Protocol (MCP) is an open standard developed by Anthropic that enables secure, two-way connections between data sources and AI-powered tools. MCP servers expose data and functionality to AI applications, allowing AI models to intelligently retrieve, process, and leverage information across private data sources.
Tool Schema
This MCP server provides one universal tool called "command" that gives AI agents a broad range of abilities to execute commands in specified directories.
{
"name": "command",
"description": "Execute commands in a specified directory",
"inputSchema": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "Command to execute"
},
"workingDir": {
"type": "string",
"description": "Working directory for command execution"
}
},
"required": ["command", "workingDir"]
}
}
Parameters Description
command
: The shell command that will be executed (e.g., "ls -la", "dir", "git status")workingDir
: The directory where the command will be executed. This must be one of the allowed directories specified in the configuration.
Project Structure
/command
โโโ config/ # Configuration-related files
โ โโโ index.js # Main config exporter
โ โโโ validation.js # Configuration validation logic
โโโ src/
โ โโโ core/ # Core server functionality
โ โ โโโ server.js # Server initialization & management
โ โ โโโ handlers.js # MCP request handlers
โ โโโ tools/ # Tool implementations
โ โ โโโ index.js # Exports all tools
โ โ โโโ command/ # Command tool module
โ โ โโโ index.js # Main command tool export
โ โ โโโ schema.js # Command tool schema
โ โ โโโ executor.js # Command execution logic
โ โ โโโ worker.js # Command worker implementation
โ โโโ utils/ # Utility functions
โ โ โโโ logging.js # Logging utilities
โ โ โโโ error.js # Error handling utilities
โ โโโ index.js # Application entry point
โโโ tests/ # Test directory
โ โโโ config.test.js # Configuration tests
โโโ logs/ # Log output directory
โโโ scripts/ # Scripts for running/building
โ โโโ start-server.sh # Unix start script
โ โโโ start-server.bat # Windows start script
โโโ package.json # Project metadata and dependencies
โโโ README.md # Project documentation
Setup Instructions
Prerequisites
- Node.js (v16 or higher)
- npm (v7 or higher)
Local Setup
- Install dependencies:
npm install
Configuration
To use this server with Claude, you need to update your Claude configuration to include the Command server.
Update your Claude configuration file (typically located at ~/.config/claude/claude_desktop_config.json
or ~/Library/Application Support/Claude/claude_desktop_config.json
) to include the following:
{
"mcpServers": {
"command": {
"command": "/path/to/command/start-server.sh",
"args": [
"/path/to/allowed/directory1",
"/path/to/allowed/directory2",
"/path/to/allowed/directory3"
]
}
}
}
Replace /path/to/command
with the actual path where this repository is located.
Replace /path/to/allowed/directory1
, /path/to/allowed/directory2
, etc. with the directories you want to allow Claude to execute commands in.
For Windows, use the batch file instead:
{
"mcpServers": {
"command": {
"command": "C:\\path\\to\\command\\start-server.bat",
"args": [
"C:\\path\\to\\allowed\\directory1",
"C:\\path\\to\\allowed\\directory2",
"C:\\path\\to\\allowed\\directory3"
]
}
}
}
Usage
Once configured, Claude can execute commands in the specified directories through the CLI MCP server.
The server accepts directory paths as arguments. Only these directories will be accessible for command execution.
Example usage in Claude:
Please run the following command:
command("ls -la", "/path/to/allowed/directory1")
On Windows, you might use:
Please run the following command:
command("dir", "C:\\path\\to\\allowed\\directory1")
Development
Available Scripts
npm start
- Run the servernpm run dev
- Run the server with auto-reload on file changesnpm test
- Run the test suite
Security Considerations
- The server only allows commands to be executed in directories specified as command-line arguments.
- Be cautious about the directories you expose to Claude, as it will have access to execute commands in these locations.
- Consider using a dedicated user with limited permissions for running the server.
- Review the commands executed by Claude to ensure they are safe and appropriate.
- The server includes path validation to prevent access to unauthorized directories.
License
Leave a Comment
Comments section will be available soon. Stay tuned!
Frequently Asked Questions
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.
What are MCP Servers?
MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.
How do MCP Servers work?
MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.
Are MCP Servers secure?
Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.
Related MCP Servers
Fetch
Web content fetching and conversion for efficient LLM usage
Playwright
A Model Context Protocol (MCP) server that provides browser automation capabilities using Playwright. This server enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models.
puppeteer-mcp-server
Puppeteer
Browser automation and web scraping
Playwright Universal MCP
A universal Playwright MCP server for browser automation in containerized environments
MCP Server Playwright
MCP Server Playwright - A browser automation service for Claude Desktop
OneNote MCP Server
MCP server for browsing and interacting with OneNote web app using browser-use automation
Playwright
๐ Fetcher MCP - Playwright Headless Browser Server
MCP server for fetch web page content using Playwright headless browser.
MCP Browser
NeoForge Browser MCP server - used to test the frontend
Submit Your MCP Server
Share your MCP server with the community
Submit Now