mcpField
M
mcp-tool-server-redis

mcp-tool-server-redis

ローカル
github.com/yhwangデータベース078 週間前に更新

mcp-tool-server-redis について

mcp-tool-server-redisは、RedisをバックエンドとするMCPサーバーです。MCPクライアント向けに、キー値の設定、取得、削除、パターン検索のツールを提供します。

主な機能

  1. 01有効期限を指定したキー値の設定
  2. 02キーによる値の取得
  3. 031つ以上のキーの削除
  4. 04パターンに一致するキーの一覧表示

活用シーン

  1. 01Redisへのアプリケーションデータの保存
  2. 02キーを指定したデータの取得
  3. 03指定したRedisキーの削除
  4. 04パターンに合うキーの検索

MCP 対応

streamable HTTPを通じて、Redisのキー値を扱う4つのツールをMCPクライアントに提供します。READMEにはDocker Composeでの起動方法が記載されています。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

mcp.json · 共通設定
{
"mcpServers": {
"tool-server-redis": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"compose"
]
}
}
}
起動コマンドdocker run -i --rm compose

ローカルサーバーにはマシン上の実行環境(Node.js 18 以上など)が必要です。設定ファイルの場所はクライアントごとに異なります。

パッケージ
ocicompose

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

mcp-tool-server-redis

Redis をバックエンドとして、キーと値のペアのデータを取得・設定するツールを提供する MCP サーバーです。

MCP サーバーの実行

docker compose を使用してサーバーを起動します。

docker compose up -d

これにより、Redis をバックエンドとする MCP サーバーが起動します。サーバーは http://localhost:3000 で利用できます。

MCP サーバーとのやり取り

オプション 1:typescript-sdk のストリーム可能な HTTP クライアント

MCP typescript-sdk リポジトリにあるシンプルなストリーム可能な HTTP クライアントを使って、MCP サーバーとやり取りできます。 https://github.com/modelcontextprotocol/typescript-sdk.git

使用方法は以下のとおりです。

git clone https://github.com/modelcontextprotocol/typescript-sdk.git
cd typescript-sdk
npm install
npx tsx src/examples/client/simpleStreamableHttp.ts

デフォルトでは、クライアントは http://localhost:3000 に接続し、次の出力が表示されます。

MCP Interactive Client
=====================
Connecting to http://localhost:3000/mcp...
Transport created with session ID: 44dff10f-89bc-4965-b280-e1df3eb56a51
Connected to MCP server

Available commands:
  connect [url]              - Connect to MCP server (default: http://localhost:3000/mcp)
  disconnect                 - Disconnect from server
  terminate-session          - Terminate the current session
  reconnect                  - Reconnect to the server
  list-tools                 - List available tools
  call-tool <name> [args]    - Call a tool with optional JSON arguments
  greet [name]               - Call the greet tool
  multi-greet [name]         - Call the multi-greet tool with notifications
  start-notifications [interval] [count] - Start periodic notifications
  list-prompts               - List available prompts
  get-prompt [name] [args]   - Get a prompt with optional JSON arguments
  list-resources             - List available resources
  help                       - Show this help
  quit                       - Exit the program

>

その後、対話型プロンプトモードになります。別の MCP サーバーに接続するには、connect [url] と入力して Enter キーを押します。

list-tools コマンドを使用すると、利用可能なすべてのツールを一覧表示できます。利用可能なツールは 4 つです。

> list-tools
Available tools:
  - set: Set a Redis key-value pair with optional expiration
  - get: Get value by key from Redis
  - delete: Delete one or more keys from Redis
  - list: List Redis keys matching a pattern

call-tool <name> コマンドを使用すると、任意の JSON 引数を指定してツールを呼び出せます。たとえば、set ツールを使用して、キーと値のペアを Redis に追加できます。

> call-tool set {"key": "this is a new key", "value": "value for the new key"}
Calling tool 'set' with args: { key: 'this is a new key', value: 'value for the new key' }
Tool result:
  Successfully set key: this is a new key

オプション2:MCP-Cli

mcp-cli コマンドラインツールを使用して、MCP サーバーとやり取りすることもできます。使用するには、次のコマンドを実行します。

npx @wong2/mcp-cli --url http://localhost:3000/mcp

これにより、ストリーム可能な HTTP 経由で MCP サーバーに接続します。利用可能なツールの一覧が表示され、JSON 引数を指定してツールを呼び出せます。たとえば、次のようになります。

$ npx @wong2/mcp-cli --url http://localhost:3000/mcp
✔ Connected, server capabilities: tools
? Pick a primitive ›
❯   tool(set) - Set a Redis key-value pair with optional expiration
    tool(get) - Get value by key from Redis
    tool(delete) - Delete one or more keys from Redis
    tool(list) - List Redis keys matching a pattern

カーソルを使って一覧を移動し、目的のプリミティブを選択できます。その後、選択したプリミティブの引数を入力するよう求められます。

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。