Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

dbsize

Retrieve the total number of keys stored in a Redis database using this tool, enabling efficient data management and monitoring for Redis MCP Server users.

Instructions

Get the number of keys stored in the Redis database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The dbsize MCP tool handler function, decorated with @mcp.tool(), which gets the number of keys in the current Redis database by calling r.dbsize()
    @mcp.tool() async def dbsize() -> int: """Get the number of keys stored in the Redis database""" try: r = RedisConnectionManager.get_connection() return r.dbsize() except RedisError as e: return f"Error getting database size: {str(e)}"
  • The load_tools() function and its invocation, which dynamically imports all src.tools modules (including server_management.py), thereby registering the dbsize tool via its @mcp.tool() decorator.
    def load_tools(): import src.tools as tools_pkg for _, module_name, _ in pkgutil.iter_modules(tools_pkg.__path__): importlib.import_module(f"src.tools.{module_name}") # Initialize FastMCP server mcp = FastMCP("Redis MCP Server", dependencies=["redis", "dotenv", "numpy", "aiohttp"]) # Load tools load_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/redis/mcp-redis'

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