Skip to main content
Glama
nexon33

Electron Terminal MCP Server

by nexon33

電子端末MCPサーバー

理想的には、ベンダーがターミナル向けに独自のMCP統合を提供するはずですが、当面はこのプロジェクトで、クライアントがElectronアプリケーション内で動作するシステムターミナルと対話できるモデルコンテキストプロトコル(MCP)サーバーを提供します。これにより、コマンドの実行、ターミナルセッションの管理、プログラムによる出力の取得が可能になります。

このシステムは、主に次の 2 つの部分から構成されます。

  • **MCPサーバー ( index.js ):**標準入出力 (stdio) 経由でMCPリクエストをリッスンするNode.jsスクリプトです。 @modelcontextprotocol/sdkを使用し、Electronバックエンドへのブリッジとして機能します。Electronバックエンドがまだ実行されていない場合は、自動的に起動します。mcp mcp-package.json"type": "module"を指定する必要があります。

  • Electronバックエンド( main.js ): Electronアプリケーションのメインプロセス。MCPサーバー( index.js )がヘルスチェックやAPI呼び出しのために通信するExpress HTTPサーバー(デフォルトはポート3000)を実行します。このバックエンドは、 terminal.htmlを読み込む非表示のBrowserWindowインスタンス内でnode-ptyを使用して、実際のターミナルプロセスを管理します。

2. スクリーンショット

Claude Desktop のようなクライアント内でのターミナル操作は次のようになります。

ターミナル出力付きのClaudeデスクトップウィンドウ: ターミナル出力を備えたClaudeデスクトップウィンドウ

個別電子端末ウィンドウ:電子端末ウィンドウ

Related MCP server: MCP Terminal Server

3. インストール

  1. 前提条件: Node.js と npm がインストールされていることを確認してください。

  2. **クローン:**まだリポジトリをクローンしていない場合は、クローンを作成します。

    git clone <your-repository-url>
    cd command-terminal-electron # Or your repository directory name
  3. 依存関係のインストール: MCP サーバーと Electron アプリの両方に Node モジュールをインストールします。

    npm install
  4. ネイティブ モジュールの再構築: Electron 用のネイティブ モジュール ( node-ptyなど) を再構築します。

    node rebuild.js

    (詳細はrebuild.js参照)

3. 使用方法

  1. MCPサーバーを起動します。Node.jsを使用してindex.jsスクリプトを実行します。これにより、stdioでMCPコマンドがリッスンされ、Electronバックエンドプロセス( main.js )がまだ実行されておらず、想定されるHTTPポートでリッスンしていない場合は、自動的に起動を試みます。

    node index.js

    注: Electron プロセスはバックグラウンドで隠れて実行され、必要なときに自動的に (再) 起動され、可能な場合は常に再利用されます。

  2. **MCP経由のやり取り:**クライアントはstdio経由でnode index.jsプロセスに接続し、 use_mcp_toolコマンドを使用します。サーバー名はindex.js内で「Electron Terminal」として定義されています。

    利用可能なツール:

    • terminal_start : 新しいターミナルセッションを作成し、初期コマンドを実行します。

      • 入力: { "command": "string" }

      • 出力: { "content": [...], "sessionId": "string" } GXP5

    • terminal_execute : 既存のセッションでコマンドを実行します。

      • 入力: { "command": "string", "sessionId": "string" }

      • 出力: { "content": [...] } (セッションIDはテキストコンテンツに含まれます) GXP6

    • terminal_get_output : セッションの累積出力を取得します。

      • 入力: { "sessionId": "string" }

      • 出力: { "content": [...] } GXP7

    • terminal_stop : 特定のターミナルセッションプロセスを終了します。

      • 入力: { "sessionId": "string" }

      • 出力: { "content": [...] } GXP8

    • terminal_get_sessions : Electron バックエンドによって管理されている現在アクティブなセッションをすべて一覧表示します。

      • 入力: {}

      • 出力: { "content": [...] } (コンテンツにはアクティブなセッションのJSON文字列が含まれています) GXP9

5. ファイルシステムMCPサーバーとの相乗効果

