Runnable examples connect popular Python agent frameworks to the installed LongMemory CLI through each framework's native MCP client.
| Framework | Native integration |
|---|---|
| CrewAI | Agent.mcps with MCPServerStdio |
| AutoGen | McpWorkbench with StdioServerParams |
| LangGraph/LangChain | MultiServerMCPClient tools passed to create_agent |
| OpenAI Agents SDK | MCPServerStdio attached through Agent.mcp_servers |
| PydanticAI | MCPToolset backed by FastMCP StdioTransport |
Install and initialize the LongMemory CLI first. Then create an isolated Python environment inside the chosen example directory:
cd integrations/frameworks/crewai
py -3.11 -m venv .venv
.\.venv\Scripts\python -m pip install -r requirements.txt
.\.venv\Scripts\python main.pyUse the same steps for autogen, langgraph, openai-agents, or pydantic-ai.
Each example accepts:
LONGMEMORY_COMMAND: override the LongMemory executable; defaults tolongmemory.cmdon Windows andlongmemoryelsewhere.LONGMEMORY_MODEL: override the framework-specific model identifier.LONGMEMORY_TASK: replace the default project-context request.
The model provider's own credentials are still required by the selected framework. No credential belongs in these files.
The examples use local stdio so the framework owns the LongMemory subprocess lifecycle. For a hosted or multi-user deployment, use the framework's Streamable HTTP MCP class with longmemory serve --mcp-http, bearer authentication, and a server-bound tenant, user, project, agent, and framework identity. Never derive those identities from model-generated tool arguments.