mcpField
M
mcp-this

mcp-this

ローカル
github.com/shane-kercheval開発ツール2050 週間前に更新

mcp-this について

mcp-this は、コマンドラインツールを MCP ツールに変換し、YAML ファイルでプロンプトテンプレートを定義する MCP サーバーです。コードを書かずに既存のシェルコマンドを MCP クライアントへ公開したいユーザーを想定しています。

主な機能

  1. 01YAML によるコマンドラインのツール定義
  2. 02パラメータプレースホルダーと任意パラメータの対応
  3. 03Handlebars 形式の構造化プロンプトテンプレート
  4. 04default、editing、github のプリセット
  5. 05ファイル、JSON 文字列、環境変数による設定

活用シーン

  1. 01git のステータス確認やポート調査のコマンドを Claude Desktop に公開する
  2. 02コードレビューや要約用の再利用可能なプロンプトを作成する
  3. 03github プリセットでプルリクエストの分析を行う

MCP 対応

MCP サーバーとして、YAML で定義したシェルコマンドとプロンプトテンプレートを、Claude Desktop などの MCP クライアントにツールとプロンプトとして公開します。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

mcp.json · 共通設定
{
"mcpServers": {
"this": {
"command": "uvx",
"args": [
"mcp-this"
]
}
}
}
起動コマンドuvx mcp-this

ローカルサーバーにはマシン上の実行環境(Node.js 18 以上など)が必要です。設定ファイルの場所はクライアントごとに異なります。

パッケージ
pypimcp-this

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

mcp-this

YAML 設定ファイルを通じて、CLI/bash コマンドをツールやプロンプトテンプレートとして動的に公開する MCP サーバーです。

mcp-this を使うと、あらゆるコマンドラインツールを MCP ツールに変換し、任意の MCP クライアント(例:Claude Desktop)が利用できる、構造化されたプロンプトテンプレートを作成できます。コードを書く代わりに、コマンド、プロンプト、パラメーターを YAML ファイルに定義するだけで、MCP サーバーが Claude Desktop などの MCP クライアントから利用できるようにします。

主な価値: シンプルな YAML 設定を使って CLI コマンドを MCP ツールに変換し、再利用可能なプロンプトテンプレートを作成できます。


仕組み

YAML でツール(CLI コマンド)とプロンプト(AI テンプレート)を定義します。

tools:
  get-current-time:
    description: |
      Display the current date and time in various formats.
      
      Examples:
      - get_current_time(format="iso") → 2025-05-18T17:17:39Z
      - get_current_time(format="readable") → Friday, May 18, 2025 5:17 PM
    execution:
      command: >-
        if [ "<<format>>" = "iso" ]; then 
          date -u +"%Y-%m-%dT%H:%M:%SZ"; 
        elif [ "<<format>>" = "readable" ]; then 
          date "+%A, %B %d, %Y %I:%M %p"; 
        else 
          echo "ISO: $(date -u +"%Y-%m-%dT%H:%M:%SZ")"; 
          echo "Readable: $(date "+%A, %B %d, %Y %I:%M %p")"; 
        fi
    parameters:
      format:
        description: "Time format: iso, readable, or empty for both"
        required: false

  system-info:
    description: Get basic system information
    execution:
      command: uname -a && echo "CPU: $(nproc) cores"
    parameters: {}

