Skip to main content
Glama
Nicolas-One

Redis CRUD MCP Server

by Nicolas-One

redis_get

Retrieve a value from Redis by specifying a key. This tool fetches the stored data associated with the key, allowing access to the value.

Instructions

获取键值。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes

Implementation Reference

  • src/index.ts:165-177 (registration)
    Tool registration for 'redis_get' in the ListToolsRequestSchema handler, defining its name, description, and input schema (type: object, required: ['key'] with a string property 'key').
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        { name: "redis_set", description: "设置键值。自动读取项目 .env 配置连接 Redis。", inputSchema: { type: "object", properties: { key: { type: "string" }, value: { type: "string" } }, required: ["key", "value"] } },
        { name: "redis_get", description: "获取键值。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } },
        { name: "redis_del", description: "删除键。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } },
        { name: "redis_exists", description: "检查键是否存在。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } },
        { name: "redis_info", description: "获取连接信息。", inputSchema: { type: "object", properties: {} } },
        { name: "redis_hset", description: "设置哈希字段。", inputSchema: { type: "object", properties: { key: { type: "string" }, field: { type: "string" }, value: { type: "string" } }, required: ["key", "field", "value"] } },
        { name: "redis_hget", description: "获取哈希字段。", inputSchema: { type: "object", properties: { key: { type: "string" }, field: { type: "string" } }, required: ["key", "field"] } },
        { name: "redis_hgetall", description: "获取哈希所有字段。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } },
        { name: "redis_hdel", description: "删除哈希字段。", inputSchema: { type: "object", properties: { key: { type: "string" }, fields: { type: "array", items: { type: "string" } } }, required: ["key", "fields"] } }
      ]
    }));
  • Handler function for 'redis_get': calls client.get(args.key) and returns a success message with the retrieved value (or 'null').
    redis_get: async () => { const r = await client.get(args.key); return `GET 成功。键: ${args.key}, 值: ${r ?? 'null'}`; },
  • Input schema for 'redis_get': JSON Schema with type 'object', properties { key: { type: 'string' } }, required: ['key'].
    { name: "redis_get", description: "获取键值。", inputSchema: { type: "object", properties: { key: { type: "string" } }, required: ["key"] } },
  • Helper function getClient() that establishes and caches a Redis connection per project directory, used by the redis_get handler.
    async function getClient(projectDir: string): Promise<any> {
      if (clientCache.has(projectDir)) return clientCache.get(projectDir)!;
    
      const config = getRedisConfig(projectDir);
      const client = createClient({
        url: `redis://:${config.password}@${config.host}:${config.port}/${config.db}`,
        socket: { connectTimeout: OPERATION_TIMEOUT }
      });
      client.on('error', (err: any) => console.error('Redis 错误:', err));
    
      // 显式连接并带超时保护
      try {
        await withTimeout(client.connect(), OPERATION_TIMEOUT, `Redis 连接超时 (${OPERATION_TIMEOUT}ms)`);
        console.error(`Redis 连接成功 [${projectDir}] -> ${config.host}:${config.port}/${config.db}`);
      } catch (error) {
        console.error(`Redis 连接失败:`, error);
        throw error;
      }
    
      clientCache.set(projectDir, client);
      return client;
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description omits behavioral details such as what happens if the key does not exist (e.g., returns nil) or if the key is of the wrong type. The description fails to disclose any behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (one short sentence), which is efficient but at the cost of completeness. It lacks structure but is not verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has one parameter, no output schema, and no annotations, the description should cover return value, error handling, or usage context. It does none of these, making it insufficient for an agent to reliably use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description should explain the 'key' parameter. It only implies the key through the Chinese phrase, but does not clarify its format, required constraints, or behavior. Minimal added value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '获取键值' (get key value) clearly states the action and resource, but it is essentially a tautology of the tool name 'redis_get'. It does not differentiate from siblings like redis_hget or provide additional context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus siblings like redis_hget or redis_set. The description lacks any contextual cues for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nicolas-One/redis-crud-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server