Implement MemGPT as REST or MCP server with Spring Boot for easy AI agent integration
This project implements a simplified and abridged version of the MemGPT research, showcasing its integration as both a REST service and an MCP server. It includes a ChatBot command line application that can interact with these mechanisms.
The MemGPT Sample MCP Server leverages Spring Boot and Spring AI to expose functionality as both a REST service and an MCP server. This implementation allows for seamless integration with various AI applications, providing a versatile platform for developing and deploying intelligent agents. By using this server, developers can integrate advanced cognitive capabilities into their applications through the Model Context Protocol (MCP), ensuring compatibility and enhanced performance.
The core-agent component is central to implementing the MemGPT concept. It defines and manages key aspects such as system prompts, tools, core memory, archival memory, and message persistence. Specifically, it handles:
Extensive APIs allow external systems (such as the restful-agent-app, memgpt-mcp-server, and simple-chat-bot-app) to interact with these core functionalities. The MemGPT Sample MCP Server supports two main interactions: via REST and through an MCP server interface.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph LR;
subgraph MemoryLayer
MemGPT::Agent[MemGPT Agent Instance]
CoreMemory[Core Memory]
ArchivalMemory[Arcival Memory]
end
subgraph ApplicationLayers
MCPClient[MCP Client]
RestServiceApp[REST Service App]
CLIChatBot[CLI Chat Bot App]
end
MCPClient --> MemGPT::Agent
RestServiceApp --> MemGPT::Agent
CLIChatBot --> MemGPT::Agent
The MemGPT Sample MCP Server is meticulously architected to facilitate seamless integration across diverse AI applications. The architecture focuses on the following key components:
MCP Client: Tools like Claude Desktop, Continue, and Cursor can integrate with this server through the Model Context Protocol (MCP). Each client supports different functionalities as detailed in the compatibility matrix below.
REST Service App & CLI Chat Bot App: These applications can communicate with the MCP Server to manage context windows and generate chat completions more efficiently.
table
|MCP Client | Resources | Tools | Prompts | Status |
|-----------------|-----------|--------|----------|------------|
|Claude Desktop | ✅ | ✅ | ✅ | Full Support|
|Continue | ✅ | ✅ | ✅ | Full Support|
|Cursor | ❌ | ✅ | ❌ | Tools Only |
Set Up Environment Variables:
export OPENAI_API_KEY=your-api-key
Build the Application:
./gradlew :restful-agent-app:build
./gradlew :memgpt-mcp-server:build
Run the MemGPT Sample MCP Server:
java -jar ./restful-agent-app/build/libs/restful-agent-app-0.0.1-SNAPSHOT.jar
java -jar ./memgpt-mcp-server/build/libs/memgpt-mcp-server-0.0.1-SNAPSHOT.jar
The server will then be ready to accept incoming transactions from the ChatBot application or any compatible client.
Imagine a knowledge worker using an advanced AI assistant that can process extensive research, draft emails, and manage complex projects. By integrating the MemGPT Sample MCP Server with their preferred device (e.g., Continue), they can benefit from:
An enterprise may deploy a chatbot that operates as customer support through a website. By integrating with the MemGPT Sample MCP Server, this chatbot can:
The MemGPT Sample MCP Server is designed for seamless integration with various MCP clients. For instance, the rest
and mcp
profiles in your configuration allow you to specify which server the simple-chat-bot-app
should communicate with:
# application.yaml snippet
spring.profiles.active: rest # or mcp
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
This section outlines the performance and compatibility matrix for typical use cases. The server is optimized to handle diverse interactions between AI applications, ensuring a smooth user experience.
Integration with Other MCP Clients:
Handling Complex Contextual Scenarios:
Security Best Practices?
Efficiency with Large-Dataset Archives:
Customization Options for Advanced Users:
git clone https://github.com/your-forked-repo.git
Explore our extensive documentation, developer forums, and community resources for more information on integrating the MemGPT Sample MCP Server into your projects:
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods