MemoryNode MCP server

MemoryNode exposes two MCP surfaces:

Both surfaces call the MemoryNode REST API; the hosted surface can short-circuit search and list_memories through hostedDirectSearch / hostedDirectListMemories to avoid HTTP hops.

Current product focus emphasizes workflow outcomes for SaaS personalization, AI companions, and creator tools. Hosted MCP tools remain broadly available, but connector/admin-adjacent and billing-management operations are not part of the default activation journey.

When to use REST vs MCP

UseChoose
Your app backend (Node, Python, edge Worker)REST or @memorynodeai/sdk
Editors and agents (Cursor, Claude Desktop)Hosted MCP URL or stdio memorynode-mcp
Production chat with strict schemas and retriesREST/SDK (transport: "rest" or default hybrid with REST fallback)

MCP tools call the same API underneath; quotas and rate limits match REST.

1. Hosted MCP

1.1 Endpoints

MethodPathPurpose
POST/v1/mcp, /mcpJSON-RPC request (initialize / tools/list / tools/call)
GET/v1/mcp, /mcpBrowser landing or SSE subscription
DELETE/v1/mcp, /mcpClose session

Authentication uses the same API key as REST (Authorization: Bearer <key> or x-api-key). CORS is permissive for MCP paths; non-MCP routes still enforce ALLOWED_ORIGINS.

1.2 Session and cache TTLs

Constants live in apps/api/src/mcpHosted.ts:

  • Session transport cache: in-memory Map, MAX_SESSIONS = 2000, SESSION_TTL_MS = 60 60 1000 (1 hour). LRU eviction drops the oldest 100 sessions when the cap is hit.
  • Session metadata registry: MCP_SESSION_DO Durable Object stores session TTL/touch metadata (workspace_id, key hash, defaults) as the source of truth for lifecycle checks.
  • Response cache (apps/api/src/mcpCache.ts): maxSize: 400, per-tool TTL — recall: 15_000 ms, context: 8_000 ms.

1.3 Internal subrequest secret

When hosted MCP fans out to REST it sets x-internal-mcp: 1 and x-internal-secret: <MCP_INTERNAL_SECRET>. Only those subrequests skip duplicate edge rate limits. MCP_INTERNAL_SECRET must be set in every deployment that uses hosted MCP.

1.4 REST origin

resolveRestApiOrigin resolves the REST base:

  • MEMORYNODE_REST_ORIGIN if set.
  • Else if the request hit mcp.memorynode.ai, use https://api.memorynode.ai.
  • Else the request origin.

1.5 Tool catalog

Registered by registerAllHostedTools in packages/mcp-core/src/registry/registerAllTools.ts. Manifest version is exported as TOOL_MANIFEST_VERSION; policy version as MCP_POLICY_VERSION.

2.3.1 Policy version negotiation

The set of policy versions the server is prepared to speak is exported as SUPPORTED_MCP_POLICY_VERSIONS (newest-first) from @memorynodeai/shared. Clients may send x-mcp-policy-version as a single value or a comma-separated list on any hosted MCP request. The server picks the newest entry in SUPPORTED_MCP_POLICY_VERSIONS that also appears in the client list and stamps the result on the response header x-mcp-policy-version.

When no overlap exists the server falls back to the newest server-supported version (preserving the previous lock-step behaviour) and emits the warn-level event mcp_policy_version_negotiated with fell_back: true. Successful negotiations against an explicit client list emit the same event at info level. Together these events power the mcp_policy_version_compat dashboard and let us decide when to add a new supported version (or retire an old one — requires 30 days of zero traffic).

The negotiated value is purely a wire contract marker. Payload-level policy_version fields stamped inside tool results still use the server's newest version: those fields are a breadcrumb for forensic logs, not a contract marker.

ToolGroupPurpose
recallsearchHybrid vector + keyword search (bounded top_k ≤ 10).
searchsearchAlias of recall.
memory_searchsearchLower-level search call (bounded).
contextprofilePrompt-ready context pack.
context_packprofileAlias of context.
memory_contextprofileSame as context with extended schema.
memory_insertprofileWrite a memory via profile engine.
identity_getprofileReturn resolved scope identity.
whoAmI / whoamiprofileReport session workspace + scope.
memorymemoryConversational memory multiplexer.
memory_savememoryPersist a memory.
memory_forgetmemoryStage a forget request.
memory_forget_confirmmemoryConfirm staged forget.
memory_getmemory (p1 hosted)Fetch by id.
memory_listmemory (p1 hosted)Paginated list.
memory_deletememory (p1 hosted)Delete by id.
memory_conversation_savememory (p1 hosted)Persist a conversation.
ingest_dispatchmemory (p1 hosted)Discriminated ingest (text / conversation / import).
connector_settings_getconnectorsAvailable for all active plans.
connector_settings_updateconnectorsSame plan gate.
usage_todaybillingCurrent-day usage snapshot.
audit_log_listbillingAvailable for all active plans.
billing_getbillingCurrent workspace_entitlements.
billing_checkout_createbillingInitiate PayU checkout.

Every tool call flows through McpPolicyEngine (packages/shared/src/mcpPolicy.ts) which emits mcp_policy_before, mcp_policy_after, and mcp_tool_execution logs with policy version and session scope.

1.6 Rate limits and quotas

Every MCP call goes through the same rateLimit / rateLimitWorkspace pipeline as REST and consumes the per-route RPM defined by getRouteRateLimitMax. Quotas for search, context, memory, and ingest tools debit through reserve_usage_if_within_cap + commit_usage_reservation just like REST.

1.7 Errors

Hosted MCP returns JSON-RPC errors whose .data carries the same {code, message} envelope used by REST (see docs/external/API_USAGE.md §3). Non-RPC-level failures (auth, rate limit) return HTTP error responses before reaching JSON-RPC.

2. stdio MCP

2.1 Install and run

npm install -g @memorynodeai/mcp-server
memorynode-mcp

Configure your MCP-speaking client (Claude Desktop, Cursor, etc.) to launch the binary with the env vars below. Source: packages/mcp-server/src/index.ts.

2.2 Environment

VariableRequiredPurpose
MEMORYNODE_API_KEYyesBearer key for REST calls.
MEMORYNODE_BASE_URLyesREST API base URL (e.g. https://api.memorynode.ai, no trailing slash). The process exits if unset.
MEMORYNODE_USER_IDnoDefault owner id for tool calls.
MEMORYNODE_NAMESPACEnoDefault namespace.
MEMORYNODE_TIMEOUT_MSnoPer-request timeout.

2.3 Tools

ToolPurpose
recallHybrid search.
contextPrompt-ready context pack.
memoryConversational memory multiplexer.
whoAmICurrent scope / workspace.

The stdio binary is a strict, documented subset of the hosted canonical catalog. The single source of truth for stdio tool names is STDIO_SUBSET_TOOL_NAMES in packages/mcp-core/src/adapters/stdio.ts; the stdio server gates registerTool through assertStdioToolNameAllowed. Billing, connector settings, and admin-adjacent tools remain hosted-only.

The legacy stdio aliases memory_search, memory_context, and memory_insert were removed from the stdio binary. The hosted Streamable MCP may still expose them as phased aliases via MCP_DEPRECATION_PHASE — prefer recall, context, and memory / memory_save in new configs.

3. Upstream constraints

  • top_k capped at 10 for recall / search.
  • containerTag capped at 128 chars; sanitized to [-a-zA-Z0-9_.:].
  • Policy engine may deny unsafe repetition (loopConfidence) or forbidden scopes; hosted MCP returns the denial reason in the tool result.
  • All hosted MCP responses include x-request-id header for log correlation.