jpskill.com
🛠️ 開発・MCP Anthropic公式 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ MCP連携

MCP Integration

Claude Codeプラグインに外部のツールやサービス

⏱ RAG構築 1週間 → 1日

📺 まず動画で見る(YouTube)

▶ The Ultimate Claude Code Guide | MCP, Skills & More ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides comprehensive guidance for integrating Model Context Protocol servers into Claude Code plugins for external tool and service integration.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Claude Codeプラグインに外部のツールやサービス

日本人がよく使う場面
・社内 API と Claude Code の連携プラグイン作成 ・Slack/Notion/JIRA 連携 ・SaaS の Claude Code 公式プラグイン化

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
4

💬 こう話しかけるだけ — サンプルプロンプト

  • プラグインへのMCPサーバー組み込み を使って、最小構成のサンプルコードを示して
  • プラグインへのMCPサーバー組み込み の主な使い方と注意点を教えて
  • プラグインへのMCPサーバー組み込み を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[Skill 名] MCP Integration

Claude Code プラグインのための MCP 統合

概要

Model Context Protocol (MCP) は、構造化されたツールアクセスを提供することで、Claude Code プラグインが外部サービスや API と統合できるようにします。MCP 統合を使用して、外部サービスの機能を Claude Code 内のツールとして公開します。

主な機能:

  • 外部サービス(データベース、API、ファイルシステム)への接続
  • 単一サービスから 10 以上の関連ツールを提供
  • OAuth や複雑な認証フローの処理
  • 自動セットアップのための MCP サーバーとプラグインのバンドル

MCP サーバー設定方法

プラグインは MCP サーバーを 2 つの方法でバンドルできます。

方法 1: 専用の .mcp.json (推奨)

プラグインのルートに .mcp.json を作成します。

{
  "database-tools": {
    "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
    "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
    "env": {
      "DB_URL": "${DB_URL}"
    }
  }
}

利点:

  • 懸念事項の明確な分離
  • メンテナンスが容易
  • 複数のサーバーに適しています

方法 2: plugin.json 内でのインライン

plugin.json に mcpServers フィールドを追加します。

{
  "name": "my-plugin",
  "version": "1.0.0",
  "mcpServers": {
    "plugin-api": {
      "command": "${CLAUDE_PLUGIN_ROOT}/servers/api-server",
      "args": ["--port", "8080"]
    }
  }
}

利点:

  • 単一の設定ファイル
  • シンプルなシングルサーバープラグインに適しています

MCP サーバーの種類

stdio (ローカルプロセス)

ローカル MCP サーバーを子プロセスとして実行します。ローカルツールやカスタムサーバーに最適です。

設定:

{
  "filesystem": {
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"],
    "env": {
      "LOG_LEVEL": "debug"
    }
  }
}

ユースケース:

  • ファイルシステムアクセス
  • ローカルデータベース接続
  • カスタム MCP サーバー
  • NPM パッケージ化された MCP サーバー

プロセス管理:

  • Claude Code がプロセスを生成し、管理します
  • stdin/stdout を介して通信します
  • Claude Code の終了時に終了します

SSE (Server-Sent Events)

OAuth サポート付きのホスト型 MCP サーバーに接続します。クラウドサービスに最適です。

設定:

{
  "asana": {
    "type": "sse",
    "url": "https://mcp.asana.com/sse"
  }
}

ユースケース:

  • 公式ホスト型 MCP サーバー (Asana, GitHub など)
  • MCP エンドポイントを持つクラウドサービス
  • OAuth ベースの認証
  • ローカルインストール不要

認証:

  • OAuth フローは自動的に処理されます
  • 初回使用時にユーザーにプロンプトが表示されます
  • トークンは Claude Code によって管理されます

HTTP (REST API)

トークン認証付きの RESTful MCP サーバーに接続します。

設定:

{
  "api-service": {
    "type": "http",
    "url": "https://api.example.com/mcp",
    "headers": {
      "Authorization": "Bearer ${API_TOKEN}",
      "X-Custom-Header": "value"
    }
  }
}

ユースケース:

  • REST API ベースの MCP サーバー
  • トークンベースの認証
  • カスタム API バックエンド
  • ステートレスなインタラクション

WebSocket (リアルタイム)

リアルタイムの双方向通信のために WebSocket MCP サーバーに接続します。

設定:

{
  "realtime-service": {
    "type": "ws",
    "url": "wss://mcp.example.com/ws",
    "headers": {
      "Authorization": "Bearer ${TOKEN}"
    }
  }
}

ユースケース:

  • リアルタイムデータストリーミング
  • 永続的な接続
  • サーバーからのプッシュ通知
  • 低遅延要件

環境変数の展開

すべての MCP 設定は環境変数の置換をサポートしています。

${CLAUDE_PLUGIN_ROOT} - プラグインディレクトリ (移植性のために常に使用):

{
  "command": "${CLAUDE_PLUGIN_ROOT}/servers/my-server"
}

ユーザー環境変数 - ユーザーのシェルから:

{
  "env": {
    "API_KEY": "${MY_API_KEY}",
    "DATABASE_URL": "${DB_URL}"
  }
}

ベストプラクティス: 必要なすべての環境変数をプラグインの README に文書化してください。

MCP ツールの命名

MCP サーバーがツールを提供する場合、それらは自動的にプレフィックスが付けられます。

形式: mcp__plugin_<plugin-name>_<server-name>__<tool-name>

例:

  • プラグイン: asana
  • サーバー: asana
  • ツール: create_task
  • フルネーム: mcp__plugin_asana_asana__asana_create_task

コマンドでの MCP ツールの使用

コマンドのフロントマターで特定の MCP ツールを事前に許可します。

---
allowed-tools: [
  "mcp__plugin_asana_asana__asana_create_task",
  "mcp__plugin_asana_asana__asana_search_tasks"
]
---

ワイルドカード (控えめに使用):

---
allowed-tools: ["mcp__plugin_asana_asana__*"]
---

ベストプラクティス: セキュリティのために、ワイルドカードではなく特定のツールを事前に許可してください。

ライフサイクル管理

自動起動:

  • MCP サーバーはプラグインが有効になると起動します
  • 最初のツール使用前に接続が確立されます
  • 設定変更には再起動が必要です

ライフサイクル:

  1. プラグインがロードされます
  2. MCP 設定が解析されます
  3. サーバープロセスが起動されるか (stdio)、接続が確立されます (SSE/HTTP/WS)
  4. ツールが検出され、登録されます
  5. ツールが mcp__plugin_...__... として利用可能になります

サーバーの表示: /mcp コマンドを使用して、プラグインが提供するものを含むすべてのサーバーを表示します。

認証パターン

OAuth (SSE/HTTP)

OAuth は Claude Code によって自動的に処理されます。

{
  "type": "sse",
  "url": "https://mcp.example.com/sse"
}

ユーザーは初回使用時にブラウザで認証します。追加の設定は不要です。

トークンベース (ヘッダー)

静的または環境変数トークン:

{
  "type": "http",
  "url": "https://api.example.com",
  "headers": {
    "Authorization": "Bearer ${API_TOKEN}"
  }
}

必要な環境変数を README に文書化してください。

環境変数 (stdio)

MCP サーバーに設定を渡します。

{
  "command": "python",
  "args": ["-m", "my_mcp_server"],
  "env": {
    "DATABASE_URL": "${DB_URL}",
    "API_KEY": "${API_KEY}",
    "LOG_LEVEL": "info"
  }
}

統合パターン

パターン 1: シンプルなツールラッパー

コマンドはユーザーとの対話で MCP ツールを使用します。

# コマンド: create-item.md
---
allowed-tools: ["mcp__plugin_name_server__create_item"]
---