このElectronターミナルMCPサーバーは、ファイルシステムMCPサーバーと連携することで非常に効果的に動作します。ファイルシステムサーバーを使用してディレクトリを参照し、ファイルの読み書きを行った後、このターミナルサーバーを使用してそれらのディレクトリ内またはファイルに関連するコマンドを実行できます。これにより、例えばclaudeデスクトップに組み込まれているインターネット検索機能とシームレスに連携する包括的なリモート開発およびインタラクションエクスペリエンスが実現します。

6. 要件

  • Node.js (v20以降を推奨、私はNode 22を使用)

  • npm

  • Electron と互換性のあるオペレーティング システム (Windows、macOS、Linux)

7. 構成

Claude デスクトップ MCP サーバー構成

位置

claude_desktop_config.jsonファイルは、ユーザーの AppData ディレクトリに配置する必要があります。

  • Windows: C:\Users\<username>\AppData\Roaming\Claude\claude_desktop_config.json

このファイルは、Claude Desktop によって外部 MCP サーバーを検出し、構成するために使用されます。

目的と構造

設定ファイルは、Claude Desktop が起動および接続できる MCP サーバーを定義します。各サーバーエントリは、サーバープロセスの起動方法を指定します。

  • mcpServers : 各キーがサーバー名で、値がその起動構成であるオブジェクト。

  • サーバー構成例 ( command-terminal ) :

    • command : 実行する実行可能ファイル (例: Node.js サーバーの場合はnode )。

    • args : コマンドに渡される引数の配列 (例: MCP サーバー スクリプトへのパス)。

{
  "mcpServers": {
    "command-terminal": {
      "command": "node",
      "args": [
        "C:\\Path\\to\\index.js"
      ]
    }
  }
}

フィールドの説明

  • mcpServers : サーバー名とその構成をマッピングする最上位オブジェクト。

  • command-terminal : サーバー名の例。このオブジェクトには複数のサーバーを定義できます。

  • command : MCP サーバーを起動するために使用される実行可能ファイル。

  • args : サーバー スクリプトへのパスなど、コマンドに渡される引数。

8. ライセンス

このプロジェクトはMITライセンスの下で提供されています。詳細はLICENSEファイルをご覧ください。

Available Tools

5 tools
terminal_executeD
ParametersJSON Schema
NameRequiredDescriptionDefault
commandYes
sessionIdYes

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

terminal_get_outputD
ParametersJSON Schema
NameRequiredDescriptionDefault
sessionIdYes

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

terminal_get_sessionsD
ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

terminal_startD
ParametersJSON Schema
NameRequiredDescriptionDefault
commandYes

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

terminal_stopD
ParametersJSON Schema
NameRequiredDescriptionDefault
sessionIdYes

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • Changedterminal_get_sessions1 field changed
      • removedInput schema / additionalProperties
        Removed value: -false
  2. 5 tool updates
    • First observedterminal_execute
    • First observedterminal_get_output
    • First observedterminal_get_sessions
    • First observedterminal_start
    • First observedterminal_stop

TDQS

C2.2/5.0

Scored across 5 tools

Disambiguation5/5

Each tool name maps to a distinct lifecycle action: start, execute, get output, stop, and list sessions. Even without descriptions, the boundaries are clear and unlikely to cause misselection.

Naming Consistency5/5

All tool names follow the same terminal_verb pattern using snake_case. The convention is uniform and predictable across the entire set.

Tool Count5/5

Five tools is a well-scoped size for a terminal management server. Each tool covers a necessary operation without redundancy or bloat.

Completeness5/5

The set covers the full terminal session lifecycle: create, interact, read output, stop, and enumerate sessions. There are no obvious dead ends or missing core operations.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that provides programmatic access to the Windows terminal, enabling AI models to interact with the Windows command line through standardized tools for writing commands, reading output, and sending control signals.
    3
    5 npm
    MIT
  • A
    license
    C
    quality
    C
    maintenance
    A server that enables AI assistants to execute terminal commands and retrieve outputs via the Model Context Protocol (MCP).
    3
    27
    MIT