← Catalog

pi-mem0-gateway

pi extension: reach every connector behind the mem0 gateway from one tool. Five operations, credentials stay server-side

ExtensionSkill

Install

Install with PiG

pig install npm:pi-mem0-gateway

Install with Pi

pi install npm:pi-mem0-gateway
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.8.1 (README.md). PiG does not review it.

pi-mem0-gateway

npm ci license

A pi extension that exposes every tool your organization has connected to the mem0 gateway as a single agent tool.

The gateway stores the credentials and audits each call, so pi never prompts for a connector login and no third-party API key is kept on the machine.

mem0_gateway(operation: "find", task: "list my open issues")
mem0_gateway(operation: "invoke", tool_name: "<connector>__<tool>", arguments: { limit: 3 })

Requirements

  • pi
  • A mem0 gateway agent key

Install

pi install npm:pi-mem0-gateway
export MEM0_GATEWAY_TOKEN="mg_..."

Restart pi.

Design

pi ships no MCP client by design: tool definitions are verbose, and a connected server consumes context on every turn whether it is used or not.

The mem0 gateway is itself a meta-gateway — five verbs in front of an entire catalogue. This extension registers one tool carrying those five operations, so context cost stays constant as an organization adds connectors. The model queries the catalogue on demand rather than holding it.

No connector is named in this package's source. An organization connects any MCP server or OpenAPI specification and grants tools per agent key, so each catalogue differs and changes during a session. Every discover and find is a live call, and a tool granted during a session is usable immediately, with no restart.

Operations

OperationPurposeKey fields
discoverConnector names and tool counts, or one connector's toolsconnector
findSearch granted tools for a tasktask, requestable
describeInput schema of one tooltool_name
invokeCall a granted tooltool_name, arguments
requestAsk an administrator for accesstool_names, reason

The standard sequence is find → describe → invoke.

discover returns a summary, because a full catalogue is large and remains in context for the rest of the session. Pass connector for one connector's tools:

mem0_gateway(operation: "discover")
mem0_gateway(operation: "discover", connector: "<connector>")

An empty find result is a confirmed no-match rather than an error. When a granted search returns nothing, search again with requestable: true, then request the tools that apply.

Error recovery

Gateway errors are descriptive, but acting on one costs an extra turn. Three follow-ups are deterministic and are applied automatically:

ConditionAttached to the result
invoke fails on argumentsThe tool's input schema
find returns exactly one toolThat tool's input schema
invoke denied, name not grantedConfirmation the name is unknown, plus near matches
invoke denied, name grantedConfirmation the tool is granted and the refusal concerns the call

The denial cases matter because invoke answers a misspelled name with out_of_scope, the same code used for a tool the key does not hold. Without the distinction, the documented path requests access to an already-granted tool.

Attached schemas are shortened: long property descriptions are cut while required fields, property names, and types are kept, and the full text remains available through describe.

Probes run only on the failures listed above. A successful call costs exactly one request, and a failed probe leaves the original error unchanged.

Configuration

Resolution order is MEM0_GATEWAY_TOKEN, then MEM0_GATEWAY_API_KEY, then pi settings.

// ~/.pi/agent/settings.json
{
  "pi-mem0-gateway": {
    "token": "${MEM0_GATEWAY_TOKEN}",  // ${VAR} is expanded
    "url": "https://gateway-mcp.mem0.ai/mcp",
    "timeoutMs": 60000
  }
}
SettingEnvironment variableDefault
tokenMEM0_GATEWAY_TOKEN, MEM0_GATEWAY_API_KEYnone — required
urlMEM0_GATEWAY_URLhttps://gateway-mcp.mem0.ai/mcp
timeoutMsMEM0_GATEWAY_TIMEOUT_MS60000

token and url are read from the environment and from global settings only. A project-local .pi/settings.json is committed to a repository, so accepting a token or URL from that file would let a cloned repository redirect every gateway call along with the key. A project may set timeoutMs, which cannot carry a credential.

Errors

Each failure returns readable text rather than a stack trace.

MessageMeaning
(config)Missing key, or malformed arguments
(transport)Gateway unreachable, timed out, or the key was rejected
(tool)The gateway or the connector refused the call
denied … (out_of_scope)Access is missing. Use find with requestable, then request
upstream_401The connector needs reconnecting in the mem0 admin console. The key is valid

Access requests are asynchronous and may take hours to approve.

Development

npm install
npm run check    # tsc --noEmit, then node --test
npm run release  # bump, tag, push; CI publishes

src/client.ts is a small MCP Streamable HTTP client. The gateway is stateless — no initialize handshake and no session id — so no SDK is required. Responses are parsed as JSON or as SSE data: frames, since the endpoint may return either.

All tests are offline. CI never calls the gateway, so no key is required and no run fails because a connector is unavailable.

License

MIT