手順:
1. ユーザーからアイテムの詳細を収集します
2. mcp__plugin_name_server__create_item を使用します
3. Con
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

MCP Integration for Claude Code Plugins

Overview

Model Context Protocol (MCP) enables Claude Code plugins to integrate with external services and APIs by providing structured tool access. Use MCP integration to expose external service capabilities as tools within Claude Code.

Key capabilities:

  • Connect to external services (databases, APIs, file systems)
  • Provide 10+ related tools from a single service
  • Handle OAuth and complex authentication flows
  • Bundle MCP servers with plugins for automatic setup

MCP Server Configuration Methods

Plugins can bundle MCP servers in two ways:

Method 1: Dedicated .mcp.json (Recommended)

Create .mcp.json at plugin root:

{
  "database-tools": {
    "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
    "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
    "env": {
      "DB_URL": "${DB_URL}"
    }
  }
}

Benefits:

  • Clear separation of concerns
  • Easier to maintain
  • Better for multiple servers

Method 2: Inline in plugin.json

Add mcpServers field to plugin.json:

{
  "name": "my-plugin",
  "version": "1.0.0",
  "mcpServers": {
    "plugin-api": {
      "command": "${CLAUDE_PLUGIN_ROOT}/servers/api-server",
      "args": ["--port", "8080"]
    }
  }
}

Benefits:

  • Single configuration file
  • Good for simple single-server plugins

MCP Server Types

stdio (Local Process)

Execute local MCP servers as child processes. Best for local tools and custom servers.

Configuration:

{
  "filesystem": {
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"],
    "env": {
      "LOG_LEVEL": "debug"
    }
  }
}

Use cases:

  • File system access
  • Local database connections
  • Custom MCP servers
  • NPM-packaged MCP servers

Process management:

  • Claude Code spawns and manages the process
  • Communicates via stdin/stdout
  • Terminates when Claude Code exits

SSE (Server-Sent Events)

Connect to hosted MCP servers with OAuth support. Best for cloud services.

Configuration:

{
  "asana": {
    "type": "sse",
    "url": "https://mcp.asana.com/sse"
  }
}

Use cases:

  • Official hosted MCP servers (Asana, GitHub, etc.)
  • Cloud services with MCP endpoints
  • OAuth-based authentication
  • No local installation needed

Authentication:

  • OAuth flows handled automatically
  • User prompted on first use
  • Tokens managed by Claude Code

HTTP (REST API)

Connect to RESTful MCP servers with token authentication.

Configuration:

{
  "api-service": {
    "type": "http",
    "url": "https://api.example.com/mcp",
    "headers": {
      "Authorization": "Bearer ${API_TOKEN}",
      "X-Custom-Header": "value"
    }
  }
}

Use cases:

  • REST API-based MCP servers
  • Token-based authentication
  • Custom API backends
  • Stateless interactions

WebSocket (Real-time)

Connect to WebSocket MCP servers for real-time bidirectional communication.

Configuration:

{
  "realtime-service": {
    "type": "ws",
    "url": "wss://mcp.example.com/ws",
    "headers": {
      "Authorization": "Bearer ${TOKEN}"
    }
  }
}

Use cases:

  • Real-time data streaming
  • Persistent connections
  • Push notifications from server
  • Low-latency requirements

Environment Variable Expansion

All MCP configurations support environment variable substitution:

${CLAUDE_PLUGIN_ROOT} - Plugin directory (always use for portability):

{
  "command": "${CLAUDE_PLUGIN_ROOT}/servers/my-server"
}

User environment variables - From user's shell:

{
  "env": {
    "API_KEY": "${MY_API_KEY}",
    "DATABASE_URL": "${DB_URL}"
  }
}

Best practice: Document all required environment variables in plugin README.

MCP Tool Naming

When MCP servers provide tools, they're automatically prefixed:

Format: mcp__plugin_<plugin-name>_<server-name>__<tool-name>

