key_search
Search for Redis keys using pattern matching with wildcards to locate specific data entries in your database.
Instructions
查找匹配的键
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"pattern": "<pattern>"
},
"name": "key_search"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | 匹配模式(支持通配符 * ? []) |
Implementation Reference
- src/services/mcpService.ts:1245-1257 (handler)The handler function that implements the key_search tool. Ensures Redis connection and calls redisService.keys(pattern) to find matching keys, then returns the result as formatted text content.
private async handleKeySearch(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.keys(args.pattern); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; } - src/services/mcpService.ts:526-536 (schema)Tool specification in listTools response, defining the name, description, and input schema (pattern: string) for key_search.
{ name: 'key_search', description: '查找匹配的键', inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: '匹配模式(支持通配符 * ? [])' } }, required: ['pattern'] } }, - src/services/mcpService.ts:692-693 (registration)Dispatch case in CallToolRequestHandler switch statement that routes key_search calls to the handleKeySearch method.
case 'key_search': return await this.handleKeySearch(args);