Back to Skills

configure-mcp-server

pjt222
Updated 2 days ago
9 views
17
2
17
View on GitHub
Developmentaimcp

About

This skill configures MCP servers for Claude Code and Claude Desktop, handling setup for mcptools, Hugging Face integration, and WSL path processing. Use it when connecting Claude Code to R via mcptools, adding remote MCP servers, or troubleshooting MCP connections between clients and servers. It supports multi-client configurations and provides essential setup guidance for developers.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/configure-mcp-server

Copy and paste this command in Claude Code to install this skill

Documentation

MCPサーバーの設定

Claude Code(WSL)とClaude Desktop(Windows)用のMCPサーバー接続をセットアップする。

使用タイミング

  • Claude Codeをmcptools経由でRに接続する時
  • Claude DesktopにMCPサーバーを設定する時
  • Hugging Faceやその他のリモートMCPサーバーを追加する時
  • ツール間のMCP接続のトラブルシューティング時

入力

  • 必須: MCPサーバータイプ(mcptools、Hugging Face、カスタム)
  • 必須: クライアント(Claude Code、Claude Desktop、または両方)
  • 任意: 認証トークン
  • 任意: カスタムサーバー実装

手順

ステップ1: MCPサーバーパッケージのインストール

R(mcptools)の場合:

install.packages("remotes")
remotes::install_github("posit-dev/mcptools")

Hugging Faceの場合:

npm install -g mcp-remote

期待結果: mcptoolsがGitHubからインストールされ、Rでエラーなくロードされる。mcp-remotewhich mcp-remoteまたはnpm list -g mcp-remoteでグローバルに利用可能。

失敗時: mcptoolsの場合、まずremotesがインストールされていることを確認する。GitHubがインストールをレート制限する場合、~/.RenvironGITHUB_PATを設定する。mcp-remoteの場合、Node.jsとnpmがインストールされPATHに含まれていることを確認する。

ステップ2: Claude Code(WSL)の設定

R mcptoolsサーバー:

claude mcp add r-mcptools stdio \
  "/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe" \
  -- -e "mcptools::mcp_server()"

Hugging Faceサーバー:

claude mcp add hf-mcp-server \
  -e HF_TOKEN=your_token_here \
  -- mcp-remote https://huggingface.co/mcp

設定の確認:

claude mcp list
claude mcp get r-mcptools

期待結果: claude mcp listr-mcptoolshf-mcp-server(または追加したサーバー)が表示される。claude mcp get r-mcptoolsで正しいコマンドと引数が表示される。

失敗時: サーバーがリストに表示されない場合、~/.claude.jsonに正しいエントリが含まれているか確認する。claudeコマンドが見つからない場合、PATHに追加する:export PATH="$HOME/.claude/local/node_modules/.bin:$PATH"

ステップ3: Claude Desktop(Windows)の設定

%APPDATA%\Claude\claude_desktop_config.jsonを編集する:

{
  "mcpServers": {
    "r-mcptools": {
      "command": "C:\\PROGRA~1\\R\\R-45~1.0\\bin\\x64\\Rscript.exe",
      "args": ["-e", "mcptools::mcp_server()"]
    },
    "hf-mcp-server": {
      "command": "mcp-remote",
      "args": ["https://huggingface.co/mcp"],
      "env": {
        "HF_TOKEN": "your_token_here"
      }
    }
  }
}

重要: スペースを含むWindowsディレクトリには8.3短縮パスを使用する(Program FilesではなくPROGRA~1)。トークンには--header引数ではなく環境変数を使用する。

期待結果: %APPDATA%\Claude\claude_desktop_config.jsonのJSON設定ファイルが正しいサーバーエントリを持つ有効なJSON。再起動後にClaude DesktopがMCPサーバーインジケータを表示する。

失敗時: リンターでJSONを検証する(例:jq . < config.json)。Windowsパスのスペースがパースエラーを引き起こす場合は8.3短縮パス(PROGRA~1)を使用する。Claude Desktopが完全に再起動されていることを確認する(最小化だけでなく)。

ステップ4: MCP用のRセッション設定

プロジェクトの.Rprofileに追加する:

if (requireNamespace("mcptools", quietly = TRUE)) {
  mcptools::mcp_session()
}

これにより、RStudioでプロジェクトを開いた時にMCPセッションが自動的に開始される。

期待結果: .RprofileファイルがRStudioでプロジェクトを開いた時に条件付きでmcptools::mcp_session()を開始し、MCPツールが自動的に利用可能になる。

