docs: Sync all documentation with Claude Code February 2026 features
Update 23 files across all 10 tutorial directories and 7 reference documents to match the latest Claude Code v2.1+ features and correct outdated content including model names (4.5→4.6), permission modes, hook events, CLI syntax, MCP config paths, plugin manifest format, checkpoint commands, session management, and URLs. Add documentation for new features: Auto Memory, Remote Control, Web Sessions, Desktop App, Agent Teams, MCP OAuth, Task List, Sandboxing, and more.
This commit is contained in:
194
05-mcp/README.md
194
05-mcp/README.md
@@ -35,6 +35,10 @@ graph TB
|
||||
B -->|Action| C
|
||||
C -->|Result| B
|
||||
B -->|Response| A
|
||||
|
||||
style A fill:#e1f5fe,stroke:#333,color:#333
|
||||
style B fill:#f3e5f5,stroke:#333,color:#333
|
||||
style C fill:#e8f5e9,stroke:#333,color:#333
|
||||
```
|
||||
|
||||
## MCP Ecosystem
|
||||
@@ -52,6 +56,18 @@ graph TB
|
||||
D -->|Query| I["PostgreSQL/MySQL"]
|
||||
E -->|Messages| J["Slack Workspace"]
|
||||
F -->|Docs| K["Google Drive"]
|
||||
|
||||
style A fill:#e1f5fe,stroke:#333,color:#333
|
||||
style B fill:#f3e5f5,stroke:#333,color:#333
|
||||
style C fill:#f3e5f5,stroke:#333,color:#333
|
||||
style D fill:#f3e5f5,stroke:#333,color:#333
|
||||
style E fill:#f3e5f5,stroke:#333,color:#333
|
||||
style F fill:#f3e5f5,stroke:#333,color:#333
|
||||
style G fill:#e8f5e9,stroke:#333,color:#333
|
||||
style H fill:#e8f5e9,stroke:#333,color:#333
|
||||
style I fill:#e8f5e9,stroke:#333,color:#333
|
||||
style J fill:#e8f5e9,stroke:#333,color:#333
|
||||
style K fill:#e8f5e9,stroke:#333,color:#333
|
||||
```
|
||||
|
||||
## MCP Installation Methods
|
||||
@@ -97,6 +113,35 @@ On native Windows (not WSL), use `cmd /c` for npx commands:
|
||||
claude mcp add --transport stdio my-server -- cmd /c npx -y @some/package
|
||||
```
|
||||
|
||||
### OAuth 2.0 Authentication
|
||||
|
||||
Claude Code supports OAuth 2.0 for MCP servers that require it. When connecting to an OAuth-enabled server, Claude Code handles the entire authentication flow:
|
||||
|
||||
```bash
|
||||
# Connect to an OAuth-enabled MCP server (interactive flow)
|
||||
claude mcp add --transport http my-service https://my-service.example.com/mcp
|
||||
|
||||
# Pre-configure OAuth credentials for non-interactive setup
|
||||
claude mcp add --transport http my-service https://my-service.example.com/mcp \
|
||||
--client-id "your-client-id" \
|
||||
--client-secret "your-client-secret" \
|
||||
--callback-port 8080
|
||||
```
|
||||
|
||||
| Feature | Description |
|
||||
|---------|-------------|
|
||||
| **Interactive OAuth** | Use `/mcp` to trigger the browser-based OAuth flow |
|
||||
| **Pre-configured credentials** | `--client-id`, `--client-secret`, `--callback-port` flags for automated setup |
|
||||
| **Token storage** | Tokens are stored securely in your system keychain |
|
||||
| **Step-up auth** | Supports step-up authentication for privileged operations |
|
||||
| **Discovery caching** | OAuth discovery metadata is cached for faster reconnections |
|
||||
|
||||
### Claude.ai MCP Connectors
|
||||
|
||||
MCP servers configured in your Claude.ai account are automatically available in Claude Code. This means any MCP connections you set up through the Claude.ai web interface will be accessible without additional configuration.
|
||||
|
||||
> **Note:** This feature is only available for users logged in with Claude.ai accounts.
|
||||
|
||||
## MCP Setup Process
|
||||
|
||||
```mermaid
|
||||
@@ -117,6 +162,39 @@ sequenceDiagram
|
||||
Claude->>User: ✅ MCP connected!
|
||||
```
|
||||
|
||||
## MCP Tool Search
|
||||
|
||||
When MCP tool descriptions exceed 10% of the context window, Claude Code automatically enables tool search to efficiently select the right tools without overwhelming the model context.
|
||||
|
||||
| Setting | Value | Description |
|
||||
|---------|-------|-------------|
|
||||
| `ENABLE_TOOL_SEARCH` | `auto` (default) | Automatically enables when tool descriptions exceed 10% of context |
|
||||
| `ENABLE_TOOL_SEARCH` | `auto:<N>` | Automatically enables at a custom threshold of `N` tools |
|
||||
| `ENABLE_TOOL_SEARCH` | `true` | Always enabled regardless of tool count |
|
||||
| `ENABLE_TOOL_SEARCH` | `false` | Disabled; all tool descriptions sent in full |
|
||||
|
||||
> **Note:** Tool search requires Sonnet 4 or later, or Opus 4 or later. Haiku models are not supported for tool search.
|
||||
|
||||
## Dynamic Tool Updates
|
||||
|
||||
Claude Code supports MCP `list_changed` notifications. When an MCP server dynamically adds, removes, or modifies its available tools, Claude Code receives the update and adjusts its tool list automatically -- no reconnection or restart required.
|
||||
|
||||
## MCP Resources via @ Mentions
|
||||
|
||||
You can reference MCP resources directly in your prompts using the `@` mention syntax:
|
||||
|
||||
```
|
||||
@server-name:protocol://resource/path
|
||||
```
|
||||
|
||||
For example, to reference a specific database resource:
|
||||
|
||||
```
|
||||
@database:postgres://mydb/users
|
||||
```
|
||||
|
||||
This allows Claude to fetch and include MCP resource content inline as part of the conversation context.
|
||||
|
||||
## MCP Scopes
|
||||
|
||||
MCP configurations can be stored at different scopes with varying levels of sharing:
|
||||
@@ -188,7 +266,7 @@ claude mcp add-from-claude-desktop
|
||||
|
||||
### Example 1: GitHub MCP Configuration
|
||||
|
||||
**File:** `.claude/mcp.json`
|
||||
**File:** `.mcp.json` (project root)
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -247,12 +325,13 @@ Reviewers: @bob, @charlie
|
||||
**Setup**:
|
||||
```bash
|
||||
export GITHUB_TOKEN="your_github_token"
|
||||
cp github-mcp.json ~/.claude/mcp.json
|
||||
# Or use the CLI to add directly:
|
||||
claude mcp add --transport stdio github -- npx @modelcontextprotocol/server-github
|
||||
```
|
||||
|
||||
### Environment Variable Expansion in Configuration
|
||||
|
||||
MCP configurations support environment variable expansion with fallback defaults:
|
||||
MCP configurations support environment variable expansion with fallback defaults. The `${VAR}` and `${VAR:-default}` syntax works in the following fields: `command`, `args`, `env`, `url`, and `headers`.
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -264,6 +343,13 @@ MCP configurations support environment variable expansion with fallback defaults
|
||||
"Authorization": "Bearer ${API_KEY}",
|
||||
"X-Custom-Header": "${CUSTOM_HEADER:-default-value}"
|
||||
}
|
||||
},
|
||||
"local-server": {
|
||||
"command": "${MCP_BIN_PATH:-npx}",
|
||||
"args": ["${MCP_PACKAGE:-@company/mcp-server}"],
|
||||
"env": {
|
||||
"DB_URL": "${DATABASE_URL:-postgresql://localhost/dev}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,7 +401,8 @@ ORDER BY order_count DESC;
|
||||
**Setup**:
|
||||
```bash
|
||||
export DATABASE_URL="postgresql://user:pass@localhost/mydb"
|
||||
cp database-mcp.json ~/.claude/mcp.json
|
||||
# Or use the CLI to add directly:
|
||||
claude mcp add --transport stdio database -- npx @modelcontextprotocol/server-database
|
||||
```
|
||||
|
||||
### Example 3: Multi-MCP Workflow
|
||||
@@ -370,7 +457,7 @@ Final Output:
|
||||
export GITHUB_TOKEN="your_github_token"
|
||||
export DATABASE_URL="postgresql://user:pass@localhost/mydb"
|
||||
export SLACK_TOKEN="your_slack_token"
|
||||
cp multi-mcp.json ~/.claude/mcp.json
|
||||
# Add each MCP server via the CLI or configure them in .mcp.json
|
||||
```
|
||||
|
||||
### Example 4: Filesystem MCP Operations
|
||||
@@ -401,7 +488,8 @@ cp multi-mcp.json ~/.claude/mcp.json
|
||||
|
||||
**Setup**:
|
||||
```bash
|
||||
cp filesystem-mcp.json ~/.claude/mcp.json
|
||||
# Use the CLI to add directly:
|
||||
claude mcp add --transport stdio filesystem -- npx @modelcontextprotocol/server-filesystem /home/user/projects
|
||||
```
|
||||
|
||||
## MCP vs Memory: Decision Matrix
|
||||
@@ -417,8 +505,12 @@ graph TD
|
||||
B -->|Stores| E["Preferences<br/>Context<br/>History"]
|
||||
D -->|Accesses| F["Live APIs<br/>Databases<br/>Services"]
|
||||
|
||||
style B fill:#e1f5ff
|
||||
style D fill:#fff9c4
|
||||
style A fill:#fff3e0,stroke:#333,color:#333
|
||||
style B fill:#e1f5fe,stroke:#333,color:#333
|
||||
style C fill:#fff3e0,stroke:#333,color:#333
|
||||
style D fill:#f3e5f5,stroke:#333,color:#333
|
||||
style E fill:#e8f5e9,stroke:#333,color:#333
|
||||
style F fill:#e8f5e9,stroke:#333,color:#333
|
||||
```
|
||||
|
||||
## Request/Response Pattern
|
||||
@@ -460,19 +552,26 @@ Then reference them in MCP config:
|
||||
}
|
||||
```
|
||||
|
||||
## Claude as MCP Server
|
||||
## Claude as MCP Server (`claude mcp serve`)
|
||||
|
||||
Claude Code itself can act as an MCP server for other applications:
|
||||
Claude Code itself can act as an MCP server for other applications. This enables external tools, editors, and automation systems to leverage Claude's capabilities through the standard MCP protocol.
|
||||
|
||||
```bash
|
||||
# Start Claude Code as an MCP server on stdio
|
||||
claude mcp serve
|
||||
```
|
||||
|
||||
This starts Claude Code in MCP server mode, allowing other MCP clients to connect and use Claude's capabilities as a service.
|
||||
Other applications can then connect to this server as they would any stdio-based MCP server. For example, to add Claude Code as an MCP server in another Claude Code instance:
|
||||
|
||||
```bash
|
||||
claude mcp add --transport stdio claude-agent -- claude mcp serve
|
||||
```
|
||||
|
||||
This is useful for building multi-agent workflows where one Claude instance orchestrates another.
|
||||
|
||||
## Managed MCP Configuration (Enterprise)
|
||||
|
||||
For enterprise deployments, MCP servers can be managed centrally via configuration files:
|
||||
For enterprise deployments, IT administrators can enforce MCP server policies through the `managed-mcp.json` configuration file. This file provides exclusive control over which MCP servers are permitted or blocked organization-wide.
|
||||
|
||||
**Location:**
|
||||
- macOS: `/Library/Application Support/ClaudeCode/managed-mcp.json`
|
||||
@@ -480,16 +579,17 @@ For enterprise deployments, MCP servers can be managed centrally via configurati
|
||||
- Windows: `%APPDATA%\ClaudeCode\managed-mcp.json`
|
||||
|
||||
**Features:**
|
||||
- Allowlist/denylist controls
|
||||
- Restrict by server name, command, or URL
|
||||
- Organization-wide MCP policies
|
||||
- `allowedMcpServers` -- whitelist of permitted servers
|
||||
- `deniedMcpServers` -- blocklist of prohibited servers
|
||||
- Supports matching by server name, command, and URL patterns
|
||||
- Organization-wide MCP policies enforced before user configuration
|
||||
- Prevents unauthorized server connections
|
||||
|
||||
**Example configuration:**
|
||||
|
||||
```json
|
||||
{
|
||||
"allowlist": [
|
||||
"allowedMcpServers": [
|
||||
{
|
||||
"serverName": "github",
|
||||
"serverUrl": "https://api.github.com/mcp"
|
||||
@@ -499,14 +599,59 @@ For enterprise deployments, MCP servers can be managed centrally via configurati
|
||||
"serverCommand": "company-mcp-server"
|
||||
}
|
||||
],
|
||||
"denylist": [
|
||||
"deniedMcpServers": [
|
||||
{
|
||||
"serverName": "untrusted-*"
|
||||
},
|
||||
{
|
||||
"serverUrl": "http://*"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> **Note:** When both `allowedMcpServers` and `deniedMcpServers` match a server, the deny rule takes precedence.
|
||||
|
||||
## Plugin-Provided MCP Servers
|
||||
|
||||
Plugins can bundle their own MCP servers, making them available automatically when the plugin is installed. Plugin-provided MCP servers can be defined in two ways:
|
||||
|
||||
1. **Standalone `.mcp.json`** -- Place a `.mcp.json` file in the plugin root directory
|
||||
2. **Inline in `plugin.json`** -- Define MCP servers directly within the plugin manifest
|
||||
|
||||
Use the `${CLAUDE_PLUGIN_ROOT}` variable to reference paths relative to the plugin's installation directory:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"plugin-tools": {
|
||||
"command": "node",
|
||||
"args": ["${CLAUDE_PLUGIN_ROOT}/dist/mcp-server.js"],
|
||||
"env": {
|
||||
"CONFIG_PATH": "${CLAUDE_PLUGIN_ROOT}/config.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## MCP Output Limits
|
||||
|
||||
Claude Code enforces limits on MCP tool output to prevent context overflow:
|
||||
|
||||
| Limit | Threshold | Behavior |
|
||||
|-------|-----------|----------|
|
||||
| **Warning** | 10,000 tokens | A warning is displayed that the output is large |
|
||||
| **Default max** | 25,000 tokens | Output is truncated beyond this limit |
|
||||
| **Disk persistence** | 50,000 characters | Tool results exceeding 50K characters are persisted to disk |
|
||||
|
||||
The maximum output limit is configurable via the `MAX_MCP_OUTPUT_TOKENS` environment variable:
|
||||
|
||||
```bash
|
||||
# Increase the max output to 50,000 tokens
|
||||
export MAX_MCP_OUTPUT_TOKENS=50000
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Security Considerations
|
||||
@@ -537,7 +682,7 @@ For enterprise deployments, MCP servers can be managed centrally via configurati
|
||||
|
||||
### Configuration Best Practices
|
||||
|
||||
1. **Version Control**: Keep `.claude/mcp.json` in git but use environment variables for secrets
|
||||
1. **Version Control**: Keep `.mcp.json` in git but use environment variables for secrets
|
||||
2. **Least Privilege**: Grant minimum permissions needed for each MCP server
|
||||
3. **Isolation**: Run different MCP servers in separate processes when possible
|
||||
4. **Monitoring**: Log all MCP requests and errors for audit trails
|
||||
@@ -560,13 +705,12 @@ For enterprise deployments, MCP servers can be managed centrally via configurati
|
||||
|
||||
### Step-by-Step Setup
|
||||
|
||||
1. **Create MCP configuration file:**
|
||||
1. **Add your first MCP server** using the CLI (example: GitHub):
|
||||
```bash
|
||||
mkdir -p ~/.claude
|
||||
touch ~/.claude/mcp.json
|
||||
claude mcp add --transport stdio github -- npx @modelcontextprotocol/server-github
|
||||
```
|
||||
|
||||
2. **Add your first MCP server** (example: GitHub):
|
||||
Or create a `.mcp.json` file in your project root:
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
@@ -581,17 +725,17 @@ touch ~/.claude/mcp.json
|
||||
}
|
||||
```
|
||||
|
||||
3. **Set environment variables:**
|
||||
2. **Set environment variables:**
|
||||
```bash
|
||||
export GITHUB_TOKEN="your_github_personal_access_token"
|
||||
```
|
||||
|
||||
4. **Test the connection:**
|
||||
3. **Test the connection:**
|
||||
```bash
|
||||
claude /mcp
|
||||
```
|
||||
|
||||
5. **Use MCP tools:**
|
||||
4. **Use MCP tools:**
|
||||
```bash
|
||||
/mcp__github__list_prs
|
||||
/mcp__github__create_issue "Title" "Description"
|
||||
|
||||
Reference in New Issue
Block a user