prompts:
  code-reviewer:
    description: Perform a thorough code review with best practices focus
    template: |
      Please review the following code with a focus on:
      - Code quality and best practices
      - Security vulnerabilities
      - Performance considerations
      {{#if focus_area}}- Special attention to: {{focus_area}}{{/if}}
      
      Code to review:
      {{code}}
      
      {{#if context}}Additional context: {{context}}{{/if}}
    arguments:
      code:
        description: Code to review
        required: true
      focus_area:
        description: Specific area to focus on (e.g., security, performance)
        required: false
      context:
        description: Additional context about the code
        required: false

Claude Desktop で使用します。

{
  "mcpServers": {
    "mcp-this-custom": {
      "command": "uvx",
      "args": ["mcp-this", "--config-path", "/path/to/your-tools.yaml"]
    }
  }
}

これだけです!Claude は次のことができるようになります。

  • カスタム CLI ツールを実行する(get-current-time、system-info)
  • 構造化されたプロンプトテンプレートを使用する(引数の入力をガイドする code-reviewer)

クイックスタート

1. uvx をインストールする
# Install uv (includes uvx)
curl -LsSf https://astral.sh/uv/install.sh | sh
2. 最初のツールを作成する

my-tools.yaml を作成します。

tools:
  web-scraper:
    description: Fetch a webpage and convert it to clean, readable text
    execution:
      command: curl -s '<<url>>' | lynx -dump -stdin
    parameters:
      url:
        description: URL of the webpage to fetch
        required: true

  find-large-files:
    description: Find files larger than specified size in a directory
    execution:
      command: find '<<directory>>' -type f -size +<<size>> -exec ls -lh {} \;
    parameters:
      directory:
        description: Directory to search
        required: true
      size:
        description: Minimum file size (e.g., 100M, 1G)
        required: true
2.1. AI プロンプトテンプレートを追加する(任意)

構造化されたプロンプトテンプレートを追加して、my-tools.yaml を拡張します。

tools:
  # ... your tools above ...

prompts:
  summarize-webpage:
    description: Generate a structured summary of webpage content
    template: |
      Please analyze the following webpage content and provide:
      
      1. **Main Topic**: What is this page about?
      2. **Key Points**: {{num_points}} most important points
      3. **Target Audience**: Who is this content for?
      {{#if focus}}4. **{{focus}} Analysis**: Specific insights about {{focus}}{{/if}}
      
      Content:
      {{content}}
    arguments:
      content:
        description: Webpage content to summarize
        required: true
      num_points:
        description: Number of key points to extract (default 5)
        required: false
      focus:
        description: Specific aspect to focus on (e.g., technical, business, educational)
        required: false

  file-analysis:
    description: Analyze files for specific purposes
    template: |
      Analyze the following files for {{analysis_type}}:
      
      {{#if criteria}}Focus on: {{criteria}}{{/if}}
      
      {{files}}
      
      Please provide:
      - Summary of findings
      - Recommendations
      - {{#if format}}Output in {{format}} format{{/if}}
    arguments:
      files:
        description: File contents or paths to analyze
        required: true
      analysis_type:
        description: Type of analysis (security, performance, quality, etc.)
        required: true
      criteria:
        description: Specific criteria or standards to check against
        required: false
      format:
        description: Output format (markdown, JSON, report, etc.)
        required: false

Claude Desktop でプロンプトを使用する方法:

  1. メッセージ入力欄の + アイコンをクリックします
  2. 「mcp-this-custom から追加」を選択します
  3. プロンプト(例:「summarize-webpage」)を選択します
  4. 引数を入力します。Claude が必須項目と任意項目の入力をガイドします
3. Claude Desktop を設定する

claude_desktop_config.json に追加します。

{
  "mcpServers": {
    "my-tools": {
      "command": "uvx",
      "args": ["mcp-this", "--config-path", "/path/to/my-tools.yaml"]
    }
  }
}
4. Claude Desktop を再起動する

ツールとプロンプトが利用できるようになります!Claude は次のことができます。

  • カスタム CLI ツールを使って、ウェブコンテンツを取得し、大きなファイルを見つける
  • 構造化されたプロンプトテンプレートを使用して、ガイド付きの分析や要約を行う

設定形式

ツールの定義
tools:
  tool-name:
    description: "Description with usage examples"
    execution:
      command: "command-template <<parameter1>> <<optional_param>>"
    parameters:
      parameter1:
        description: "Parameter description"
        required: true
      optional_param:
        description: "Optional parameter description"  
        required: false

重要なポイント:

  • コマンド内では <<parameter>> プレースホルダーを使用します
  • required: false に設定したパラメーターは、指定されていない場合、コマンドから削除されます
  • 複数行のコマンドには command: | ではなく command: >- を使用します
プロンプトの定義
prompts:
  prompt-name:
    description: "Prompt description"
    template: |
      Template with {{argument}} placeholders.
      {{#if optional_arg}}Conditional: {{optional_arg}}{{/if}}
    arguments:
      argument:
        description: "Argument description"
        required: true
      optional_arg:
        description: "Optional argument"
        required: false

プロンプトとツールの違い:

  • ツールはコマンドを実行し、<<parameter>> 構文を使用します
  • プロンプトはテキストテンプレートを生成し、Handlebars の {{argument}} 構文を使用します

設定方法

方法用途例
YAML ファイル--config-path <path>--config-path ./my-tools.yaml
JSON 文字列--config-value <json>--config-value '{"tools":{...}}'
環境変数MCP_THIS_CONFIG_PATHexport MCP_THIS_CONFIG_PATH=./tools.yaml
組み込みプリセット--preset <n>--preset default

事前構築済みのツールとプロンプトのコレクション(プリセット)

手軽に利用できるように、mcp-this にはすぐに使えるツールとプロンプトのコレクションが含まれています。

  • default - 安全な読み取り専用ツール(ファイルの調査、ウェブスクレイピング)
  • editing - ファイル操作ツール(作成、編集、削除)
  • github - GitHub 連携ツール(PR 分析、リポジトリ操作)+ 専用プロンプト(コードレビュー、PR の説明文作成)

簡単な使い方:

{
  "mcpServers": {
    "mcp-this": {
      "command": "uvx", 
      "args": ["mcp-this", "--preset", "default"]
    }
  }
}

プリセットの詳細なドキュメント、ツールの一覧、依存関係、高度な設定については、README_PRESETS.md をご覧ください。


実際の使用例

開発ワークフロー向けツール
tools:
  git-status-summary:
    description: Get a concise overview of git repository status
    execution:
      command: >-
        echo "=== Branch ===" && git branch --show-current &&
        echo "=== Status ===" && git status --porcelain &&
        echo "=== Recent Commits ===" && git log --oneline -5
    parameters: {}

  test-runner:
    description: Run tests with optional pattern matching
    execution:
      command: >-
        if [ -n "<<pattern>>" ]; then
          npm test -- --grep "<<pattern>>"
        else
          npm test
        fi
    parameters:
      pattern:
        description: Test pattern to match (optional)
        required: false

  docker-container-logs:
    description: Get logs from a Docker container
    execution:
      command: docker logs <<container_name>> --tail <<lines>>
    parameters:
      container_name:
        description: Name or ID of the Docker container
        required: true
      lines:
        description: Number of log lines to show (default 100)
        required: false
        default: "100"
AI を活用したワークフロー向けプロンプト
prompts:
  refactor-code:
    description: Guide code refactoring with specific goals and constraints
    template: |
      Please refactor the following code with these objectives:
      {{#if goals}}
      **Goals:**
      {{goals}}
      {{/if}}
      
      **Constraints:**
      - Maintain existing functionality
      - {{#if language}}Follow {{language}} best practices{{/if}}
      - {{#if performance}}Optimize for {{performance}}{{/if}}
      {{#if additional_constraints}}
      - {{additional_constraints}}
      {{/if}}
      
      **Code to refactor:**
      ```
      {{code}}
      ```
      
      Please provide:
      1. Refactored code with explanations
      2. Summary of changes made
      3. Potential risks or considerations
    arguments:
      code:
        description: Code to refactor
        required: true
      goals:
        description: Specific refactoring goals (e.g., improve readability, reduce complexity)
        required: false
      language:
        description: Programming language for best practices
        required: false
      performance:
        description: Performance optimization target (speed, memory, etc.)
        required: false
      additional_constraints:
        description: Any additional constraints or requirements
        required: false

  technical-documentation:
    description: Generate comprehensive technical documentation
    template: |
      Create {{doc_type}} documentation for:
      
      {{content}}
      
      **Requirements:**
      - Target audience: {{audience}}
      {{#if style}}- Documentation style: {{style}}{{/if}}
      {{#if sections}}- Include sections: {{sections}}{{/if}}
      - {{#if detail_level}}Detail level: {{detail_level}}{{/if}}
      
      {{#if examples}}**Include examples:** {{examples}}{{/if}}
      
      Please structure the documentation with clear headings, examples, and actionable information.
    arguments:
      content:
        description: Code, API, or system to document
        required: true
      doc_type:
        description: Type of documentation (API, user guide, technical spec, etc.)
        required: true
      audience:
        description: Target audience (developers, end-users, administrators, etc.)
        required: true
      style:
        description: Documentation style (formal, conversational, tutorial, reference)
        required: false
      sections:
        description: Specific sections to include
        required: false
      detail_level:
        description: Level of detail (high-level, detailed, comprehensive)
        required: false
      examples:
        description: Types of examples to include
        required: false
システム管理ツール
tools:
  port-checker:
    description: Check what process is using a specific port
    execution:
      command: lsof -i :<<port>>
    parameters:
      port:
        description: Port number to check
        required: true

  service-status:
    description: Check the status of a system service
    execution:
      command: systemctl status <<service_name>>
    parameters:
      service_name:
        description: Name of the service to check
        required: true

  disk-usage-analyzer:
    description: Analyze disk usage and find largest directories
    execution:
      command: >-
        echo "=== Disk Usage Summary ===" &&
        df -h <<path>> &&
        echo "=== Largest Directories ===" &&
        du -h <<path>> | sort -hr | head -10
    parameters:
      path:
        description: Path to analyze (default current directory)
        required: false
        default: "."

Python API の使用方法

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

# Using custom configuration
server_params = StdioServerParameters(
    command='uvx',
    args=['mcp-this', '--config-path', '/path/to/tools.yaml'],
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        
        # List available tools
        tools = await session.list_tools()
        print([tool.name for tool in tools.tools])
        
        # Use a tool
        result = await session.call_tool(
            'git-status-summary',
            {}
        )
        print(result.content[0].text)

インストール方法

uvx 経由(推奨)
# No installation needed - uvx runs tools in isolated environments
uvx mcp-this --config-path ./my-tools.yaml
pip 経由
pip install mcp-this
mcp-this --config-path ./my-tools.yaml
ソースから
git clone https://github.com/your-username/mcp-this.git
cd mcp-this
uv sync
python -m mcp_this --config-path ./my-tools.yaml

セキュリティに関する考慮事項

⚠️ 重要: mcp-this は設定に基づいてシェルコマンドを実行します。必ず次の点を守ってください。

  • 信頼できる設定ファイルのみを使用する
  • 本番環境ではユーザー入力を検証する
  • 必要最小限の権限で実行する
  • セキュリティをさらに高めるため、コンテナー化を検討する
  • 危険な操作を行うコマンドがないか確認する

詳細なセキュリティガイダンスについては、セキュリティのセクションをご覧ください。


開発

Setup
git clone https://github.com/your-username/mcp-this.git
cd mcp-this
uv sync
Testing
make tests         # Run all tests
make unittests     # Unit tests only
make linting       # Linting only
make open_coverage # View coverage report
Building
make package-build    # Build package
make package-publish  # Publish (requires UV_PUBLISH_TOKEN)

License

Apache License 2.0

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。