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