Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Cognee
https://github.com/topoteretes/cognee
Admin
Memory for AI Agents in 5 lines of code
Tokens:
776,162
Snippets:
4,545
Trust Score:
7.8
License:
Apache-2.0
Update:
2 weeks ago
Context
Chat
Benchmark
66.27
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Run simple example Source: https://github.com/topoteretes/cognee/blob/main/CONTRIBUTING.md Run the simple cognee example. Requires .env setup and uv sync or a virtual environment. ```shell uv run python examples/guides/simple_cognee_example.py ``` -------------------------------- ### Run an example: install dev environment and configure API keys Source: https://github.com/topoteretes/cognee/blob/main/examples/README.md Commands to set up the dev environment and run any example script. Requires `uv` and a `.env` file with at least `LLM_API_KEY` set. ```bash # Install dev environment uv sync --dev --all-extras --reinstall # Configure API keys (one-time) cp .env.template .env # edit .env: set LLM_API_KEY (your OpenAI key) at minimum # Run any example uv run python examples/guides/simple_cognee_example.py ``` -------------------------------- ### Setup Commands Source: https://github.com/topoteretes/cognee/blob/main/CLAUDE.md Commands to create a virtual environment, install cognee with pip or uv, install dev dependencies, install specific extras, and set up pre-commit hooks. ```bash # Create virtual environment (recommended: uv) uv venv && source .venv/bin/activate # Install with pip or uv uv pip install -e . # Install with dev dependencies uv pip install -e ".[dev]" # Install with specific extras uv pip install -e ".[postgres,neo4j,docs]" # Set up pre-commit hooks pre-commit install ``` -------------------------------- ### One-time setup: install sbx, start daemon, login, set policy and secret Source: https://github.com/topoteretes/cognee/blob/main/examples/integrations/docker-sandbox-kit/README.md Installs the Docker sandbox kit, starts the daemon, logs in via browser OAuth, initializes a strict deny-all policy, and sets a custom secret for the OpenAI API key. The `set-custom` command prints a placeholder (`sbx-cs-…`) retrievable via `sbx secret ls`; sandboxes only see the placeholder, and the proxy substitutes the real key on requests to `api.openai.com`. ```console $ brew trust docker/tap && brew install docker/tap/sbx $ sbx daemon start # own terminal, or: nohup sbx daemon start & $ sbx login # browser OAuth $ sbx policy init deny-all # strictest baseline; the kit's allowlist is the only egress $ sbx secret set-custom --host api.openai.com --env LLM_API_KEY --value "$LLM_API_KEY" ``` -------------------------------- ### Frontend setup and development Source: https://github.com/topoteretes/cognee/blob/main/AGENTS.md Installs dependencies, runs the Next.js dev server, lints with ESLint, and builds for production. ```bash cd cognee-frontend npm install npm run dev # Next.js dev server npm run lint # ESLint npm run build && npm start ``` -------------------------------- ### Install and run frontend dev server Source: https://github.com/topoteretes/cognee/blob/main/cognee-frontend/README.md Installs frontend dependencies and starts the Next.js development server from the cognee-frontend directory. Use localhost consistently, not 127.0.0.1, in the browser because OAuth cookies and redirect origins must match. ```bash npm ci NEXT_PUBLIC_IS_CLOUD_ENVIRONMENT=false COGNEE_BACKEND_URL=http://localhost:8000 \ npm run dev -- --hostname 127.0.0.1 --port 3000 ``` -------------------------------- ### Launch visualization server via CLI Source: https://github.com/topoteretes/cognee/blob/main/CLAUDE.md Starts the full Cognee stack with UI at http://localhost:3000. Use this command-line approach for a quick setup. ```bash cognee-cli -ui # Launches full stack with UI at http://localhost:3000 ``` -------------------------------- ### Project structure for follow_up_agent Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/company_brain/follow_up_agent/README.md Shows the file layout of the follow_up_agent example. The README.md is this file; follow_up_agent.py checks setup and calls the scripts in order; setup.py writes the sample; sample/, credentials.json, and token.json are git-ignored; scripts/ contains the individual scripts. ```text follow_up_agent/ ├── README.md this file ├── follow_up_agent.py checks setup, then calls the scripts in order ├── setup.py writes the sample, for --sample ├── sample/ written by setup.py, git-ignored ├── credentials.json yours, git-ignored (optional) ├── token.json yours, git-ignored, written on the first Gmail run └── scripts/ ├── clear.py ├── ingest_granola.py ├── ingest_linear.py ├── ingest_email.py ├── follow_up.py └── ui.py ``` -------------------------------- ### Deploy Cognee with Daytona CLI Source: https://github.com/topoteretes/cognee/blob/main/distributed/deploy/README.md Install the Daytona CLI, create a sandbox, then inside the sandbox install cognee[api] and start the API server with uvicorn on port 8000. ```bash brew install daytonaio/cli/daytona daytona create # Inside the sandbox: pip install 'cognee[api]' python -m uvicorn cognee.api.client:app --host 0.0.0.0 --port 8000 ``` -------------------------------- ### Example output from import_agent_sessions.py Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/import_agent_sessions/README.md Sample output showing setup, session reading, ingestion, and ask results. With one agent named, only the 'all sessions' answer is printed. ```text [setup] cognee runs on openai (OPENAI_API_KEY), local fastembed embeddings. [setup] Importing Claude Code and Codex history. [read_sessions] Claude Code: 20 sessions, 164 turns [read_sessions] Codex: 20 sessions, 31 turns [ingest_sessions] Remembered 20 claude sessions as imported_agent_sessions:claude_code [ingest_sessions] Remembered 20 codex sessions as imported_agent_sessions:codex [ask] you> What did I work on in these sessions? [ask] all sessions> Your sessions are mainly about ... [ask] Claude Code only> ... [ask] Codex only> ... ``` -------------------------------- ### Install pre-commit Source: https://github.com/topoteretes/cognee/blob/main/CONTRIBUTING.md Install pre-commit using uv and set up the git hook. ```shell uv run pip install pre-commit && pre-commit install ``` -------------------------------- ### Example output of the companion run Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/self_hosted_companion/README.md Shows the expected output when running the companion: it remembers the notes, starts a chat, and saves the chat to memory. The chat ends with /bye. ```text [ingest_notes] Remembered the notes in /Users/you/Documents/journal [chat] Chat with your companion. Type /bye to end. you> When is my sister's birthday? companion> Your sister Lena's birthday is on October 4th. ... you> /bye [chat] Saved this chat to memory. ``` -------------------------------- ### Launch Cognee CLI UI Source: https://github.com/topoteretes/cognee/blob/main/README.md Starts the local UI for inspecting a Cognee installation. Requires Node.js/npm and Docker for the MCP service. ```bash cognee-cli -ui ``` -------------------------------- ### Catalog entry YAML for document-qa use-case Source: https://github.com/topoteretes/cognee/blob/main/docs/contributing/add-catalog-entry.md Example catalog entry for a use-case. The filename stem must match the entry's id. The quickstart block shows the commands a user runs to try the example, and expected_output describes the result. ```yaml # catalog/entries/use-cases/document-qa.yaml id: document-qa title: Document Q&A backed by a knowledge graph kind: use-case stack: use-case tags: - document-qa - graph-rag - recall - reading-comprehension summary: Answer questions grounded in a set of documents using cognee's graph-completion retrieval instead of plain RAG. what_youll_build: A recall pipeline that ingests documents, extracts entities and relationships into a graph, and answers questions with citations back to source chunks. quickstart: | git clone https://github.com/topoteretes/cognee.git cd cognee uv pip install cognee export LLM_API_KEY=your_openai_key python examples/guides/recall_core.py expected_output: | A ranked list of retrieved passages plus a synthesized natural-language answer citing the original documents. Compare against a plain RAG baseline to see graph-completion's contribution. difficulty: easy example_path: examples/guides/recall_core.py ``` -------------------------------- ### Install dependencies and enter analysis directory Source: https://github.com/topoteretes/cognee/blob/main/cognee/eval_framework/token_usage_analysis/README.md Install the project with eval dependencies and navigate to the analysis directory. The script loads the repo-root `.env`, so it must contain a working `LLM_PROVIDER`, `LLM_MODEL`, and API key. ```bash uv sync --dev --all-extras cd cognee/eval_framework/token_usage_analysis ``` -------------------------------- ### Invoke run_cognify_pipeline on example dataset Source: https://github.com/topoteretes/cognee/blob/main/notebooks/cognee_demo.ipynb Retrieves the default user, gets the user by ID, fetches the dataset named 'example', and invokes run_cognify_pipeline on the first dataset with the user. This is the invocation that triggers the cognify pipeline defined in the previous snippet. ```python from cognee.modules.users.methods import get_default_user from cognee.modules.data.methods import get_datasets_by_name from cognee.modules.users.methods import get_user default_user = await get_default_user() user = await get_user(default_user.id) datasets = await get_datasets_by_name(["example"], user.id) await run_cognify_pipeline(datasets[0], user) ``` -------------------------------- ### Coolify Installation Command Source: https://github.com/topoteretes/cognee/blob/main/docs/how-to-guides/cognee-sdk/deployment/coolify.mdx Run this one-line installer on a fresh Linux server as root or with sudo to install Coolify v4. After installation, open the dashboard at http://<your-server-ip>:8000 and register the first account immediately, as the first user owns the instance. ```bash curl -fsSL https://cdn.coollabs.io/coolify/install.sh | sudo bash ``` -------------------------------- ### Pull and serve Ollama models Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/self_hosted_companion/README.md Pull the required Ollama models and start the Ollama server. Needed for the fully local setup. ```bash ollama pull llama3.1:8b ollama pull nomic-embed-text ollama serve ``` -------------------------------- ### Run demo import of sample agent sessions Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/import_agent_sessions/README.md Runs the cookbook without --agents to import the sample Claude Code and Codex sessions written by setup.py into the demo dataset imported_agent_sessions_demo and ask the default question. The demo dataset is forgotten at the start of every run so it never mixes with your imported sessions. Without --agents the run stops with [setup] MISSING:. ```bash uv run python examples/cookbooks/import_agent_sessions/import_agent_sessions.py ``` -------------------------------- ### Install SDK extras for Google Drive and Gmail Source: https://github.com/topoteretes/cognee/blob/main/cognee-frontend/README.md Installs the SDK extras for Google Drive and Gmail from the repository root. Required before testing the integrations. ```bash uv sync --extra google-drive --extra gmail --dev ``` -------------------------------- ### Deploy Cognee with Islo CLI and Python SDK Source: https://github.com/topoteretes/cognee/blob/main/distributed/deploy/README.md Install the Islo CLI, log in, create an API key with a 90-day expiry, then install the Python SDK, set environment variables, and run the deployment script. The CLI is used only to create the access key. ```bash curl -fsSL https://islo.dev/install.sh | bash islo login islo api-key create cognee-deploy --expires 90 --show pip install islo export ISLO_API_KEY=your-cli-created-key export LLM_API_KEY=sk-xxx python distributed/deploy/islo_sandbox.py ``` -------------------------------- ### Start Cognee with docker compose up Source: https://github.com/topoteretes/cognee/blob/main/docs/minimal-docker-compose.md Starts the Cognee API server with Docker Compose. Requires an OpenAI API key exported as LLM_API_KEY before running docker compose up. ```bash export LLM_API_KEY="sk-..." # your OpenAI API key docker compose up ``` -------------------------------- ### Install cognee with Gmail extra Source: https://github.com/topoteretes/cognee/blob/main/cognee/tasks/ingestion/connectors/gmail.md Installs the cognee SDK with the Gmail connector extra. The second command is for installing from the monorepo. ```bash uv pip install "cognee[gmail]" # or, from this monorepo: uv sync --extra gmail ``` -------------------------------- ### Install dependencies with uv in the mcp folder Source: https://github.com/topoteretes/cognee/blob/main/cognee-mcp/README.md Install dependencies with uv in the mcp folder. Re-run after every change to the local cognee checkout. ```bash uv sync --reinstall ``` -------------------------------- ### Install and run MCP server locally Source: https://github.com/topoteretes/cognee/blob/main/AGENTS.md Installs dependencies and runs the MCP server with different transports: stdio (default), SSE, or HTTP with custom host, port, and path. ```bash cd cognee-mcp uv sync --dev --all-extras --reinstall uv run python src/server.py # stdio (default) uv run python src/server.py --transport sse uv run python src/server.py --transport http --host 127.0.0.1 --port 8000 --path /mcp ``` -------------------------------- ### cognee.start_visualization_server Source: https://github.com/topoteretes/cognee/blob/main/cognee/skill.md Starts a visualization server for the knowledge graph. This is an asynchronous operation that starts a server on the specified port. ```APIDOC ## cognee.start_visualization_server ### Description Starts a visualization server for the knowledge graph. ### Method `start_visualization_server` (async) ### Parameters - **port** (integer) - Optional - The port to run the server on. Default is 8080. ### Example ```python await cognee.start_visualization_server(port=8080) ``` ``` -------------------------------- ### Run journey tests with pytest and environment flags Source: https://github.com/topoteretes/cognee/blob/main/cognee/tests/journeys/README.md Commands to run the journey tests. Use the first to run all journeys except the slow quickstart. The quickstart command builds a wheel and requires uv. The real LLM command runs with a live model. The last command accepts an intentional route-table change and is the only way the snapshot is written. ```bash # everything except the slow quickstart pytest cognee/tests/journeys -m "journey and not quickstart" # quickstart (builds a wheel, needs uv) COGNEE_JOURNEY_QUICKSTART=1 pytest cognee/tests/journeys -m quickstart # real LLM COGNEE_JOURNEY_MODE=llm pytest cognee/tests/journeys -m "journey and not quickstart" # accept an intentional route-table change (the only way the snapshot is written) COGNEE_UPDATE_API_SNAPSHOT=1 pytest cognee/tests/journeys/test_http_api_journey.py ``` -------------------------------- ### Install Codex plugin Source: https://github.com/topoteretes/cognee/blob/main/README.md Adds the Cognee marketplace and installs the cognee plugin for Codex. ```bash codex plugin marketplace add topoteretes/cognee-integrations --ref main codex plugin add cognee@cognee ``` -------------------------------- ### Start isolated test server with uvicorn Source: https://github.com/topoteretes/cognee/blob/main/cognee-frontend/README.md Starts a loopback-only, single-user test server with isolated storage from the repository root. Reuse the same test root when restarting to retain connections. Do not expose this server publicly. ```bash GOOGLE_TEST_ROOT=$(mktemp -d /tmp/cognee-google-ui.XXXXXX) DB_PATH="$GOOGLE_TEST_ROOT/databases" \ SYSTEM_ROOT_DIRECTORY="$GOOGLE_TEST_ROOT/system" \ DATA_ROOT_DIRECTORY="$GOOGLE_TEST_ROOT/data" \ CACHE_ROOT_DIRECTORY="$GOOGLE_TEST_ROOT/cache" \ COGNEE_LOGS_DIR="$GOOGLE_TEST_ROOT/logs" \ DLT_DATA_DIR="$GOOGLE_TEST_ROOT/dlt" \ PIPELINES_DIR="$GOOGLE_TEST_ROOT/dlt/pipelines" \ DB_PROVIDER=sqlite GRAPH_DATABASE_PROVIDER=ladybug VECTOR_DB_PROVIDER=lancedb \ ENABLE_BACKEND_ACCESS_CONTROL=true REQUIRE_AUTHENTICATION=true \ DEFAULT_USER_PASSWORD='<choose a local test password>' \ AUTH_TOKEN_COOKIE_NAME=cognee_google_test_auth \ CORS_ALLOWED_ORIGINS=http://localhost:3000 \ uv run --no-sync python -m uvicorn cognee.api.client:app --host 127.0.0.1 --port 8000 ``` -------------------------------- ### Start Colima VM with Optional --network-address Source: https://github.com/topoteretes/cognee/blob/main/docs/docker-colima-setup.md Starts the Colima VM. The basic start is sufficient for most cases; the --network-address flag provisions a shared-network IP reachable from both the VM and the host, which helps host.docker.internal resolve. ```bash # Basic start colima start # Recommended: give the VM a host-reachable network address colima start --network-address ``` -------------------------------- ### Install cognee with Turso extra and configure environment Source: https://github.com/topoteretes/cognee/blob/main/docs/turso-local.md Install the cognee package with the Turso extra and set environment variables to enable Turso for database, graph, vector, and cache providers. The LLM_API_KEY is required for cognify. Remote Turso URLs are not supported and cause hard errors. ```bash pip install cognee"[turso]" # or: uv pip install -e ".[turso]" # .env — pick any subset DB_PROVIDER=turso GRAPH_DATABASE_PROVIDER=turso VECTOR_DB_PROVIDER=turso CACHE_BACKEND=turso LLM_API_KEY=... # cognify needs an LLM as usual ``` -------------------------------- ### Register GitHub connector on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/github/README.md Call register() before the app starts to make GitHub appear in GET /api/v1/integrations/status. The module's routers() is empty; install flow uses generic /api/v1/integrations/github/... routes and deliveries arrive on POST /api/v1/integrations/github/events. ```python from cognee_connector_github.cognee_host import register register() # before the app starts; GitHub appears in GET /api/v1/integrations/status ``` -------------------------------- ### Install Gmail connector Source: https://github.com/topoteretes/cognee/blob/main/examples/integrations/README.md Install the Gmail connector package from PyPI with the `cognee[gmail]` extra. ```bash pip install "cognee[gmail]" ``` -------------------------------- ### Install dev dependencies with uv Source: https://github.com/topoteretes/cognee/blob/main/AGENTS.md Creates or refreshes the environment and installs development dependencies with all extras. Requires Python >= 3.10 and < 3.15. ```bash uv sync --dev --all-extras --reinstall ``` -------------------------------- ### Run Turso local example script Source: https://github.com/topoteretes/cognee/blob/main/docs/turso-local.md Commands to run the Turso local example script for ingest, verify, and cleanup. The verify command runs in a new process to confirm persistence. Setting TURSO_JOURNAL_MODE=mvcc enables concurrent writes for graph and vector stores. ```bash uv run python examples/guides/turso_local_example.py ingest # add -> cognify -> search uv run python examples/guides/turso_local_example.py verify # fresh process: search the stored files uv run python examples/guides/turso_local_example.py cleanup # forget(everything=True) + remove files ``` -------------------------------- ### Run the migrate_from_mem0 tutorial Source: https://github.com/topoteretes/cognee/blob/main/examples/demos/ingestion_and_migration/migrate_from_mem0/README.md Command to execute the tutorial script. Requires LLM_API_KEY in .env for re-derive mode and recall. ```bash uv run python examples/demos/ingestion_and_migration/migrate_from_mem0/migrate_from_mem0.py ``` -------------------------------- ### Install cognee connector from PyPI Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/README.md Install a connector package from PyPI. The base package includes the connector and its DLT source; the [cognee] extra adds the adapter for a cognee server and installs cognee. Supports Python 3.10 through 3.14 and pins cognee-connectors-core>=0.1,<1. ```bash pip install cognee-connector-notion # the connector and its DLT source pip install "cognee-connector-notion[cognee]" # plus the adapter for a cognee server (installs cognee) ``` -------------------------------- ### Run follow_up_agent.py with sample data Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/company_brain/follow_up_agent/README.md Runs the follow-up agent cookbook script. Only LLM_API_KEY is needed; a sample run never posts to Slack. Without GRANOLA_API_KEY, LINEAR_API_KEY, and Gmail credentials.json, the script runs setup.py itself and uses the sample. Pass --sample to use it even when your own sources are set up. A sample run first forgets the dataset follow_up_agent; --no-clear keeps it. ```bash uv run python examples/cookbooks/company_brain/follow_up_agent/follow_up_agent.py ``` -------------------------------- ### Example Cypher query: Get all nodes connected to John Source: https://github.com/topoteretes/cognee/blob/main/cognee/infrastructure/llm/prompts/natural_language_retriever_system.txt Example query that matches a node with name 'John' and returns it along with all its neighbors. Uses the Entity label and the name property. ```cypher MATCH (n:Entity {'name': 'John'})--(neighbor) RETURN n, neighbor ``` -------------------------------- ### Install optional dependencies at runtime with EXTRAS Source: https://github.com/topoteretes/cognee/blob/main/cognee-mcp/README.md Docker run commands that set the EXTRAS environment variable to install optional dependency groups (e.g., aws, postgres, neo4j) at runtime. Supports single or comma-separated groups. ```bash # Install a single optional dependency group at runtime docker run \ -e TRANSPORT_MODE=http \ -e EXTRAS=aws \ --env-file ./.env \ -p 8000:8000 \ --rm -it cognee/cognee-mcp:main ``` ```bash # Install multiple optional dependency groups at runtime (comma-separated) docker run \ -e TRANSPORT_MODE=sse \ -e EXTRAS=aws,postgres,neo4j \ --env-file ./.env \ -p 8000:8000 \ --rm -it cognee/cognee-mcp:main ``` -------------------------------- ### Install Colima and Docker CLI with Homebrew Source: https://github.com/topoteretes/cognee/blob/main/docs/docker-colima-setup.md Installs Colima and the Docker CLI via Homebrew on macOS or Linux. The same command works for both platforms. ```bash # macOS (Homebrew) brew install colima docker # Linux (Homebrew) brew install colima docker ``` -------------------------------- ### Install cognee-connector-linear and cognee adapter Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/linear/README.md Install the Linear connector and its DLT source, or include the cognee server adapter with the [cognee] extra. ```bash pip install cognee-connector-linear # the connector and its DLT source ``` ```bash pip install "cognee-connector-linear[cognee]" # plus the adapter for a cognee server (installs cognee) ``` -------------------------------- ### cognee.start_ui Source: https://github.com/topoteretes/cognee/blob/main/cognee/skill.md Starts the Cognee UI. This is an asynchronous operation that launches the user interface. ```APIDOC ## cognee.start_ui ### Description Starts the Cognee UI. ### Method `start_ui` (async) ### Example ```python await cognee.start_ui() ``` ``` -------------------------------- ### Run local quickstart from the CLI Source: https://github.com/topoteretes/cognee/blob/main/README.md CLI commands to remember and recall text using the local_quickstart dataset. Works without an LLM; LLM-dependent improvement stages skip automatically. ```bash cognee-cli remember "Marie Curie was born in Warsaw." -d local_quickstart cognee-cli recall "Where was Marie Curie born?" -d local_quickstart ``` -------------------------------- ### Run handover.py with CLI options Source: https://github.com/topoteretes/cognee/blob/main/examples/integrations/daytona/README.md Install daytona, set required environment variables (DAYTONA_API_KEY and LLM_API_KEY), and run the handover script. The first run builds a snapshot (~3 min) and then executes three phases; use --keep to leave sandboxes, --rebuild to rebuild the snapshot, --handover copy to move raw state instead of a COGX archive, and --strict-walls to fail on the Tier 1/2 proxy-path gap. ```console $ pip install daytona $ export DAYTONA_API_KEY=... # https://app.daytona.io $ export LLM_API_KEY=sk-... # first run only: creates the host-scoped Secret $ python handover.py # ~3 min snapshot build the first time, then the 3 phases $ python handover.py --keep # leave the sandboxes for inspection $ python handover.py --rebuild # rebuild the snapshot after a cognee release $ python handover.py --handover copy # move the raw state instead of a COGX archive $ python handover.py --strict-walls # fail on the Tier 1/2 proxy-path gap ``` -------------------------------- ### Initialize Cognee and configuration Source: https://github.com/topoteretes/cognee/blob/main/notebooks/ontology_demo.ipynb Import necessary libraries, configure the LLM provider and model, and initialize logging. ```python # Import required libraries import cognee print(cognee.__version__) from cognee.shared.logging_utils import get_logger cognee.config.set_llm_model("gpt-4o-mini") cognee.config.set_llm_provider("openai") from cognee.api.v1.search import SearchType logger = get_logger() ``` -------------------------------- ### Run company_qa.py with uv Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/company_brain/company_qa/README.md Runs the company QA cookbook script. With no --database, --tickets, or --docs, it runs setup.py and uses the sample data. Pass --sample to force the sample even when your own sources are set up. Requires only LLM_API_KEY. ```bash uv run python examples/cookbooks/company_brain/company_qa/company_qa.py ``` -------------------------------- ### Install cognee with eval extra Source: https://github.com/topoteretes/cognee/blob/main/cognee/eval_framework/README.md Install the optional 'eval' extra to get the HTML dashboard (plotly), DeepEval engine (deepeval), and dataset download dependencies (e.g., gdown for Musique). A plain 'pip install cognee' is unaffected; a run with '--engine direct_llm --no-dashboard' works without this extra. ```bash pip install "cognee[eval]" ``` -------------------------------- ### Inspect a kept sandbox with Daytona Python SDK Source: https://github.com/topoteretes/cognee/blob/main/examples/integrations/daytona/README.md Start a kept sandbox (run id printed at start and in 'Sandboxes kept:' line) and execute commands to inspect the environment. The first command prints the placeholder LLM_API_KEY, never a real key; the second lists the cognee state databases. ```python from daytona import Daytona sb = Daytona().get("cognee-review-<run>") sb.start() print(sb.process.exec("printf '%s' \"$LLM_API_KEY\"").result) # the placeholder, never a key print(sb.process.exec("ls ~/cognee-state/system/databases/").result) # cognee_db + per-owner dirs ``` -------------------------------- ### Setup LLM environment variables Source: https://github.com/topoteretes/cognee/blob/main/cognee-starter-kit/README.md Environment variables to add to the .env file. For OpenAI, only the model and api_key are required. ```bash LLM_PROVIDER="" LLM_MODEL="" LLM_ENDPOINT="" LLM_API_KEY="" LLM_API_VERSION="" EMBEDDING_PROVIDER="" EMBEDDING_MODEL="" EMBEDDING_ENDPOINT="" EMBEDDING_API_KEY="" EMBEDDING_API_VERSION="" ``` -------------------------------- ### Register connector on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/templates/connector/README.md Call register() before the app starts so the provider appears in GET /api/v1/integrations/status. The module also exposes routers() to list mounted routers. ```python from __MODULE__.cognee_host import register register() # before the app starts; the provider appears in GET /api/v1/integrations/status ``` -------------------------------- ### Run the self-hosted companion script Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/self_hosted_companion/README.md Runs the cookbook script with sample notes. Requires LLM_API_KEY in .env. With no notes folder, it runs setup.py and uses the sample; pass --sample to force sample use, --no-clear to keep the dataset, or --ask to change the question. ```bash uv run python examples/cookbooks/self_hosted_companion/self_hosted_companion.py ``` -------------------------------- ### Run the development server with npm, yarn, pnpm, or bun Source: https://github.com/topoteretes/cognee/blob/main/cognee-frontend/README.md Start the Next.js development server using any of the four package managers. After running one of these commands, open http://localhost:3000 to view the app. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun dev ``` -------------------------------- ### Warm up cognee MCP server with uvx cognee-mcp --help Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/company_brain/company_qa/README.md Run this once before first use. The first uvx run downloads cognee, and even a cached start takes about 20 seconds, longer than an agent waits on a first launch. ```bash uvx cognee-mcp --help ``` -------------------------------- ### Test a connector with FakeHttpClient and webhook_headers Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/core/README.md Use FakeHttpClient, FakeSettings, and webhook_headers to simulate token exchange and webhook verification. The example asserts the provider account ID and delivery ID from the parsed installation and dispatched webhook. ```python from cognee_connectors_core.testing import FakeHttpClient, FakeSettings, webhook_headers token_response = {"access_token": "tok", "organization": {"id": "org-1"}} http = FakeHttpClient({("POST", DESCRIPTOR.token_url): (200, token_response)}) connector = DescriptorConnector(DESCRIPTOR, FakeSettings(webhook_secret="s3"), http) account_data = await connector.exchange_callback("code", {}) installation = connector.parse_installation(account_data) assert installation.provider_account_id == "org-1" assert http.last_call.data["grant_type"] == "authorization_code" body = b'{"organizationId": "org-1", "webhookId": "d1"}' headers = webhook_headers(DESCRIPTOR, "s3", body) verified = await connector.webhook_verifier().verify(body, headers) dispatch = await connector.handle_webhook(verified, {}) assert dispatch.provider_account_id == "org-1" and dispatch.delivery_id == "d1" ``` -------------------------------- ### Register Slack integration on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/slack/README.md Register the Slack integration before the app starts so it appears in GET /api/v1/integrations/status, then include the routers. The routers serve the OAuth flow and the Slack webhook and settings routes under /api/v1/slack. ```python from cognee_connector_slack.cognee_host import register, routers register() # before the app starts; Slack appears in GET /api/v1/integrations/status for router, prefix, tags in routers(): app.include_router(router, prefix=prefix, tags=tags) ``` -------------------------------- ### Structured Output Framework Configuration Source: https://github.com/topoteretes/cognee/blob/main/CLAUDE.md Choose the structured output framework: litellm_native (default), instructor (legacy, requires instructor extra), or baml (requires baml extra). BAML requires additional provider settings. ```bash # litellm_native (default): plain litellm, schema-native response_format # with prompted-JSON fallback — no instructor in the call path STRUCTURED_OUTPUT_FRAMEWORK="litellm_native" # Or use Instructor (legacy, via litellm; requires instructor extra: pip install cognee[instructor]) STRUCTURED_OUTPUT_FRAMEWORK="instructor" # Or use BAML (requires baml extra: pip install cognee[baml]) STRUCTURED_OUTPUT_FRAMEWORK="baml" BAML_LLM_PROVIDER=openai BAML_LLM_MODEL="gpt-4o-mini" BAML_LLM_API_KEY="your_api_key" ``` -------------------------------- ### Register Gmail connector on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/gmail/README.md Call register() before the app starts to make the Gmail provider appear in GET /api/v1/integrations/status. The OAuth flow uses generic /api/v1/integrations/gmail/... routes; no webhooks are received. ```python from cognee_connector_gmail.cognee_host import register register() # before the app starts; the provider appears in GET /api/v1/integrations/status ``` -------------------------------- ### Start MCP server in Cloud Mode via environment variables Source: https://github.com/topoteretes/cognee/blob/main/cognee-mcp/README.md Zero-config alternative to CLI flags for Cloud Mode. Set `COGNEE_SERVICE_URL` and `COGNEE_API_KEY` environment variables, then run the server. The server calls `cognee.serve()` at startup and routes all SDK operations to the cloud; no local databases are needed. Database migrations are automatically skipped. ```bash export COGNEE_SERVICE_URL="https://your-instance.cognee.ai" export COGNEE_API_KEY="ck_..." python src/server.py ``` -------------------------------- ### Check entry points with python scripts/check_entry_points.py Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/docs/RELEASE.md Run this script to resolve entry points for a distribution, ensuring the host adapter is installed correctly. ```bash python scripts/check_entry_points.py <distribution> ``` -------------------------------- ### Register Google Calendar connector on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/google-calendar/README.md Call register() before the app starts so the provider appears in GET /api/v1/integrations/status. The module's routers() is empty; the OAuth flow uses the generic /api/v1/integrations/google_calendar/... routes and no webhooks are received. ```python from cognee_connector_google_calendar.cognee_host import register register() # before the app starts; the provider appears in GET /api/v1/integrations/status ``` -------------------------------- ### Slack history sync configuration JSON Source: https://github.com/topoteretes/cognee/blob/main/docs/slack-history.md Example JSON body for configuring periodic refresh via PUT. A saved selection resolves `days` into a fixed start and extends to the present on each refresh; saving again replaces the selection. Set `enabled: false` to disable. ```json { "enabled": true, "interval_seconds": 21600, "selection": { "dataset_id": "YOUR_DATASET_UUID", "channel_ids": ["C0123456789"], "days": 14 } } ``` -------------------------------- ### Run the Google Workspace Memory example with uv Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/google_workspace_memory/README.md Run the cookbook script with uv. Requires only LLM_API_KEY; no Google account needed. Without credentials.json, the script runs setup.py itself and uses the sample data. ```bash uv run python examples/cookbooks/google_workspace_memory/google_workspace_memory.py ``` -------------------------------- ### Register connector on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/README.md Register the provider before the cognee server app starts. The connector appears in GET /api/v1/integrations/status. The OAuth flow runs on generic /api/v1/integrations/notion/... routes; providers with custom routes (Slack) expose routers() for the host to mount. ```python from cognee_connector_notion.cognee_host import register register() # the connector appears in GET /api/v1/integrations/status ``` -------------------------------- ### Deploy Cognee to Fly.io using CLI Source: https://github.com/topoteretes/cognee/blob/main/distributed/deploy/README.md Install flyctl, log in, set the LLM_API_KEY, and run the deployment script. The script handles app creation, secrets, volumes, and deployment. ```bash # Install flyctl curl -L https://fly.io/install.sh | sh && fly auth login # Deploy export LLM_API_KEY=sk-xxx bash distributed/deploy/fly-deploy.sh ``` -------------------------------- ### Connection contract usage Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/slack/README.md Use the connector without cognee: get the Slack consent URL, exchange the callback code for an OAuth token, parse the installation, and sync a scope. The exchange checks for 'ok: false' and the parse extracts team.id, bot token, and metadata. ```python from cognee_connectors_core.testing import FakeCredential from cognee_connector_slack import CONNECTOR url = CONNECTOR.authorize_url(state) # the slack.com consent URL account = await CONNECTOR.exchange_callback(code, {}) # oauth.v2.access, checked for ok: false installation = CONNECTOR.parse_installation(account) # team.id, bot token, metadata scope = await CONNECTOR.sync_scope(credential, tokens, resources=["C0123456789"]) ``` -------------------------------- ### Register Linear connector on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/linear/README.md Registers the Linear connector with a cognee server before the app starts. After registration, the provider appears in GET /api/v1/integrations/status. The module's routers() is empty; Linear uses generic integration routes and webhook events arrive on POST /api/v1/integrations/linear/events. ```python from cognee_connector_linear.cognee_host import register register() # before the app starts; the provider appears in GET /api/v1/integrations/status ``` -------------------------------- ### Run walkthrough.py with various flags Source: https://github.com/topoteretes/cognee/blob/main/examples/integrations/daytona/README.md Shows the command-line usage of walkthrough.py to replay a transcript, pause between steps, run live, record a transcript, or generate Markdown. Requires no account for replay; --live runs handover.py and annotates as it streams; flags after -- pass through. ```console $ python walkthrough.py # replay transcript.txt; needs no account $ python walkthrough.py --pause # wait for Enter between steps (presenting) $ python walkthrough.py --live # run handover.py now and annotate it as it streams $ python walkthrough.py --live --record transcript.txt -- --keep # record; flags pass through $ python walkthrough.py --markdown > WALKTHROUGH.md # the same as a document ``` -------------------------------- ### Register Google Drive connector on cognee server Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/google-drive/README.md Call register() before the cognee server starts to make the Google Drive provider appear in GET /api/v1/integrations/status. The module's routers() is empty; Drive mounts no routes of its own, and the OAuth flow uses the generic /api/v1/integrations/google_drive/... routes. ```python from cognee_connector_google_drive.cognee_host import register register() # before the app starts; the provider appears in GET /api/v1/integrations/status ``` -------------------------------- ### Run personalized_email.py with uv Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/personalized_email/README.md Runs the cookbook script on sample data. Only LLM_API_KEY is needed; no Gmail or Granola account required. With neither Gmail credentials.json nor GRANOLA_API_KEY set up, the script runs setup.py itself and uses the sample. Pass --sample to use it even when your own sources are set up. ```bash uv run python examples/cookbooks/personalized_email/personalized_email.py ``` -------------------------------- ### Docker quickstart for MCP server Source: https://github.com/topoteretes/cognee/blob/main/AGENTS.md Runs the MCP server in Docker with HTTP transport mode. See cognee-mcp/README.md for full details. ```bash docker run -e TRANSPORT_MODE=http --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main ``` -------------------------------- ### GET /api/v1/integrations/{provider}/sync/progress Source: https://github.com/topoteretes/cognee/blob/main/docs/integration-sync-progress.md Retrieves the sync progress for a specific integration provider. Use the account ID of an active connection owned by the authenticated user; omitting it selects the user's connection using existing integration API selection rules. This endpoint reads status only and does not start or retry a sync. ```APIDOC ## [GET] /api/v1/integrations/{provider}/sync/progress ### Description Retrieves the sync progress for a specific integration provider. Use the account ID of an active connection owned by the authenticated user; omitting it selects the user's connection using existing integration API selection rules. This endpoint reads status only and does not start or retry a sync. ### Method GET ### Endpoint /api/v1/integrations/{provider}/sync/progress ### Parameters #### Path Parameters - **provider** (string) - Required - The integration provider identifier. #### Query Parameters - **account_id** (string) - Optional - The account ID of an active connection owned by the authenticated user. If omitted, the user's connection is selected using existing integration API selection rules. ### Response #### Success Response (200) - **latest** (object) - The latest run information. - **activeRuns** (array) - Runs confirmed active in this API process. - **unknownActivityCount** (integer) - Number of runs with unconfirmed activity. Each run includes: - **state** (string) - The current state of the run. - **phase** (string) - The current phase of the run. - **startedAt** (timestamp) - Start timestamp. - **updatedAt** (timestamp) - Last update timestamp. - **endedAt** (timestamp) - End timestamp, if applicable. - **elapsedSeconds** (number) - Elapsed time in seconds. - **completed** (number) - Number of completed items. - **total** (number) - Total items, if known. - **unit** (string) - Unit of progress (e.g., files, repositories). - **counts** (object) - Provider counters (e.g., scanned, skipped, failed, completed). - **reason** (string) - Safe reason for waiting, blocking, partial completion, or failure. - **phasePercent** (number) - Phase-local progress percentage. - **phaseEtaSeconds** (number) - Estimated remaining time in seconds, or null if unknown. - **executionActive** (boolean|null) - Whether activity is confirmed; null means unconfirmed. ### Notes - A connection with no recorded runs has no latest progress yet. - Nonterminal records from another process or previous process lifetime have unconfirmed activity. - A persisted `running` state describes the last report; it is not proof that a worker survived a restart. - No timeout invents a failure or silently starts the job again. ### Authentication Requires a Bearer token in the Authorization header. ``` -------------------------------- ### Install connector and cognee adapter Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/templates/connector/README.md Install the connector package and optionally the cognee adapter. The adapter installs cognee. ```bash pip install __DIST__ # the connector and its DLT source pip install "__DIST__[cognee]" # plus the adapter for a cognee server (installs cognee) ``` -------------------------------- ### Project structure for personalized_email cookbook Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/personalized_email/README.md Shows the file layout of the personalized_email cookbook. The README.md is this file, personalized_email.py checks setup and calls the scripts in order, setup.py writes the sample for --sample, sample/ is written by setup.py and git-ignored, credentials.json and token.json are yours and git-ignored (token.json is written on the first Gmail run), and scripts/ contains clear.py, ingest_granola.py, ingest_email.py, and draft.py. ```text personalized_email/ ├── README.md this file ├── personalized_email.py checks setup, then calls the scripts in order ├── setup.py writes the sample, for --sample ├── sample/ written by setup.py, git-ignored ├── credentials.json yours, git-ignored ├── token.json yours, git-ignored, written on the first Gmail run └── scripts/ ├── clear.py ├── ingest_granola.py ├── ingest_email.py └── draft.py ``` -------------------------------- ### Install cognee-connector-google with pip Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/google/README.md Install the base package for the shared Google OAuth client, settings base, and connector contract. Use the [cognee] extra to also install the cognee host base (which installs cognee). ```bash pip install cognee-connector-google # the OAuth client, settings base and contract pip install "cognee-connector-google[cognee]" # plus the cognee host base (installs cognee) ``` -------------------------------- ### Deploy Cognee with Daytona Python SDK Source: https://github.com/topoteretes/cognee/blob/main/distributed/deploy/README.md Install the Daytona Python SDK, set the required environment variables (DAYTONA_API_KEY and LLM_API_KEY), and run the deployment script. The DAYTONA_API_KEY is obtained from https://app.daytona.io. ```bash pip install daytona export DAYTONA_API_KEY=your-key # from https://app.daytona.io export LLM_API_KEY=sk-xxx python distributed/deploy/daytona_sandbox.py ``` -------------------------------- ### Run company_qa.py with --check and --ask Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/company_brain/company_qa/README.md Two bash commands: first checks setup without doing work, second runs the full pipeline with database, tickets, docs, and a question. The --database flag accepts SQLAlchemy URLs; --tables limits tables, otherwise all are read. Re-running skips already-remembered content; edited files become new documents. ```bash uv run python examples/cookbooks/company_brain/company_qa/company_qa.py --check \ --database postgresql://user:password@host/hr --tickets ~/exports/tickets.json \ --docs ~/Documents/company ``` ```bash uv run python examples/cookbooks/company_brain/company_qa/company_qa.py \ --database postgresql://user:password@host/hr --tables employees,projects \ --tickets ~/exports/tickets.json --docs ~/Documents/company \ --ask "Who owns the open billing incident, and what did we decide to do about it?" ``` -------------------------------- ### Install cognee with Google Calendar extra Source: https://github.com/topoteretes/cognee/blob/main/cognee/tasks/ingestion/connectors/google_calendar.md Install the cognee SDK with the google-calendar extra using uv. The second command is for installing from the monorepo. ```bash uv pip install "cognee[google-calendar]" # or, from this monorepo: uv sync --extra google-calendar ``` -------------------------------- ### Install cognee-connector-google-calendar Source: https://github.com/topoteretes/cognee/blob/main/cognee-connectors/connectors/google-calendar/README.md Install the connector and its DLT source, or include the cognee server adapter. The cognee extra installs cognee. Requires a cognee with DOCUMENT_SYNC_VERSION >= 1 (cognee 1.6.5+); an older host is refused when the source is built. Also installs cognee-connector-google, the shared OAuth client and contract. ```bash pip install cognee-connector-google-calendar # the connector and its DLT source ``` ```bash pip install "cognee-connector-google-calendar[cognee]" # plus the adapter for a cognee server (installs cognee) ``` -------------------------------- ### Install Cognee package Source: https://github.com/topoteretes/cognee/blob/main/notebooks/ontology_demo.ipynb Install the required cognee package using pip. ```python # Install required package # !pip install cognee ``` -------------------------------- ### Install cognee with Google Drive extra Source: https://github.com/topoteretes/cognee/blob/main/cognee/tasks/ingestion/connectors/google_drive.md Install the cognee SDK with the google-drive extra using uv. The second command installs the extra from the monorepo. ```bash uv pip install "cognee[google-drive]" # or, from this monorepo: uv sync --extra google-drive ``` -------------------------------- ### Run the follow-up agent with uv Source: https://github.com/topoteretes/cognee/blob/main/examples/cookbooks/company_brain/follow_up_agent/README.md Run the agent from the repo root. Use --check to validate, --days to set the lookback window, and --ui to launch the interface. The first Gmail run opens a browser for consent; reruns skip already-known content and merge Gmail rows by message id. Add --clear to forget the follow_up_agent dataset first. ```bash uv run python examples/cookbooks/company_brain/follow_up_agent/follow_up_agent.py --check uv run python examples/cookbooks/company_brain/follow_up_agent/follow_up_agent.py uv run python examples/cookbooks/company_brain/follow_up_agent/follow_up_agent.py --days 7 --ui ```