Run any command with `run_command` and `run_script` tools.
The Model Context Protocol (MCP) is revolutionizing how Large Language Models (LLMs) interact with the world. By providing a standardized interface for LLMs to access external data sources and tools, MCP unlocks a new realm of possibilities for AI-powered applications. This document delves into the practical application of MCP, focusing on the use of tools to extend the capabilities of LLMs like Claude.
Tools enable LLMs to perform actions and gather information beyond their pre-trained knowledge. Consider them as extensions of the LLM's capabilities, allowing them to interact with the environment and access real-time data.
This implementation provides two powerful tools:
run_command
: Executes shell commands directly on the server. This allows the LLM to perform tasks such as:
hostname
)ls -al
)echo "hello world"
)run_script
: Executes scripts written in various languages (e.g., fish
, bash
, zsh
, python
). This empowers the LLM to:
run_command
with the script provided as input.cat
as an interpreter to create new files.Security Considerations:
[!WARNING] Exercising caution when using these tools is paramount. The
run_command
andrun_script
tools can potentially execute arbitrary code on the server.When using with Claude Desktop, it is highly recommended to use the
Approve Once
option instead ofAllow for This Chat
. This allows you to carefully review each command before execution. If you are unsure about the safety of a command, use theDeny
option.The permissions granted to the LLM are determined by the user account running the server. Never run the server with
sudo
or elevated privileges.
Prompts serve as the bridge between the user and the LLM, guiding its behavior and providing context. In environments like Zed's AI Chat panel, prompts can be used to trigger specific actions.
run_command
Prompt: This prompt type allows users to directly request the execution of a command and receive the output within the chat interface.This section outlines the steps required to set up and run the MCP server.
Prerequisites:
Installation:
npm install
npm run build
npm run watch
To enable the MCP server within the Claude Desktop application, you need to configure the claude_desktop_config.json
file.
Configuration File Location:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
Configuration Options:
This is the recommended approach for most users.
{ "mcpServers": { "mcp-server-commands": { "command": "npx", "args": ["mcp-server-commands"] } } }
This option is useful for developers who are actively modifying the server code.
{ "mcpServers": { "mcp-server-commands": { // works b/c of shebang in index.js "command": "/path/to/mcp-server-commands/build/index.js" } } }
Effective monitoring and debugging are crucial for ensuring the stability and reliability of the MCP server.
Logging:
Claude Desktop writes logs to: ~/Library/Logs/Claude/mcp-server-mcp-server-commands.log
By default, only errors and important messages are logged. To increase the verbosity of the logs, add the --verbose
flag to the args
in the server configuration.
Example:
{ "mcpServers": { "mcp-server-commands": { "command": "npx", "args": ["mcp-server-commands", "--verbose"] } } }
Note: Logs are written to STDERR
because that is the channel used by Claude Desktop for log file routing. Future implementations may utilize the STDIO
transport for more structured log messages.
Debugging with MCP Inspector:
The MCP Inspector provides a powerful set of debugging tools for MCP servers. It can be launched using the following npm script:
npm run inspector
This will provide a URL to access the Inspector in your browser, allowing you to inspect the communication between the LLM and the server.
By leveraging the power of tools and the Model Context Protocol, developers can create intelligent and interactive AI applications that seamlessly integrate with the real world.
๐ ๐ Autonomous shell execution, computer control and coding agent. (Mac)
๐ MCP server that can execute commands such as keyboard input and mouse movement
๐ ๐ ๐ฆ Analyzes your codebase identifying important files based on dependency relationships. Generates diagrams and importance scores, helping AI assistants understand the codebase.
๐ ๐ An MCP Server and VS Code Extension which enables (language agnostic) automatic debugging via breakpoints and expression evaluation.