MCP API Examples
Hello World: A Guide to the MemMachine MCP Server API
This guide provides a quick and simple way to get started with the MemMachine Model Content Protocol (MCP) Server API usingcurl
commands. It can also be found in our Quick Start Guide.
Prerequisites
First, ensure your FastAPI application is running. Open your terminal, navigate to the directory containing yourapp.py
file, and run the following command. The output should confirm that the server is listening for requests.
1
Get All Sessions
The simplest way to start is by checking for existing sessions. This is an MCP resource, which returns a list of all available sessions.Command:Expected Output:You will likely see an empty list since no sessions have been created yet.
2
Add a New Memory
This is where you’ll use an MCP tool to create your first memory episode. The Expected Output:You will receive a JSON response confirming the status. A status of
mcp_add_session_memory
tool is invoked with a POST
request to its dedicated endpoint.Command:0
indicates success.3
Search for the Memory
Now that a memory has been added, let’s use another MCP tool to find it. The Expected Output:You should see a
mcp_search_session_memory
tool is designed for this purpose.Command:200 OK
response containing the search results, including the memory episode you just added.4
Delete the Session Data
To clean up after your test, use the Expected Output:You will receive a JSON response confirming the status of the deletion. A status of
mcp_delete_session_data
tool. This is a great way to ensure your database remains clean.Command:0
indicates that the data was deleted successfully.