Redis Mcp Server For Java

Created By
6000fish6 hours ago
A stdio MCP server that connects MCP-compatible Agents to Redis for safe key/value, hash, list, set, metadata, and diagnostic operations. Part of MCP Java SDK, a Java toolkit for building custom MCP Servers.
Overview

Redis MCP Server 使用手册

中文 | English

Redis MCP Server 通过 stdio 将常用 Redis 操作暴露为 MCP 工具。

构建

mvn package -pl mcp-server-collection/mcp-server-redis -am -DskipTests

可执行 jar 生成位置:

mcp-server-collection/mcp-server-redis/target/mcp-server-redis-0.1.1.jar

配置

环境变量:

变量必填默认值说明
REDIS_HOSTlocalhostRedis 地址
REDIS_PORT6379Redis 端口
REDIS_PASSWORDRedis 密码

Agent 配置

{
  "mcpServers": {
    "redis": {
      "type": "stdio",
      "command": "java",
      "args": [
        "-jar",
        "/absolute/path/to/mcp-java/mcp-server-collection/mcp-server-redis/target/mcp-server-redis-0.1.1.jar"
      ],
      "env": {
        "REDIS_HOST": "localhost",
        "REDIS_PORT": "6379",
        "REDIS_PASSWORD": ""
      }
    }
  }
}

工具

工具说明
get(key)获取字符串键的值
set(key, value, ttl?)设置字符串键值,可选 TTL
del(keys)已注册,但默认安全策略下禁用
keys(pattern)使用窄命名空间模式查找最多 100 个键
type(key)返回 key 中存储的数据类型
ttl(key)返回 key 的 TTL 信息
hget(key, field)读取一个 hash 字段
hset(key, field, value)写入一个 hash 字段
hgetall(key)以 JSON 读取小型 hash
lrange(key, start, stop)读取有边界的 Redis list 范围
llen(key)统计 Redis list 元素数量
scard(key)统计 Redis set 成员数量
smembers(key)读取小型 Redis set
info(section)读取安全的 Redis INFO section
dbsize()统计当前 Redis 数据库中的 key 数量

示例 Prompt

Set Redis key demo:greeting to hello-mcp and read it back.
Show me the Redis server memory info.
Find keys under the demo:* namespace.

安全行为

  • del(keys) 会注册给客户端看到安全策略,但默认禁用并始终拒绝删除操作。
  • 拒绝 *、前置通配符和过短通配符前缀等宽泛 key pattern;建议使用 demo:* 这类命名空间模式。
  • keys(pattern) 最多返回 100 个 key。
  • hgetalllrangesmembers 最多读取 100 个集合元素。
  • set(key, value, ttl?) 接受 1 秒到 30 天之间的 TTL。
  • info(section) 必须指定 serverclientsmemorystatskeyspacecpu
  • 拒绝控制字符和超长 key/field;key、field 和 pattern 限制为 512 字符。

Server Config

{
  "mcpServers": {
    "redis": {
      "type": "stdio",
      "command": "java",
      "args": [
        "-jar",
        "/absolute/path/to/mcp-server-redis-0.1.1.jar"
      ],
      "env": {
        "REDIS_HOST": "localhost",
        "REDIS_PORT": "6379",
        "REDIS_PASSWORD": ""
      }
    }
  }
}
Project Info
Created At
6 hours ago
Updated At
6 hours ago
Author Name
6000fish
Star
-
Language
-
License
-
Category
Tags

Recommend Servers

View All
Tavily Mcp
@tavily-ai

JavaScript
a year ago
Meok Bs7121 Mcp

an hour ago
GovQL
@Alex Stout

# govql-mcp-server An MCP (Model Context Protocol) server for [GovQL](https://govql.us) — gives AI clients like Claude Desktop, Claude Code, and Cursor direct access to the US Congressional GraphQL API at [api.govql.us/graphql](https://api.govql.us/graphql) without bespoke HTTP wiring. For the design rationale (why FastMCP-Python, the passthrough+curated philosophy, roadmap through v0.4), see [design.md](https://github.com/govql/govql/blob/main/mcp-server/docs/design.md). ## What you can do with it Ask an agent questions like: - *"How did Vermont's two senators vote on the most recent nomination?"* - *"Which legislators in the 118th Congress switched parties during their service?"* - *"Compare Senator Sanders' voting record to Senator Murkowski's on cloture votes in the most recent Congress."* The agent picks the right tool, writes the GraphQL query against the live schema, and parses the response — no manual API wrangling. ## Install The server runs as a per-client subprocess over stdio. Pick your client: ### Claude Desktop Edit `claude_desktop_config.json` (Settings → Developer → Edit Config): ```json { "mcpServers": { "govql": { "command": "uvx", "args": ["govql-mcp-server"] } } } ``` Restart Claude Desktop. The `govql` tools appear in the tools panel. ### Claude Code Add to `.mcp.json` in your project (or `~/.mcp.json` for global): ```json { "mcpServers": { "govql": { "command": "uvx", "args": ["govql-mcp-server"] } } } ``` ### Cursor Settings → MCP → Add Server. Use the same `command` / `args` as above. ### Other clients Any MCP-compatible client that supports stdio servers will work. The command is `uvx govql-mcp-server` with no required arguments. ## Tools | Tool | Purpose | |---|---| | `execute_graphql` | Run any GraphQL query against the GovQL endpoint. Returns the result plus an `last_ingest` timestamp so the agent can reason about data freshness. | | `list_types` | Returns the names and kinds of every type in the GovQL schema. Optional `kind` filter (`"OBJECT"`, `"INPUT_OBJECT"`, `"ENUM"`, etc.) to narrow further. Start here when you don't know what's queryable. | | `describe_type` | Returns one type's full details — fields, arg signatures, input fields, enum values. Call after `list_types` to learn the shape of a specific type before writing a query. | ## Configuration All env vars are optional — the package is zero-config for end users. | Env var | Default | Purpose | |---|---|---| | `GOVQL_ENDPOINT` | `https://api.govql.us/graphql` | Endpoint to query. Override to point at a local dev stack. | | `GOVQL_TIMEOUT_MS` | `30000` | Per-request HTTP timeout. | | `LOG_LEVEL` | `INFO` | Logging level. Logs go to stderr only (stdout is reserved for the MCP transport). | ## Limits (enforced by the upstream API) - Max query depth: 10 - Max query complexity: ~10 billion points (`first: N` multiplies child cost by N — keep page sizes reasonable on deeply nested queries) - Rate limit: 100 requests / 60 s per source IP A depth or complexity violation surfaces as a GraphQL `errors` entry in the tool response so the agent can adjust and retry. ## Data freshness Every `execute_graphql` response includes a `last_ingest` ISO timestamp. Vote data refreshes hourly; legislator data refreshes daily. ## Status Version 0.1.0 ships three foundational tools: a GraphQL passthrough (`execute_graphql`) and two narrow schema-discovery tools (`list_types`, `describe_type`). Curated higher-level tools (`find_legislator`, `get_voting_record`, `compare_voters`, etc.) are planned for subsequent releases — see [design.md](https://github.com/govql/govql/blob/main/mcp-server/docs/design.md) for the roadmap. ## Links - [GovQL project site](https://govql.us) - [GraphQL API](https://api.govql.us/graphql) - [Source / issues](https://github.com/govql/govql)

15 hours ago
Voyei

2 days ago