Skip to main content
Glama
yonaka15

Simple Subprocess MCP Server

by yonaka15

run_command

Execute shell commands to automate tasks, retrieve system information, or manage processes through a secure subprocess interface.

Instructions

Execute a shell command using subprocess and return the output

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes

Implementation Reference

  • server.py:6-26 (handler)
    The main handler function for the 'run_command' tool. It executes the provided shell command using subprocess.run with shell=True, captures output, handles success/error/timeout cases, and returns the appropriate string response.
    @mcp.tool def run_command(command: str) -> str: """Execute a shell command using subprocess and return the output""" try: result = subprocess.run( command, shell=True, capture_output=True, text=True, timeout=30 # 30秒でタイムアウト ) if result.returncode == 0: return result.stdout else: return f"Error (exit code {result.returncode}): {result.stderr}" except subprocess.TimeoutExpired: return "Error: Command timed out after 30 seconds" except Exception as e: return f"Error executing command: {str(e)}"
  • server.py:6-6 (registration)
    The @mcp.tool decorator registers the run_command function as an MCP tool.
    @mcp.tool
  • server.py:7-8 (schema)
    Type hints and docstring define the input schema (command: str) and output (str), used by FastMCP for tool schema.
    def run_command(command: str) -> str: """Execute a shell command using subprocess and return the output"""
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yonaka15/simple-subprocess-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server