Skip to main content
Glama

Simple Subprocess MCP Server

by yonaka15
server.py807 B
import subprocess from fastmcp import FastMCP mcp = FastMCP("Simple Subprocess Server") @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)}" if __name__ == "__main__": mcp.run()

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