# AIエージェント向けモデルコンテキストプロトコル (MCP) – Node版

<figure><img src="https://859776093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL6k1aGsLiFiiJ3Y7zCl%2Fuploads%2F1vQOpGnqfPVtmwIBteoi%2Fimage.png?alt=media&#x26;token=ec1c632c-3332-493c-bbe7-87ccb6eaf64e" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Keeperシークレットマネージャー (KSM) でAIエージェントとの連携機能を利用するには、ロールに「アプリケーションの作成およびシークレットの管理」の[ポリシーが設定](https://docs.keeper.io/jp/keeperpam/privileged-access-manager/getting-started/enforcement-policies)されている必要があります。
{% endhint %}

{% hint style="danger" %}
この機能を有効にすると、KeeperとサードパーティのAIツールやサービスとの連携を許可することになります。Keeperはゼロトラストアーキテクチャを維持しており、ボルト内のレコードにはアクセスせず、処理も行いません。

ただし、サードパーティのツールと共有されたデータについては、それぞれのツールのセキュリティ、プライバシー、コンプライアンスの方針が適用され、Keeperの方針は適用されません。これらの連携の設定、管理、監査は、組織の内部ポリシーや適用される法規制に従って、利用者自身の責任で行ってください。

リスクを最小限に抑えるために、AIエージェントに付与するアクセス権は、特定の事例の達成に必要な最小限のフォルダに限定するようにしてください。
{% endhint %}

## モデルコンテキストプロトコル (MCP) によるAIエージェント統合

Keeperシークレットマネージャーはモデルコンテキストプロトコル (MCP) を通じてAIエージェントと統合できます。これにより、AIエージェントがKeeperのボルト内の特定のフォルダにだけ安全にアクセスできるようになります。この仕組みは、AIエージェントにアクセスを許可する情報を明確に制限できるゼロトラスト型の設計です。

MCPは、AIアシスタントとKeeperシークレットマネージャーの間にセキュアな橋渡し役として機能します。これにより、AIがパスワードや秘密情報を使って作業を支援できるようになります。また、機密性の高い操作には人間による確認を取り入れることで、最高レベルのセキュリティ基準を維持します。

**GitHub**: <https://github.com/Keeper-Security/keeper-mcp-node>

### 主なメリット

* **ゼロトラストアーキテクチャ**: AIエージェントにはボルト内の特定フォルダのみを割り当て
* **ユーザーの承認**: 機密操作時にユーザー確認を要求
* **エンタープライズ対応**: 監査ログやコンプライアンス機能を完備
* **マルチプラットフォーム対応**: Linux、macOS、Windowsで動作

### AIアシスタントでできること

#### シークレット操作

* **シークレットの一覧表示**: アクセス可能なシークレットを確認
* **シークレットの検索**: タイトル、URL、ユーザー名などで検索
* **シークレットの取得**: 特定のシークレット値を取得 (マスク解除には確認が必要)
* **シークレットの作成**: 新しいシークレットエントリを登録
* **シークレットの更新**: 既存の情報を修正
* **シークレットの削除**: シークレットを削除 (確認あり)

#### ファイル管理

* **添付ファイルの一覧表示**: シークレットに添付されたファイルを確認
* **ファイルのアップロード**: ファイルをシークレットに添付
* **ファイルのダウンロード**: 添付ファイルを取得
* **ファイルの削除**: 添付ファイルを削除

#### ユーティリティ機能

* **パスワード生成**: 条件を指定して安全なパスワードを生成
* **TOTPコードの取得**: 現在のワンタイムパスワードを取得
* **KSM表記法の実行**: Keeper表記法を使って高度な操作を実行
* **ヘルスチェック**: サーバーの状態や接続状況を確認

### セットアップとインストール

#### 1. シークレットマネージャーアプリケーションの作成

Keeperシークレットマネージャーで、新しいアプリケーションを作成するか、既存のアプリケーションを使用します。

<figure><img src="https://859776093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL6k1aGsLiFiiJ3Y7zCl%2Fuploads%2Fx7Wjszsttq0SxWq6Skfg%2Fimage.png?alt=media&#x26;token=7288f222-d10a-4108-bff5-e9316203890c" alt=""><figcaption><p>アプリケーションを作成してフォルダへアサイン</p></figcaption></figure>

#### 2. デバイストークンの作成

最初に表示されるデバイストークンは破棄し、**\[デバイスを追加]** をクリックして、新しいBase64構成データを生成します。この構成情報は、AIエージェントに提供されます。

<figure><img src="https://859776093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL6k1aGsLiFiiJ3Y7zCl%2Fuploads%2FXewMdCcCxGBJ3QVft1jV%2Fimage.png?alt=media&#x26;token=baca8fee-ed30-4651-8100-27dde8a1469b" alt=""><figcaption><p>Base64トークンの生成</p></figcaption></figure>

#### 3. MCPサーバーを構成

#### オプションA: 構成ファイル (推奨)

以下のいずれかの場所にダウンロードした構成ファイルを配置します。

* `~/.keeper/ksm-config.json` (推奨)
* `./ksm-config.json` (カレントディレクトリ)

#### オプションB: ワンタイムトークン

ワンタイムトークンがある場合

```bash
export KSM_TOKEN="US:YOUR_ONE_TIME_TOKEN_HERE"
```

このトークンにより、サーバーが自動的に構成ファイルを生成・保存します。

#### 4. サーバーのテスト

以下のコマンドでサーバーを直接起動して動作確認します。

```bash
npm start
```

`Keeper MCP server is running` と表示されます。

### MCPクライアントとの連携例

#### Claude Desktop

Claude Desktopの構成ファイル (`~/Library/Application Support/Claude/claude_desktop_config.json`) に以下を追加します。

```json
{
  "mcpServers": {
    "keeper": {
      "command": "node",
      "args": ["/path/to/keeper-mcp-node/dist/index.js"]
    }
  }
}
```

#### Postman

1. API Networkタブに移動します。
2. MCPリクエストを作成または選択します。
3. stdio接続を以下のように設定します。
   * Command: `node`
   * Arguments: `/path/to/keeper-mcp-node/dist/index.js`

#### その他のMCP対応クライアント

stdio経由で通信するため、以下のように実行することで任意のMCP対応クライアントと連携可能です。

```bash
node /path/to/keeper-mcp-node/dist/index.js
```

## 利用可能なツール

### シークレット操作

#### `ksm_list_secrets`

アプリケーションからアクセス可能なすべてのシークレットを一覧表示します (メタデータのみ)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_list_secrets",
    "arguments": {}
  }
}
```

レスポンス

```json
[
  {
    "uid": "XXXXXXXXXXXXXXXXXXXXXX",
    "title": "My Secret",
    "type": "login"
  }
]
```

#### `ksm_get_secret`

UIDまたはタイトルを指定して、完全なシークレットを取得します (機密フィールドはデフォルトで伏字となります)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_get_secret",
    "arguments": {
      "identifier": "My Secret",
      "unmask": false
    }
  }
}
```

