The DiceDB MCP server implements the Model Context Protocol (MCP) to enable interactions between AI applications and DiceDB database servers. It provides a bridge for AI systems to perform database operations on DiceDB using the DiceDB Go SDK for communication.
You can download the appropriate binary for your operating system and processor architecture from the Releases page.
Prerequisites:
go install github.com/pottekkat/dicedb-mcp@latest
Get the path to the dicedb-mcp
binary:
which dicedb-mcp
Add this to your claude_desktop_config.json
for Claude Desktop or mcp.json
for Cursor:
{
"mcpServers": {
"dicedb-mcp": {
"command": "path/to/dicedb-mcp"
}
}
}
Here's how to use the dicedb-mcp
server with the OpenAI Agents SDK:
from agents import Agent, Runner, trace
from agents.mcp import MCPServer, MCPServerStdio
from dotenv import load_dotenv
import os
import openai
import asyncio
load_dotenv()
async def run(mcp_server: MCPServer, prompt: str, server_url: str):
agent = Agent(name="DiceDB MCP",
instructions=f"""You can interact with a DiceDB database
running at {server_url}, use
this for url.""",
mcp_servers=[mcp_server],)
result = await Runner.run(starting_agent=agent, input=prompt)
print(result.final_output)
async def main():
openai.api_key = os.getenv("OPENAI_API_KEY")
prompt = "Can you change the value of the 'name' key to 'Rachel Green'?"
server_url = "localhost:7379"
async with MCPServerStdio(
cache_tools_list=True,
params={"command": "path/to/dicedb-mcp", "args": [""]},
) as server:
with trace(workflow_name="DiceDB MCP"):
await run(server, prompt, server_url)
if __name__ == "__main__":
asyncio.run(main())
Pings a DiceDB server to check connectivity.
Echoes a message through the DiceDB server.
Retrieves a value from DiceDB by key.
Sets a key-value pair in DiceDB.
Deletes one or more keys from DiceDB.
Increments the integer value of a key by one.
Decrements the integer value of a key by one.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.