Adding a custom prompt to the KurrentDB MCP Server

Disclaimer: Please try the MCP Server in your development environment first.
In this part of the MCP Server series we will look at how to modify the MCP Server code to add a prompt to build applications with KurrentDB.
If you would like to watch a video of this blog post instead, check out this video:
Prepare your environment
The KurrentDB MCP Server is free and open source. You can clone the GitHub repository by calling:
git clone https://github.com/kurrent-io/mcp-server
Then, install the dependencies using pip
. Make sure you have Python 3.10 or higher installed on your machine. You can check your Python version by running python --version
or python3 --version
.
pip install "mcp[cli]"
pip install kurrentdbclient
Change the MCP Server code
You should then be all set to edit server.py
, the only code file for the MCP Server. It is barely 200 lines of code and easy to extend. There are three important decorators when building MCP Servers: @mcp.resource
, @mcp.tool
, and @mcp.prompt
.
We are going to add a new prompt to the code as follows. Copy and paste the following method and add it to your MCP Server. Alternatively, you can also check out the build_application
branch.
@mcp.prompt()
def build_application_in_python(user_prompt: str) -> str:
template = f"""
Write a Python CLI Application interface with KurrentDB based on: {user_prompt}
# Guidelines:
KurrentDB saves every state transition as events in granular streams.
Below are the steps that you need to take to build an application on KurrentDB:
- Call Sequential Thinking tool if available.
- DO NOT CREATE A UI.
- BE CONCISE & SAVE TOKENS.
- DO NOT PROVIDE A GUIDE or INSTRUCTIONS.
1. Break down the application into smaller components
2. Define how the states will change and what events will be generated
3. Define the streams that you need to read from and write to in format stream_name-unique_id.
- You can then access all streams from this category using '$ce-stream_name'.
- Do not use multiple dash - in the stream name (use a maximum of one dash -). 4. Create a projection or multiple projections for the logic of the application to build the states.
5. Test each projection and fix faulted projection. Only then create more projections.
6. Create a simple command line app to interact with the application in Python.
Sample code to read events from streams in Python:
from kurrentdbclient import KurrentDBClient, StreamState, NewEvent
from esdbclient.exceptions import NotFound
esdb_client = KurrentDBClient(
uri="esdb://localhost:2113?Tls=false"
)
events = esdb_client.get_stream(
stream_name="stream-name",
resolve_links=True,
)
Every Event has the following important attributes:
type: str
data: bytes
metadata: bytes
id: UUID
stream_name: str
stream_position: int # this is the event number
Sample code to write events to stream in Python:
from kurrentdbclient import KurrentDBClient, StreamState, NewEvent
from kurrentdbclient.exceptions import NotFoundError
import json
kdb_client = KurrentDBClient(
uri="esdb://localhost:2113?Tls=false"
)
event = NewEvent(
type="flight details",
data=bytes(json.dumps(flight), 'utf-8'),
content_type='application/json',
metadata=bytes(json.dumps(metadata), 'utf-8')
)
kdb_client.append_to_stream(
stream_name="flights",
events=[event],
current_version=StreamState.ANY
)
--- end of sample code ---
7. FIX ANY FAULTED PROJECTIONS.
"""
return template
Let’s take a quick look at the code. We are providing the MCP Client (Claude Desktop or VS Code Copilot and so) with guidelines on how to build a Python application. There are not only stream name formats given but also sample code to read and write to KurrentDB.

If you look closely you will also notice that we are asking for a tool call to Sequential Thinking if available. This is another MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process. It works well on complex problems.
Use the MCP Server
Provide Claude Desktop with a prompt and watch the KurrentDB MCP Server build and debug an application.

You can also read the MCP Server Introduction blog post where you find some example prompts and their output.