Example:

  • Plugin: asana
  • Server: asana
  • Tool: create_task
  • Full name: mcp__plugin_asana_asana__asana_create_task

Using MCP Tools in Commands

Pre-allow specific MCP tools in command frontmatter:

---
allowed-tools: [
  "mcp__plugin_asana_asana__asana_create_task",
  "mcp__plugin_asana_asana__asana_search_tasks"
]
---

Wildcard (use sparingly):

---
allowed-tools: ["mcp__plugin_asana_asana__*"]
---

Best practice: Pre-allow specific tools, not wildcards, for security.

Lifecycle Management

Automatic startup:

  • MCP servers start when plugin enables
  • Connection established before first tool use
  • Restart required for configuration changes

Lifecycle:

  1. Plugin loads
  2. MCP configuration parsed
  3. Server process started (stdio) or connection established (SSE/HTTP/WS)
  4. Tools discovered and registered
  5. Tools available as mcp__plugin_...__...

Viewing servers: Use /mcp command to see all servers including plugin-provided ones.

Authentication Patterns

OAuth (SSE/HTTP)

OAuth handled automatically by Claude Code:

{
  "type": "sse",
  "url": "https://mcp.example.com/sse"
}

User authenticates in browser on first use. No additional configuration needed.

Token-Based (Headers)

Static or environment variable tokens:

{
  "type": "http",
  "url": "https://api.example.com",
  "headers": {
    "Authorization": "Bearer ${API_TOKEN}"
  }
}

Document required environment variables in README.

Environment Variables (stdio)

Pass configuration to MCP server:

{
  "command": "python",
  "args": ["-m", "my_mcp_server"],
  "env": {
    "DATABASE_URL": "${DB_URL}",
    "API_KEY": "${API_KEY}",
    "LOG_LEVEL": "info"
  }
}

Integration Patterns

Pattern 1: Simple Tool Wrapper

Commands use MCP tools with user interaction:

# Command: create-item.md
---
allowed-tools: ["mcp__plugin_name_server__create_item"]
---

Steps:
1. Gather item details from user
2. Use mcp__plugin_name_server__create_item
3. Confirm creation

Use for: Adding validation or preprocessing before MCP calls.

Pattern 2: Autonomous Agent

Agents use MCP tools autonomously:

# Agent: data-analyzer.md

Analysis Process:
1. Query data via mcp__plugin_db_server__query
2. Process and analyze results
3. Generate insights report

Use for: Multi-step MCP workflows without user interaction.

Pattern 3: Multi-Server Plugin

Integrate multiple MCP servers:

{
  "github": {
    "type": "sse",
    "url": "https://mcp.github.com/sse"
  },
  "jira": {
    "type": "sse",
    "url": "https://mcp.jira.com/sse"
  }
}

Use for: Workflows spanning multiple services.

Security Best Practices

Use HTTPS/WSS

Always use secure connections:

✅ "url": "https://mcp.example.com/sse"
❌ "url": "http://mcp.example.com/sse"

Token Management

DO:

  • ✅ Use environment variables for tokens
  • ✅ Document required env vars in README
  • ✅ Let OAuth flow handle authentication

DON'T:

  • ❌ Hardcode tokens in configuration
  • ❌ Commit tokens to git
  • ❌ Share tokens in documentation

Permission Scoping

Pre-allow only necessary MCP tools:

✅ allowed-tools: [
  "mcp__plugin_api_server__read_data",
  "mcp__plugin_api_server__create_item"
]

❌ allowed-tools: ["mcp__plugin_api_server__*"]

Error Handling

Connection Failures

Handle MCP server unavailability:

  • Provide fallback behavior in commands
  • Inform user of connection issues
  • Check server URL and configuration

Tool Call Errors

Handle failed MCP operations:

  • Validate inputs before calling MCP tools
  • Provide clear error messages
  • Check rate limiting and quotas

Configuration Errors

Validate MCP configuration:

  • Test server connectivity during development
  • Validate JSON syntax
  • Check required environment variables

