ping
Checks if the Redis server is reachable and responsive by sending a simple connectivity test.
Instructions
测试Redis连接是否正常
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/redis_mcp_server/server.py:36-43 (handler)The MCP tool handler for 'ping'. Decorated with @mcp.tool(), it calls db.ping() and returns the result as JSON.
@mcp.tool() def ping() -> str: """测试Redis连接是否正常""" try: result = db.ping() return json.dumps(result, ensure_ascii=False, indent=2) except Exception as e: return json.dumps({"error": str(e)}, ensure_ascii=False) - src/redis_mcp_server/db.py:73-76 (helper)The RedisConnection.ping() helper that executes the actual Redis PING command and returns connection status.
def ping(self) -> dict[str, Any]: """测试Redis连接""" result = self._client.ping() return {"connected": result, "host": self.config.host, "port": self.config.port} - src/redis_mcp_server/server.py:36-37 (registration)The tool is registered via @mcp.tool() decorator on the ping() function in server.py.
@mcp.tool() def ping() -> str: - src/redis_mcp_server/server.py:37-38 (schema)The ping tool takes no arguments and returns a string. No Pydantic schema is needed since it has no parameters.
def ping() -> str: """测试Redis连接是否正常"""