MCP Console Automation Server

MCP Console Automation Server

Enables AI assistants to fully interact with console applications, monitor output, detect errors, and automate terminal workflows across multiple sessions. Similar to how Playwright works for web browsers but for command-line interfaces.

Category
访问服务器

README

MCP Console Automation Server

Production-Ready Model Context Protocol (MCP) server that enables AI assistants to fully interact with console applications, monitor output, detect errors, and automate terminal workflows - similar to how Playwright works for web browsers.

Version License Node

Production Status ✅

This server is fully production-ready with:

  • ✅ No native compilation required (removed node-pty dependency)
  • ✅ Full cross-platform support (Windows, macOS, Linux)
  • ✅ Streaming support for long-running processes
  • ✅ Multiple console type support (cmd, PowerShell, bash, zsh, sh)
  • ✅ Resource management and automatic cleanup
  • ✅ Comprehensive error handling and recovery
  • ✅ Easy installation scripts for all major MCP clients
  • ✅ All tests passing (see test-functionality.js)

Features

  • Full Terminal Control: Create and manage multiple console sessions simultaneously
  • Interactive Input: Send text input and special key sequences (Enter, Tab, Ctrl+C, etc.)
  • Real-time Output Monitoring: Capture and analyze console output as it happens
  • Streaming Support: Efficient streaming for long-running processes
  • Multiple Console Types: Support for cmd, PowerShell, bash, zsh, sh
  • Automatic Error Detection: Built-in patterns to detect errors, exceptions, and stack traces
  • Session Management: Create, stop, and manage up to 50 concurrent sessions
  • Resource Management: Memory monitoring, automatic cleanup, session limits
  • Command Execution: Run commands and wait for completion with timeout support
  • Pattern Matching: Wait for specific output patterns before continuing
  • Cross-platform: Works on Windows, macOS, and Linux without native dependencies

Quick Installation

Windows (PowerShell as Administrator)

git clone https://github.com/ooples/mcp-console-automation.git
cd mcp-console-automation
.\install.ps1 -Target claude  # or google, openai, custom, all

macOS/Linux

git clone https://github.com/ooples/mcp-console-automation.git
cd mcp-console-automation
chmod +x install.sh
./install.sh --target claude  # or google, openai, custom, all

Manual Installation

git clone https://github.com/ooples/mcp-console-automation.git
cd mcp-console-automation
npm install --production
npm run build

Configuration

For Claude Desktop

Add to your Claude Desktop configuration file:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "console-automation": {
      "command": "npx",
      "args": ["@mcp/console-automation"],
      "env": {
        "LOG_LEVEL": "info"
      }
    }
  }
}

For other MCP clients

# Start the server
mcp-console --log-level info

# Or with npx
npx @mcp/console-automation --log-level info

Available Tools (12 Total)

console_create_session

Create a new console session for running commands.

Parameters:

  • command (required): The command to execute
  • args: Array of command arguments
  • cwd: Working directory
  • env: Environment variables object
  • detectErrors: Enable automatic error detection (default: true)
  • timeout: Session timeout in milliseconds

Example:

{
  "command": "python",
  "args": ["script.py"],
  "cwd": "/path/to/project",
  "detectErrors": true
}

console_send_input

Send text input to an active console session.

Parameters:

  • sessionId (required): Session ID
  • input (required): Text to send

console_send_key

Send special key sequences to a console session.

Parameters:

  • sessionId (required): Session ID
  • key (required): Key to send (enter, tab, up, down, ctrl+c, escape, etc.)

console_get_output

Retrieve output from a console session.

Parameters:

  • sessionId (required): Session ID
  • limit: Maximum number of output lines to return

console_wait_for_output

Wait for specific output pattern in console.

Parameters:

  • sessionId (required): Session ID
  • pattern (required): Regex pattern to wait for
  • timeout: Timeout in milliseconds (default: 5000)

console_execute_command

Execute a command and wait for completion.

Parameters:

  • command (required): Command to execute
  • args: Command arguments
  • cwd: Working directory
  • env: Environment variables
  • timeout: Execution timeout

console_detect_errors

Analyze console output for errors and exceptions.

Parameters:

  • sessionId: Session ID to analyze
  • text: Direct text to analyze (if not using session)

console_stop_session

