docs: fix Claude Desktop MCP setup, CrewAI guide, and missing contributor docs (#6945)
This commit is contained in:
@@ -85,6 +85,19 @@ sign. Signing takes less than a minute and only needs to be done once. Pull
|
||||
requests from contributors who have not signed the CLA will be blocked from
|
||||
merging.
|
||||
|
||||
## First Contribution Fast Path
|
||||
|
||||
Fixing a typo or a small docs issue? You don't need the full workflow below.
|
||||
|
||||
1. **Pick something small.** Look for issues labeled `documentation` or `good first issue`, or a typo/broken link you noticed while reading the docs.
|
||||
2. **Branch from `main`** with a name that says what you're fixing, e.g. `docs/fix-quickstart-typo` or `fix/broken-crewai-link`.
|
||||
3. **Make the change, then run only what applies:**
|
||||
- Docs-only change (`docs/**`): preview with `make docs`. If you added or removed an `.mdx` page, run `python scripts/check-llms-txt-coverage.py --write` so `docs/llms.txt` stays in sync.
|
||||
- Code change: run the linter and tests for the package you touched, see [Development Workflow](#development-workflow) below.
|
||||
4. **Open a PR** against `main` with `Closes #<issue-number>` and a one-line description of what you fixed.
|
||||
|
||||
For anything larger than a docs fix or a small bug, follow the full workflow below.
|
||||
|
||||
## Repository Layout
|
||||
|
||||
The two most common contribution targets are the SDKs:
|
||||
|
||||
@@ -79,6 +79,33 @@ For detailed guidance on pull requests, refer to [GitHub's documentation](https:
|
||||
|
||||
---
|
||||
|
||||
## Installing from Source
|
||||
|
||||
If you just want to run the latest, unreleased SDK code instead of the published `mem0ai` package, for example to try out a fix before it ships, or to depend on a fork, install directly from a local clone rather than setting up the full contributor environment below.
|
||||
|
||||
### Python SDK
|
||||
|
||||
```bash
|
||||
git clone https://github.com/mem0ai/mem0.git
|
||||
cd mem0
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
This installs `mem0ai` in editable mode, so edits under `mem0/` take effect immediately without reinstalling. Add an extra if you need one, e.g. `pip install -e ".[vector-stores]"` (see `pyproject.toml` for the full list). If you are contributing to the SDK itself and need every optional dependency for the test suite, use `hatch` instead, see [Dependency Management](#dependency-management).
|
||||
|
||||
### TypeScript SDK
|
||||
|
||||
```bash
|
||||
git clone https://github.com/mem0ai/mem0.git
|
||||
cd mem0/mem0-ts
|
||||
pnpm install
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
This builds `mem0-ts/dist` (CJS + ESM). To use it from another local project, add it as a `file:` dependency pointing at `mem0-ts`, or run `pnpm link --global` inside `mem0-ts` and `pnpm link --global mem0ai` in the consuming project.
|
||||
|
||||
---
|
||||
|
||||
## Python SDK (`mem0/`)
|
||||
|
||||
### Dependency Management
|
||||
|
||||
@@ -39,6 +39,10 @@ os.environ["SERPER_API_KEY"] = "your-serper-api-key"
|
||||
client = MemoryClient()
|
||||
```
|
||||
|
||||
<Note>
|
||||
Newer versions of CrewAI removed the `memory_config={"provider": "mem0"}` shortcut on `Crew(...)` that older guides referenced. CrewAI still offers a native Mem0 path through its `ExternalMemory` API, so that option remains open; check [CrewAI's memory documentation](https://docs.crewai.com/en/concepts/memory) for the shape your version expects. This guide wires Mem0 in explicitly through `MemoryClient` instead, which keeps retrieval under your control and stays valid as CrewAI's memory API changes.
|
||||
</Note>
|
||||
|
||||
## Store User Preferences
|
||||
|
||||
Set up initial conversation and preferences storage:
|
||||
@@ -69,9 +73,21 @@ messages = [
|
||||
store_user_preferences("crew_user_1", messages)
|
||||
```
|
||||
|
||||
## Retrieve Relevant Memories
|
||||
|
||||
Look up what Mem0 already knows about the user before planning a trip, so the crew's output reflects their actual preferences:
|
||||
|
||||
```python
|
||||
def get_user_context(user_id: str, query: str) -> str:
|
||||
"""Fetch relevant memories and format them for a task description"""
|
||||
relevant_memories = client.search(query, filters={"user_id": user_id})
|
||||
memories = [m["memory"] for m in relevant_memories.get("results", [])]
|
||||
return "\n".join(f"- {memory}" for memory in memories)
|
||||
```
|
||||
|
||||
## Create CrewAI Agent
|
||||
|
||||
Define an agent with memory capabilities:
|
||||
Define an agent with search capabilities:
|
||||
|
||||
```python
|
||||
def create_travel_agent():
|
||||
@@ -83,61 +99,60 @@ def create_travel_agent():
|
||||
goal="Plan personalized travel itineraries",
|
||||
backstory="""You are a seasoned travel planner, known for your meticulous attention to detail.""",
|
||||
allow_delegation=False,
|
||||
memory=True,
|
||||
tools=[search_tool],
|
||||
)
|
||||
```
|
||||
|
||||
## Define Tasks
|
||||
|
||||
Create tasks for your agent:
|
||||
Create a task that folds the retrieved memories into its description, so the agent plans around the user's known preferences:
|
||||
|
||||
```python
|
||||
def create_planning_task(agent, destination: str):
|
||||
"""Create a travel planning task"""
|
||||
def create_planning_task(agent, destination: str, user_context: str):
|
||||
"""Create a travel planning task personalized with the user's stored preferences"""
|
||||
return Task(
|
||||
description=f"""Find places to live, eat, and visit in {destination}.""",
|
||||
expected_output=f"A detailed list of places to live, eat, and visit in {destination}.",
|
||||
description=f"""Find places to live, eat, and visit in {destination}.
|
||||
|
||||
Known preferences for this user:
|
||||
{user_context or "No stored preferences yet."}
|
||||
""",
|
||||
expected_output=f"A detailed list of places to live, eat, and visit in {destination}, tailored to the user's preferences.",
|
||||
agent=agent,
|
||||
)
|
||||
```
|
||||
|
||||
## Set Up Crew
|
||||
|
||||
Configure the crew with memory integration:
|
||||
Configure the crew. Mem0 handles persistence outside of CrewAI, so the crew itself does not need `memory=True` or a `memory_config`:
|
||||
|
||||
```python
|
||||
def setup_crew(agents: list, tasks: list):
|
||||
"""Set up a crew with Mem0 memory integration"""
|
||||
"""Set up a crew; memory is managed through Mem0, not CrewAI's memory_config"""
|
||||
return Crew(
|
||||
agents=agents,
|
||||
tasks=tasks,
|
||||
process=Process.sequential,
|
||||
memory=True,
|
||||
memory_config={
|
||||
"provider": "mem0",
|
||||
"config": {"user_id": "crew_user_1"},
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
## Main Execution Function
|
||||
|
||||
Implement the main function to run the travel planning system:
|
||||
Implement the main function to run the travel planning system: retrieve context from Mem0, run the crew, then store the new conversation back:
|
||||
|
||||
```python
|
||||
def plan_trip(destination: str, user_id: str):
|
||||
# Create agent
|
||||
travel_agent = create_travel_agent()
|
||||
|
||||
# Create task
|
||||
planning_task = create_planning_task(travel_agent, destination)
|
||||
|
||||
# Setup crew
|
||||
user_context = get_user_context(user_id, f"travel preferences for {destination}")
|
||||
planning_task = create_planning_task(travel_agent, destination, user_context)
|
||||
crew = setup_crew([travel_agent], [planning_task])
|
||||
result = crew.kickoff()
|
||||
|
||||
# Execute and return results
|
||||
return crew.kickoff()
|
||||
client.add(
|
||||
[{"role": "user", "content": f"Planned a trip to {destination}."}],
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
# Example usage
|
||||
if __name__ == "__main__":
|
||||
|
||||
+12
-19
@@ -28,11 +28,15 @@ npx mcp-add \
|
||||
--name mem0-mcp \
|
||||
--type http \
|
||||
--url "https://mcp.mem0.ai/mcp" \
|
||||
--clients "claude,claude code,cursor,windsurf,vscode,opencode"
|
||||
--clients "claude code,cursor,windsurf,vscode,opencode"
|
||||
```
|
||||
|
||||
`mcp-add` is a helper that writes the Mem0 server into each client's own MCP config file, so you do not have to edit them by hand. Name only the clients you actually use. If you would rather see the change yourself, every client's manual config is under [Client-specific setup](#client-specific-setup).
|
||||
|
||||
<Note>
|
||||
Claude Desktop is not in the list above: it rejects the `mcp-add` command. Add it through Settings instead, see [Claude Desktop](#client-specific-setup) below.
|
||||
</Note>
|
||||
|
||||
Restart each client afterwards so it picks up the new server.
|
||||
|
||||
## Signing in
|
||||
@@ -81,25 +85,14 @@ You can also configure individual clients:
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Claude Desktop">
|
||||
```bash
|
||||
npx mcp-add \
|
||||
--name mem0-mcp \
|
||||
--type http \
|
||||
--url "https://mcp.mem0.ai/mcp" \
|
||||
--clients "claude"
|
||||
```
|
||||
Claude Desktop does not support the `mcp-add` command, it rejects the server as "not a valid MCP server." Add the Mem0 server through the Settings UI instead:
|
||||
|
||||
Or manually add to your Claude Desktop configuration (`claude_desktop_config.json`):
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"mem0-mcp": {
|
||||
"type": "http",
|
||||
"url": "https://mcp.mem0.ai/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
1. Open Claude Desktop and go to **Settings > Connectors**.
|
||||
2. Click **Add custom connector**.
|
||||
3. Enter a name (for example `mem0-mcp`) and the URL `https://mcp.mem0.ai/mcp`.
|
||||
4. Save, then restart Claude Desktop.
|
||||
|
||||
The first time you use a Mem0 tool, Claude Desktop opens a browser window to sign in, see [Signing in](#signing-in).
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Claude Code">
|
||||
|
||||
Reference in New Issue
Block a user