#### `ksm_search_secrets`

タイトル、メモ、または他のフィールド内容でシークレットを検索します。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_search_secrets",
    "arguments": {
      "query": "database"
    }
  }
}
```

#### `ksm_create_secret`

Keeperシークレットマネージャーに新しいシークレットを作成します (確認が必要)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_create_secret",
    "arguments": {
      "title": "New Database Credentials",
      "type": "login",
      "fields": {
        "login": "admin",
        "password": "secure_password",
        "url": "https://db.example.com"
      },
      "notes": "Production database",
      "folderId": "FOLDER_UID"
    }
  }
}
```

#### `ksm_update_secret`

既存のシークレットを更新します (確認が必要)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_update_secret",
    "arguments": {
      "identifier": "My Secret",
      "updates": {
        "title": "Updated Title",
        "fields": {
          "password": "new_password"
        }
      }
    }
  }
}
```

#### `ksm_delete_secret`

Keeperシークレットマネージャーからシークレットを削除します (確認が必要)

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_delete_secret",
    "arguments": {
      "identifier": "My Secret"
    }
  }
}
```

#### `ksm_get_field`

指定されたシークレットから特定のフィールド値を取得します。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_get_field",
    "arguments": {
      "identifier": "My Secret",
      "field": "password"
    }
  }
}
```

一般的なフィールド名

* `password`: パスワードフィールド
* `login`: ユーザー名またはメールアドレス
* `url`: ウェブサイトのURL

カスタムフィールドラベルにも対応しています。

### フォルダ操作

#### `ksm_list_folders`

Keeperシークレットマネージャーでアクセス可能なすべてのフォルダを一覧表示します。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_list_folders",
    "arguments": {}
  }
}
```

