> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Inspector で MCPサーバーをテストする

> MCP Inspector を使って MCPサーバーをテストする方法について説明します。

MCPサーバーをローカルで開発する際のテスト方法はいくつかあります。標準的なAIクライアントに接続する方法もありますが、その場合は基盤となるプロトコルの詳細が見えにくくなることが多く、特定のリクエストをデバッグするのが困難です。curlのようなコマンドラインツールを使う方法もありますが、複雑な認証フローを扱う場合や、JSONペイロードを手作業で作成する場合には特に手間がかかります。

そこで活躍するのが[MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector)です。MCP Inspectorはこの用途のために作られたグラフィカルツールで、両者の長所を兼ね備えています。サーバーで利用可能なツールをわかりやすく対話的なインターフェースで確認できるほか、複雑な認証も代わりに処理してくれます。さらに、自然言語のプロンプトを使わずに、特定の入力を指定してツールを直接実行できます。このように直接操作できるため、効率的なデバッグと開発に欠かせないツールとなっています。

## MCP Inspector の起動

まず、MCPサーバーが別のターミナルで起動していることを確認してください。次に、新しいターミナルウィンドウを開き、以下のコマンドを実行して MCP Inspector を起動します。

```shell theme={null}
npx @modelcontextprotocol/inspector@latest
```

これにより、既定のブラウザーで MCP Inspector のインターフェースが開きます。

![起動後の MCP Inspector の画面](https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/ai/mcp/mcp_inspector_configured.png)

## MCPサーバーに接続する

Inspectorを開いたら、ローカルのMCPサーバーに接続するよう設定します。

1. **Transport Type**を`Streamable HTTP`に設定します。
2. サーバーのURLを入力します。通常は`http://localhost:3001/mcp`です。

MCP InspectorをMCPサーバーに接続するには、静的クライアント登録 (推奨) とDynamic Client Registration (DCR) のどちらかを使用します。以下から希望する方法を選び、手順に従ってください。

**Static Client Registration**

## Create an Application to Represent Your MCP Client

Run this command to create the client:

```shell wrap lines theme={null}
auth0 api post clients --data '{
  "name": "MCP Inspector",
  "app_type": "regular_web",
  "is_first_party": false,
  "callbacks": ["http://localhost:6274/oauth/callback"],
  "grant_types": ["authorization_code"],
  "token_endpoint_auth_method": "client_secret_post",
  "oidc_conformant": true,
  "jwt_configuration": { "alg": "RS256" },
  "logo_uri": "https://avatars.githubusercontent.com/u/182288589"
}' | jq -r '"\nClient ID:     " + .client_id + "\nClient Secret: " +  .client_secret'
```

Save the `Client ID` and `Client Secret` from the command output.

In the left navigation menu, click on **Authentication** and enter the **Client ID** and **Client Secret** you obtained when you registered your application.

**Dynamic Client Registration**

## Enable Dynamic Client Registration (DCR)

Set the tenant-level flag required for Dynamic Client Registration (DCR):

```shell wrap lines theme={null}
auth0 tenant-settings update set flags.enable_dynamic_client_registration
```

Enabling `enable_dynamic_client_registration` allows MCP tools to register themselves as applications automatically through Dynamic Client Registration (DCR).

> [!WARNING]
>
> Auth0 supports Open Dynamic Registration, which means that if you enable this feature, anyone will be able to create applications in your tenant without a token. Read [Securing an Open DCR Endpoint](/ai/docs/mcp/guides/registering-your-mcp-client-application/dynamic-client-registration.md#securing-an-open-dcr-endpoint) to learn strategies to mitigate risks with Open DCR.

Your MCP server is now ready to use!

3. **Connect**をクリックします。

ログイン画面と同意画面にリダイレクトされます。ツールの使用に必要な権限が付与されたユーザーアカウントでサインインしてください。

初めてサーバーに接続する際には、[Auth0ユニバーサルログイン](https://auth0.com/features/universal-login)による認証プロセスに沿って進みます。同意画面が表示され、アクセスできるツールを確認できます。

![認証中の同意モーダル](https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/ai/mcp/consent_screen_while_logging_in.png)

**Accept**をクリックして要求された権限を付与すると、MCP Inspectorにリダイレクトされます。インターフェースにはサーバーが接続済みであることが示され、利用可能なツールの一覧が表示されます。

![実行後のMCP Inspectorページ](https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/ai/mcp/mcp_inspector_after_login.png)

## ツールを実行する

認証が完了すると、MCPサーバーがユーザーに公開しているツールを実行できます。利用できるツールは、サーバーの設定によってユーザーごとに異なる場合があります。

![Tool Administratorロールを持つユーザーのツール一覧](https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/ai/mcp/tools_list_tool_administrator_role.png)

MCPサーバーで利用可能なツールの一覧

ツールを実行するには、一覧から対象のツールをクリックし、**Run Tool**をクリックします。

![MCP InspectorでWhoAmIツールを呼び出した際のレスポンス](https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/ai/mcp/whoami_tool_call_through_mcp_inspector.png)

## よくある問題のトラブルシューティング

問題が発生した場合は、まず以下の点を確認してください。

### 接続に失敗した場合:

* MCPサーバーが別のターミナルで起動しているか確認してください。
* Inspector で指定したURL ([http://localhost:3001/mcp](http://localhost:3001/mcp)) が、サーバーに設定されているポートとエンドポイントに一致しているか、もう一度確認してください。

### 認証エラー:

* Inspector に入力した Client ID と Client Secret が正しいこと、また余分なスペースが含まれていないことを確認してください。
* 認証プロバイダー (例: Auth0) に登録されているユーザーアカウントでログインしているか確認してください。

### ログイン後にツールが表示されない場合:

* 通常、ログインに使用したユーザーに必要なロールまたは権限が付与されていないことが原因です。
* 認証プロバイダーで、ユーザーに適切なロール(例: "Tool User" や "Tool Administrator")が割り当てられているかを確認してください。
* サーバーの OAuth 設定で定義されているスコープが、ツールに必要な権限と一致しているかを確認してください。

## まとめ

これで、MCP Inspectorの起動からセキュアなサーバーへの接続、そして最初のツールの実行まで、一連の手順をひととおり確認できました。Inspectorを開発ワークフローに組み込めば、本格的なAIクライアントを用意する手間をかけずに、実装のテストやセキュリティルールの検証、ツールロジックのデバッグを手軽かつ効果的に行えます。MCPを活用したアプリケーションの構築や拡張を自信を持って進めていくためにも、この欠かせないユーティリティを常に手元に置いておきましょう。
