MCP CLI について
MCP CLIは、設定したシェルコマンドをAIアシスタント向けのツールとして公開するMCPサーバーです。実行可能なコマンドを限定し、個々のコマンドへの承認操作を減らしたいVS Codeユーザー向けです。
主な機能
- 01設定したシェルコマンドの公開
- 02許可コマンド一覧の管理
- 03ツール名と説明の設定
- 04作業ディレクトリと環境変数の指定
活用シーン
- 01エージェントによるビルドコマンドの実行
- 02プロジェクトテストの実行
- 03特定のデータベース接続コマンドの呼び出し
MCP 対応
設定したシェルコマンドをMCPクライアント向けのツールとして公開します。許可リストにコマンドを登録し、ツール単位で承認できます。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
MCP CLI
GitHub Copilot などの AI アシスタントにシェルコマンドをツールとして公開する、Model Context Protocol(MCP)サーバーです。

なぜ使うのか?
GitHub Copilot は任意のシェルコマンドをすでに実行できますが、mcp-cli を使うと、コードのビルドやテストの実行などに必要なシェルコマンドや、データベースへの接続に必要な独特な手順を正確に指定できます。
また、セキュリティ上の理由から、GitHub Copilot はシェルコマンドを実行するたびに許可を求めます。mcp-cli では許可するシェルコマンドの一覧を管理できるため、各ツールの実行を許可するのは一度だけで済みます。
インストール
git clone <repository-url>
cd mcp-cli
cabal install
まず、許可するコマンドを記述した JSON 設定ファイルを作成します。たとえば、mcp-cli.json を作成します。
{
"commands": [
"ls -l",
"date",
"pwd"
]
}
次に、Agent モードで Tools ボタンをクリックし、「Add More Tools...」、「Add MCP Server...」、「Command (stdio)...」の順に選択します。次に mcp-cli ${workspaceFolder}/mcp-cli.json と入力し、自動生成された名前を mcp-cli に変更して、「Workspace Settings」を選択します。これで、プロンプトの一部として mcp-cli に言及し、エージェントにツールを使うよう指示できます。
次のような .vscode/mcp.json ファイルが作成されます。
{
"servers": {
"mcp-cli": {
"type": "stdio",
"command": "mcp-cli",
"args": [
"${workspaceFolder}/mcp-cli.json"
]
}
}
}
使い方
JSON 設定ファイル内の許可するコマンド一覧を変更できます。
セッションの例を示します。
HUMAN
Please use the `mcp-cli` tool to repeatedly call `date` for 10 seconds, and
report the time at which the experiment started and ended. After each call,
carefully consider whether the 10 seconds has elapsed before deciding whether
to call `date` again.
AGENT
I'll help you use the mcp-cli tool to repeatedly call date for 10 seconds. Let
me start by making the first call to record the start time, then continue
calling until 10 seconds have elapsed.
VS CODE
> Run execute_command_2
[Continue] [Cancel]
HUMAN
(clicks the arrow next to "Continue", then "Allow in this session")
AGENT
> Ran execute_command_2
The experiment started at Fri May 30 08:51:55 AM EDT 2025. Now I'll continue
calling the date command repeatedly until 10 seconds have elapsed.
> Ran execute_command_2
The second call shows Fri May 30 08:51:58 AM EDT 2025 - that's 3 seconds after
the start. I need to continue calling date until 10 seconds have elapsed from
the start time (08:51:55). Let me continue:
> Ran execute_command_2
The third call shows Fri May 30 08:52:01 AM EDT 2025 - that's 6 seconds after
the start. I need to continue until 10 seconds have elapsed (until 08:52:05).
Let me continue:
> Ran execute_command_2
The fourth call shows Fri May 30 08:52:04 AM EDT 2025 - that's 9 seconds after
the start. I need one more call to reach or exceed the 10-second mark:
> Ran execute_command_2
Perfect! The experiment is now complete. Here are the results:
Experiment Summary:
Start time: Fri May 30 08:51:55 AM EDT 2025
End time: Fri May 30 08:52:07 AM EDT 2025
Total duration: 12 seconds
I made 5 calls to the date command through the mcp-cli tool:
08:51:55 (start)
08:51:58 (3 seconds elapsed)
08:52:01 (6 seconds elapsed)
08:52:04 (9 seconds elapsed)
08:52:07 (12 seconds elapsed - experiment complete)
The experiment ran for 12 seconds total, which exceeded the target of 10
seconds. After the 4th call at 08:52:04 (9 seconds elapsed), I made one final
call to ensure we had crossed the 10-second threshold, which occurred at
08:52:07, confirming that 10+ seconds had elapsed from the start time.
詳細設定
次の拡張形式を使うと、以下も指定できます。
- AI アシスタントに表示される名前。デフォルトは
execute_command_1です。 - ツールの機能を AI アシスタントに説明する説明文。デフォルトは
Execute the shell command: pwdです。 - コマンドを実行する作業ディレクトリ。
mcp-cli.jsonファイルの場所を基準とした相対パスです。ツール固有のパスは、トップレベルのパスが指定されている場合、それを基準とした相対パスになります。デフォルトは VS Code の起動元フォルダーです。 - AI アシスタントが指定する必要がある引数。コマンド内では環境変数になります。
- 設定する環境変数。ツール固有の環境変数は、トップレベルの環境変数を上書きします。
{
"commands": [
"ls -l",
{
"name": "list-source-files",
"workingDirectory": "src",
"command": "ls -l"
},
{
"name": "list-files-in",
"command": "ls -l \"$FOLDER\"",
"arguments": [
"FOLDER"
]
},
"git status",
{
"name": "recent_changes",
"description": "summarize the last few commits",
"command": "git log --oneline | head -n \"$N\"",
"arguments": [
{
"name": "N",
"description": "the number of commits to list"
}
],
"envVars": [
"GIT_EDITOR": "code"
]
}
],
"envVars": [
"NO_COLOR": "true",
"PAGER": null
]
}
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。