#### `ksm_create_folder`

新しいフォルダを作成します (確認が必要。親の共有フォルダを指定する必要があります)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_create_folder",
    "arguments": {
      "name": "Development Secrets",
      "parentFolderId": "PARENT_FOLDER_UID"
    }
  }
}
```

#### `ksm_create_folder`

新しいフォルダを作成します (確認が必要。親の共有フォルダを指定する必要があります)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_create_folder",
    "arguments": {
      "name": "Development Secrets",
      "parentFolderId": "PARENT_FOLDER_UID"
    }
  }
}
```

#### `ksm_delete_folder`

フォルダを削除します (確認が必要)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_delete_folder",
    "arguments": {
      "folderId": "FOLDER_UID",
      "force": false
    }
  }
}
```

#### `ksm_upload_file`

シークレットにファイルを添付します (確認が必要)。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_upload_file",
    "arguments": {
      "identifier": "My Secret",
      "filePath": "/path/to/certificate.pem",
      "fileName": "server-cert.pem"
    }
  }
}
```

#### `ksm_download_file`

シークレットから添付ファイルをダウンロードします。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_download_file",
    "arguments": {
      "identifier": "My Secret",
      "fileId": "certificate.pem",
      "outputPath": "/tmp/downloaded-cert.pem"
    }
  }
}
```

### ユーティリティ

#### `ksm_generate_password`

安全なパスワードを生成します。

生成したパスワードをAIに表示せずに新しいシークレットとして保存することもできます。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_generate_password",
    "arguments": {
      "length": 24,
      "includeUppercase": true,
      "includeLowercase": true,
      "includeNumbers": true,
      "includeSpecial": true,
      "saveToSecret": {
        "title": "Generated API Key",
        "login": "api-user",
        "url": "https://api.example.com",
        "notes": "Auto-generated API key"
      }
    }
  }
}
```

#### `ksm_get_totp_code`

TOTPが設定されたシークレットの現在のコードを取得します。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_get_totp_code",
    "arguments": {
      "identifier": "My 2FA Secret"
    }
  }
}
```

#### `ksm_get_server_version`

KSM MCPサーバーの現在のバージョンを取得します。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_get_server_version",
    "arguments": {}
  }
}
```

#### `ksm_health_check`

MCPサーバーとKSMとの接続状態をチェックします。

リクエスト

```json
{
  "method": "tools/call",
  "params": {
    "name": "ksm_health_check",
    "arguments": {}
  }
}
```

### トラブルシューティング

**エラー: No Keeper Secrets Manager configuration found**

* 構成ファイルがサポートされている場所にあるか確認する
* JSON形式が正しいことを確認する
* ファイルのパーミッションが適切で、ユーザーが読み取れる状態であることを確認する

**エラー: Failed to initialize KSM**

* 構成ファイルに必要な項目がすべて含まれているか確認する
* アプリケーションが対象の共有フォルダまたはシークレットにアクセス可能であることを確認する
* デバイスがKeeperで無効化されていないことを確認する

**接続に関する問題**

* インターネット接続があることを確認する
* 組織内でIP制限が設定されていないか確認する
* Keeperのサブスクリプションにシークレットマネージャーが含まれていることを確認する

***

追加のセットアップ手順については、[こちらのリポジトリ](https://github.com/Keeper-Security/keeper-mcp-node/)をご参照ください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/jp/keeperpam/secrets-manager/integrations/model-context-protocol-mcp-for-ai-agents-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