Stop an active console session.

Parameters:

  • sessionId (required): Session ID to stop

console_list_sessions

List all active console sessions.

console_resize_session

Resize terminal dimensions for a session.

Parameters:

  • sessionId (required): Session ID
  • cols (required): Number of columns
  • rows (required): Number of rows

console_clear_output

Clear the output buffer for a session.

Parameters:

  • sessionId (required): Session ID

Use Cases

1. Running and monitoring a development server

// Create a session for the dev server
const session = await console_create_session({
  command: "npm",
  args: ["run", "dev"],
  detectErrors: true
});

// Wait for server to start
await console_wait_for_output({
  sessionId: session.sessionId,
  pattern: "Server running on",
  timeout: 10000
});

// Monitor for errors
const errors = await console_detect_errors({
  sessionId: session.sessionId
});

2. Interactive debugging session

// Start a Python debugging session
const session = await console_create_session({
  command: "python",
  args: ["-m", "pdb", "script.py"]
});

// Set a breakpoint
await console_send_input({
  sessionId: session.sessionId,
  input: "b main\n"
});

// Continue execution
await console_send_input({
  sessionId: session.sessionId,
  input: "c\n"
});

// Step through code
await console_send_key({
  sessionId: session.sessionId,
  key: "n"
});

3. Automated testing with error detection

// Run tests
const result = await console_execute_command({
  command: "pytest",
  args: ["tests/"],
  timeout: 30000
});

// Check for test failures
const errors = await console_detect_errors({
  text: result.output
});

if (errors.hasErrors) {
  console.log("Test failures detected:", errors);
}

4. Interactive CLI tool automation

// Start an interactive CLI tool
const session = await console_create_session({
  command: "mysql",
  args: ["-u", "root", "-p"]
});

// Enter password
await console_wait_for_output({
  sessionId: session.sessionId,
  pattern: "Enter password:"
});

await console_send_input({
  sessionId: session.sessionId,
  input: "mypassword\n"
});

// Run SQL commands
await console_send_input({
  sessionId: session.sessionId,
  input: "SHOW DATABASES;\n"
});

Error Detection Patterns

The server includes built-in patterns for detecting common error types:

  • Generic errors (error:, ERROR:, Error:)
  • Exceptions (Exception:, exception)
  • Warnings (Warning:, WARNING:)
  • Fatal errors
  • Failed operations
  • Permission/access denied
  • Timeouts
  • Stack traces (Python, Java, Node.js)
  • Compilation errors
  • Syntax errors
  • Memory errors
  • Connection errors

Development

Building from source

npm install
npm run build

Running in development mode

npm run dev

Running tests

npm test

Type checking

npm run typecheck

Linting

npm run lint

Architecture

The server is built with:

  • node-pty: For creating and managing pseudo-terminals
  • @modelcontextprotocol/sdk: MCP protocol implementation
  • TypeScript: For type safety and better developer experience
  • Winston: For structured logging

Core Components

  1. ConsoleManager: Manages terminal sessions, input/output, and lifecycle
  2. ErrorDetector: Analyzes output for errors and exceptions
  3. MCP Server: Exposes console functionality through MCP tools
  4. Session Management: Handles multiple concurrent console sessions

Requirements

  • Node.js >= 18.0.0
  • Windows, macOS, or Linux operating system
  • No additional build tools required!

Testing

Run the included test suite to verify functionality:

node test-functionality.js

Troubleshooting

Common Issues

  1. Permission denied errors: Ensure the server has permission to spawn processes
  2. node-pty compilation errors: Install build tools for your platform
  3. Session not responding: Check if the command requires TTY interaction
  4. Output not captured: Some applications may write directly to terminal, bypassing stdout

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

MIT License - see LICENSE file for details

Support

For issues, questions, or suggestions, please open an issue on GitHub: https://github.com/yourusername/mcp-console-automation/issues

Roadmap

  • [ ] Add support for terminal recording and playback
  • [ ] Implement session persistence and recovery
  • [ ] Add more error detection patterns for specific languages
  • [ ] Support for terminal multiplexing (tmux/screen integration)
  • [ ] Web-based terminal viewer
  • [ ] Session sharing and collaboration features
  • [ ] Performance profiling tools
  • [ ] Integration with popular CI/CD systems

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选