Performance Considerations

Lazy Loading

MCP servers connect on-demand:

  • Not all servers connect at startup
  • First tool use triggers connection
  • Connection pooling managed automatically

Batching

Batch similar requests when possible:

# Good: Single query with filters
tasks = search_tasks(project="X", assignee="me", limit=50)

# Avoid: Many individual queries
for id in task_ids:
    task = get_task(id)

Testing MCP Integration

Local Testing

  1. Configure MCP server in .mcp.json
  2. Install plugin locally (.claude-plugin/)
  3. Run /mcp to verify server appears
  4. Test tool calls in commands
  5. Check claude --debug logs for connection issues

Validation Checklist

  • [ ] MCP configuration is valid JSON
  • [ ] Server URL is correct and accessible
  • [ ] Required environment variables documented
  • [ ] Tools appear in /mcp output
  • [ ] Authentication works (OAuth or tokens)
  • [ ] Tool calls succeed from commands
  • [ ] Error cases handled gracefully

Debugging

Enable Debug Logging

claude --debug

Look for:

  • MCP server connection attempts
  • Tool discovery logs
  • Authentication flows
  • Tool call errors

Common Issues

Server not connecting:

  • Check URL is correct
  • Verify server is running (stdio)
  • Check network connectivity
  • Review authentication configuration

Tools not available:

  • Verify server connected successfully
  • Check tool names match exactly
  • Run /mcp to see available tools
  • Restart Claude Code after config changes

Authentication failing:

  • Clear cached auth tokens
  • Re-authenticate
  • Check token scopes and permissions
  • Verify environment variables set

Quick Reference

MCP Server Types

Type Transport Best For Auth
stdio Process Local tools, custom servers Env vars
SSE HTTP Hosted services, cloud APIs OAuth
HTTP REST API backends, token auth Tokens
ws WebSocket Real-time, streaming Tokens

Configuration Checklist

  • [ ] Server type specified (stdio/SSE/HTTP/ws)
  • [ ] Type-specific fields complete (command or url)
  • [ ] Authentication configured
  • [ ] Environment variables documented
  • [ ] HTTPS/WSS used (not HTTP/WS)
  • [ ] ${CLAUDE_PLUGIN_ROOT} used for paths

Best Practices

DO:

  • ✅ Use ${CLAUDE_PLUGIN_ROOT} for portable paths
  • ✅ Document required environment variables
  • ✅ Use secure connections (HTTPS/WSS)
  • ✅ Pre-allow specific MCP tools in commands
  • ✅ Test MCP integration before publishing
  • ✅ Handle connection and tool errors gracefully

DON'T:

  • ❌ Hardcode absolute paths
  • ❌ Commit credentials to git
  • ❌ Use HTTP instead of HTTPS
  • ❌ Pre-allow all tools with wildcards
  • ❌ Skip error handling
  • ❌ Forget to document setup

Additional Resources

Reference Files

For detailed information, consult:

  • references/server-types.md - Deep dive on each server type
  • references/authentication.md - Authentication patterns and OAuth
  • references/tool-usage.md - Using MCP tools in commands and agents

Example Configurations

Working examples in examples/:

  • stdio-server.json - Local stdio MCP server
  • sse-server.json - Hosted SSE server with OAuth
  • http-server.json - REST API with token auth

External Resources

Implementation Workflow

To add MCP integration to a plugin:

  1. Choose MCP server type (stdio, SSE, HTTP, ws)
  2. Create .mcp.json at plugin root with configuration
  3. Use ${CLAUDE_PLUGIN_ROOT} for all file references
  4. Document required environment variables in README
  5. Test locally with /mcp command
  6. Pre-allow MCP tools in relevant commands
  7. Handle authentication (OAuth or tokens)
  8. Test error cases (connection failures, auth errors)
  9. Document MCP integration in plugin README

Focus on stdio for custom/local servers, SSE for hosted services with OAuth.

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。