Skip to main content

FastMCP bridge for a self-hosted Mem0 REST API

Project description

mem0-selfhosted-fastmcp

Thin FastMCP bridge for a self-hosted Mem0 REST API.

It fetches the live OpenAPI spec from a Mem0 server, prunes it to the useful memory operations, and exposes those endpoints as MCP tools for OpenCode or other MCP clients.

Implementation note:

  • this uses FastMCP's official OpenAPI integration via FastMCP.from_openapi
  • there is no handwritten MCP protocol layer here; the bridge is generated from the live Mem0 OpenAPI spec at startup and then lightly curated (path pruning plus friendly MCP tool names)

Scope

Exposed tools:

  • add_memory
  • list_memories
  • search_memories
  • get_memory
  • update_memory
  • delete_memory
  • delete_all_memories
  • memory_history
  • list_entities
  • delete_entity

Excluded on purpose:

  • auth/login/refresh flows
  • setup/bootstrap endpoints
  • admin/configure/request-log endpoints

Environment

Required:

  • MEM0_BASE_URL (default: http://mem0-memory:8765)
  • one of:
    • MEM0_API_KEY (sent as X-API-Key)
    • MEM0_BEARER_TOKEN (sent as Authorization: Bearer ...)

Optional:

  • FASTMCP_TRANSPORT (stdio by default)
  • HOST / PORT for HTTP transports

Usage

Stdio mode for OpenCode-style spawning:

MEM0_BASE_URL=http://mem0-memory:8765 \
MEM0_API_KEY=... \
uv run mem0-selfhosted-fastmcp

Dump the pruned OpenAPI used for generation:

MEM0_BASE_URL=http://mem0-memory:8765 \
MEM0_API_KEY=... \
uv run mem0-selfhosted-fastmcp --dump-openapi

Run as HTTP MCP server:

MEM0_BASE_URL=http://mem0-memory:8765 \
MEM0_API_KEY=... \
uv run mem0-selfhosted-fastmcp --transport streamable-http --port 8081

Maintenance

Because the bridge loads the live OpenAPI spec at startup, many Mem0 API changes are picked up automatically without code generation. The places most likely to need manual updates are:

  • path allowlist changes in server.py
  • operationId -> MCP name mappings when upstream operationIds change
  • auth header strategy if Mem0 auth changes

Helpful targets:

make sync              # install/update dependencies
make dump-openapi      # print the pruned live OpenAPI used by the bridge
make snapshot-openapi  # save the current pruned live OpenAPI to generated/
make check-live        # smoke-test server creation against the live Mem0 API
make run               # stdio mode for OpenCode
make run-http          # streamable-http mode for shared/server use

OpenCode MCP example

[servers.mem0]
transport = "stdio"
command = "uvx"
args = ["--from", "/workspace/jr200-labs/mem0-selfhosted-fastmcp", "mem0-selfhosted-fastmcp"]
env.MEM0_BASE_URL = "http://mem0-memory:8765"
env.MEM0_API_KEY = "${MEM0_API_KEY}"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mem0_selfhosted_fastmcp-0.1.1.tar.gz (51.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mem0_selfhosted_fastmcp-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file mem0_selfhosted_fastmcp-0.1.1.tar.gz.

File metadata

  • Download URL: mem0_selfhosted_fastmcp-0.1.1.tar.gz
  • Upload date:
  • Size: 51.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mem0_selfhosted_fastmcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e455754528536cc80ccca08814fa23c4025e7d108179f6d3fe23293d7b43eb17
MD5 3e63a27caf6f65da99eda1d9e1b4a317
BLAKE2b-256 9c73ff2081b5531cd265909e3ea313fdc417872d87a884b3e2f803ad175534dd

See more details on using hashes here.

File details

Details for the file mem0_selfhosted_fastmcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mem0_selfhosted_fastmcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mem0_selfhosted_fastmcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb2cf1128b978dc75abbde8f3f9149d8840029f48e8c60333862f50d66d7fcaa
MD5 2e2f5af774f533a00e4e21d97f204e31
BLAKE2b-256 333860301eb904d4af62fab264dbb1e204389eb6f0254a4d15cc6778cbbe3dc4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page