Claude
Skills
Sign in
Back

mcp-integration

Included with Lifetime
$97 forever

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", discusses MCP server types (SSE, stdio, HTTP, WebSocket), or asks to "find MCP server", "discover MCP servers", "what MCP servers exist", "recommend MCP server for [service]", "MCP prompts", "MCP prompts as commands", "tool search", "tool search threshold", "claude mcp serve", "allowedMcpServers", "deniedMcpServers", "managed MCP". Provides comprehensive guidance for integrating Model Context Protocol servers into Claude Code plugins for external tool and service integration.

AI Agents

What this skill does


# 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:

```json
{
  "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:

```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 Scope System

MCP server configurations follow scope precedence: Local > Project > User.

| Scope   | Storage                        | Sharing              | Best For                           |
| ------- | ------------------------------ | -------------------- | ---------------------------------- |
| Local   | `~/.claude.json` (project path) | Private, current project | Experimental, sensitive credentials |
| Project | `.mcp.json` in project root    | Via version control  | Team-shared, project-specific      |
| User    | `~/.claude.json` (global)      | All projects         | Personal utilities, cross-project  |

Plugin-bundled MCP servers (via `.mcp.json` or inline in `plugin.json`) auto-start when the plugin is enabled. They interact with user/project MCP configs — if a user has a server with the same name, scope precedence determines which loads.

## Discovering MCP Servers

Find existing MCP servers for your plugin using PulseMCP, the comprehensive MCP server directory with 6,800+ servers.

**Discovery workflow:**

1. Search PulseMCP using Tavily extract on `https://www.pulsemcp.com/servers?q=[keyword]`
2. Evaluate results by classification (official vs community), popularity, and relevance
3. Fetch detail pages for GitHub links and configuration examples
4. Generate `.mcp.json` configuration based on server type

**See `references/server-discovery.md`** for detailed search instructions, URL patterns, and curated server recommendations by category.

## MCP Server Types

### stdio (Local Process)

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

**Configuration:**

```json
{
  "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:**

```json
{
  "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:**

```json
{
  "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:**

```json
{
  "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):

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

**User environment variables** - From user's shell:

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

Env vars support fallback values: `${VAR:-default_value}`. If `VAR` is unset, `default_value` is used. Supported in `command`, `args`, `env`, `url`, and `headers` fields.

**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`

## MCP Resources

MCP servers can expose resources that Claude can access using the `@` syntax:

### Resource Syntax

```
@server-name:protocol://path
```

**Examples:**

```
@filesystem:file:///Users/me/project/README.md
@database:postgres://localhost/mydb/users
@github:https://github.com/user/repo
```

### Using Resources in Prompts

Reference resources directly in your prompts:

```
Look at @filesystem:file:///path/to/config.json and suggest improvements
```

Claude will fetch the resource content and include it in context.

### Resource Types

- **file://** - Local file system paths
- **https://** - HTTP resources
- **Custom protocols** - Server-specific (postgres://, s3://, etc.)

## MCP Prompts as Commands

MCP servers can expose **prompts** that appear as slash commands in Claude Code:

**Format:** `/mcp__servername__promptname`

**Example:**

- Server `github` exposes prompt `create-pr`
- Available as: `/mcp__github__create-pr`

MCP prompts appear alongside regular commands in the `/` menu. They accept arguments and execute the server's prompt template with Claude. This enables MCP servers to provide guided workflows beyond simple tool calls.

**Plugin design note:** If your MCP server exposes prompts, document their names and expected arguments in your plugin README so users can discover them.

**Plugin-provided MCP prompts:** If your plugin bundles an MCP server, that server can expose prompts that automatically become slash commands for users. This provides guided workflows beyond simple tool calls — for example, a `/mcp__myserver__setup-project` prompt that walks users through project configuration.

## Tool Search

For MCP servers with many tools, use Tool Search to find relevant tools:

**When to use:**

- Server provides 10+ tools
- You don't know exact tool names
- Exploring server capabilities

**How it works:**

1. Claude Code indexes MCP tool names and descriptions
2. Search by natural language or partial names
3. Get filtered list of matching tools

### Auto-Enable Behavior

Tool Search activates automatically when MCP servers collectively provide more tools than fit efficiently in Claude's context window (default threshold: 10% of context). Instead of loading all tool descriptions upfront, Claude searc

Related in AI Agents