失敗時: セッション開始時にmcptoolsが見つからない場合、RStudioが使用するライブラリにインストールされているか確認する(.libPaths()を確認)。renvを使用している場合、mcptoolsがrenvライブラリにあることを確認する。

ステップ5: 接続の確認

WSLからのR MCPテスト:

"/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe" -e "mcptools::mcp_server()"

Claude Code内からのテスト:

Claude Codeを起動してMCPツールを使用する — ツールリストに表示されるはず。

Claude Desktopのテスト:

設定変更後にClaude Desktopを再起動する。UIでMCPサーバーインジケータを確認する。

期待結果: mcptools::mcp_server()でRscriptを実行するとエラーなく出力される。アクティブセッション中にClaude CodeのツールリストにMCPツールが表示される。再起動後にClaude Desktopがサーバーステータスを表示する。

失敗時: Rscriptコマンドが失敗する場合、フルパスが正しいか確認する(ls "/mnt/c/Program Files/R/"でRバージョンを確認)。Claude Codeにツールが表示されない場合、セッションを再起動する。Claude Desktopの場合、ファイアウォール設定を確認する。

ステップ6: マルチサーバー設定

Claude CodeとClaude Desktopは複数のMCPサーバーを同時にサポートする:

# Claude Code: 複数のサーバーを追加
claude mcp add r-mcptools stdio "/path/to/Rscript.exe" -- -e "mcptools::mcp_server()"
claude mcp add hf-mcp-server -e HF_TOKEN=token -- mcp-remote https://huggingface.co/mcp
claude mcp add custom-server stdio "/path/to/server" -- --port 3001

期待結果: 複数のMCPサーバーが設定され同時にアクセス可能。claude mcp listですべてのサーバーが表示される。各サーバーのツールが同じClaude Codeセッションで利用可能。

失敗時: サーバーが競合する場合、設定で各サーバーが一意の名前を持っていることを確認する。あるサーバーが他をブロックする場合、サーバーがノンブロッキングI/Oを使用していることを確認する(stdioトランスポートはこれを自動的に処理する)。

バリデーション

  • claude mcp listですべての設定済みサーバーが表示される
  • R MCPサーバーがツール呼び出しに応答する
  • Hugging Face MCPサーバーが認証し応答する
  • Claude CodeとClaude Desktopの両方が接続できる(両方設定した場合)
  • セッション中にツールリストにMCPツールが表示される

よくある落とし穴

  • Windowsパスのスペース: 8.3短縮名を使用するか、パスを正しくクォートする。ツールによってパスのパース方法が異なる
  • コマンド引数にトークン: Windowsでは--header "Authorization: Bearer token"がパースの問題で失敗する。代わりに環境変数を使用する
  • Claude CodeとClaude Desktopの設定の混同: これらは別々のツールで別々の設定ファイルを持つ(~/.claude.json vs %APPDATA%\Claude\
  • npx vs グローバルインストール: npx mcp-remoteはClaude Desktopのコンテキストで失敗する可能性がある。npm install -g mcp-remoteでグローバルにインストールする
  • mcptoolsのバージョン: mcptoolsが最新であることを確認する。依存関係としてellmerパッケージが必要

関連スキル

  • build-custom-mcp-server -- 独自のMCPサーバーの作成
  • troubleshoot-mcp-connection -- 接続問題のデバッグ
  • setup-wsl-dev-environment -- WSLセットアップの前提条件

GitHub Repository

pjt222/agent-almanac
Path: i18n/ja/skills/configure-mcp-server
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

qmd

Development

qmd is a local search and indexing CLI tool that enables developers to index and search through local files using hybrid search combining BM25, vector embeddings, and reranking. It supports both command-line usage and MCP (Model Context Protocol) mode for integration with Claude. The tool uses Ollama for embeddings and stores indexes locally, making it ideal for searching documentation or codebases directly from the terminal.

View skill

subagent-driven-development

Development

This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.

View skill

mcporter

Development

The mcporter skill enables developers to manage and call Model Context Protocol (MCP) servers directly from Claude. It provides commands to list available servers, call their tools with arguments, and handle authentication and daemon lifecycle. Use this skill for integrating and testing MCP server functionality in your development workflow.

View skill

adk-deployment-specialist

Development

This skill deploys and orchestrates Vertex AI ADK agents using A2A protocol, managing AgentCard discovery, task submission, and supporting tools like Code Execution Sandbox and Memory Bank. It enables building multi-agent systems with sequential, parallel, or loop orchestration patterns in Python, Java, or Go. Use it when asked to deploy ADK agents or orchestrate agent workflows on Google Cloud.

View skill