Skip to content

Direct API vs MCP Tools

The AutoMem system is accessible through two interfaces: the HTTP API (direct REST calls to the AutoMem server) and the MCP tools (JSON-RPC calls through the mcp-automem bridge). Both interfaces reach the same backend but differ in transport, parameter style, and what they expose to callers.

For the HTTP API reference, see Memory Operations, Recall Operations, and related pages. For MCP setup, see MCP Integration.


graph LR
    subgraph mcp["MCP JSON-RPC Tools"]
        StoreMemory["store_memory"]
        RecallMemory["recall_memory"]
        AssociateMemories["associate_memories"]
        UpdateMemory["update_memory"]
        DeleteMemory["delete_memory"]
        CheckHealth["check_database_health"]
    end

    subgraph client["AutoMemClient Methods"]
        StoreMethod["storeMemory(args)"]
        RecallMethod["recallMemory(args)"]
        AssociateMethod["associateMemories(args)"]
        UpdateMethod["updateMemory(args)"]
        DeleteMethod["deleteMemory(args)"]
        HealthMethod["checkHealth()"]
    end

    subgraph api["AutoMem HTTP API"]
        PostMemory["POST /memory"]
        GetRecall["GET /recall"]
        PostAssociate["POST /associate"]
        PatchMemory["PATCH /memory/:id"]
        DeleteMemoryEndpoint["DELETE /memory/:id"]
        GetHealth["GET /health"]
    end

    StoreMemory --> StoreMethod
    RecallMemory --> RecallMethod
    AssociateMemories --> AssociateMethod
    UpdateMemory --> UpdateMethod
    DeleteMemory --> DeleteMethod
    CheckHealth --> HealthMethod

    StoreMethod -->|"JSON body"| PostMemory
    RecallMethod -->|"Query params"| GetRecall
    AssociateMethod -->|"JSON body"| PostAssociate
    UpdateMethod -->|"JSON body"| PatchMemory
    DeleteMethod -->|"URL param"| DeleteMemoryEndpoint
    HealthMethod -->|"No params"| GetHealth

The MCP bridge (mcp-automem) operates as a thin translation layer. Each MCP tool call is mapped to an AutoMemClient method, which in turn makes an HTTP request to the AutoMem server. No business logic lives in the bridge — it handles parameter mapping, content validation, and response formatting only.


The mcp-automem package (src/index.ts) serves two purposes from a single entry point:

  1. Server Mode: When launched without arguments, it becomes an MCP server communicating over stdio
  2. CLI Mode: When launched with commands (setup, cursor, recall, etc.), it executes utility functions and exits

Mode detection occurs immediately at startup:

// src/index.ts lines 36-37
if (process.argv.length > 2) {
// CLI mode — execute command and exit
} else {
// Server mode — start MCP stdio transport
}

This allows a single npm package to serve as both an interactive MCP server for AI platforms and a command-line toolkit for configuration management.

In server mode, all MCP communication occurs over stdin/stdout using the StdioServerTransport from @modelcontextprotocol/sdk. All logging is redirected to stderr to prevent pollution of the JSON-RPC channel:

// Redirect console output to stderr (server mode only)
console.log = (...args) => process.stderr.write(args.join(" ") + "\n");
console.error = (...args) => process.stderr.write(args.join(" ") + "\n");
StageLinesDescription
Entry1–35Shebang, imports, helper functions
Mode Detection36–51Determine server vs CLI mode
CLI Routing96–293Execute CLI commands and exit
Configuration295–312Load environment, create AutoMemClient
Server Setup314–876Create server, register tools and handlers
Main Loop1225–1237Install guards, connect transport, run

The server guards against two classes of failures:

Broken pipe errors — When the AI platform terminates the connection unexpectedly:

// installStdioErrorGuards() — lines 69-79
process.stdout.on("error", (err) => {
if (err.code === "EPIPE") process.exit(0);
});

Tool execution errors — All tool handlers are wrapped in try-catch, returning MCP error responses rather than crashing the server.


graph TB
    subgraph tools["MCP Tools (buildMcpServer)"]
        direction TB

        T1["store_memory<br/>Required: content<br/>Optional: tags, importance,<br/>embedding, metadata, timestamps"]
        T2["recall_memory<br/>Optional: query, queries,<br/>embedding, limit, sort,<br/>time filters, tags,<br/>expand options, context hints"]
        T3["associate_memories<br/>Required: memory1_id,<br/>memory2_id, type, strength"]
        T4["update_memory<br/>Required: memory_id<br/>Optional: content, tags,<br/>importance, metadata, timestamps"]
        T5["delete_memory<br/>Required: memory_id"]
        T6["check_database_health<br/>No parameters"]
    end

    subgraph schemas["Input Schemas"]
        S1["type: object<br/>properties: {content, tags[],<br/>importance, embedding[], ...}<br/>required: ['content']"]
        S2["type: object<br/>properties: {query, queries[],<br/>embedding[], limit, sort,<br/>expand_relations, expand_entities,<br/>context, language, ...}"]
        S3["type: object<br/>properties: {memory1_id,<br/>memory2_id, type, strength}<br/>required: all"]
        S4["type: object<br/>properties: {memory_id,<br/>content, tags[], importance, ...}<br/>required: ['memory_id']"]
        S5["type: object<br/>properties: {memory_id}<br/>required: ['memory_id']"]
        S6["type: object<br/>properties: {}"]
    end

    T1 --- S1
    T2 --- S2
    T3 --- S3
    T4 --- S4
    T5 --- S5
    T6 --- S6
Tool NameHTTP EquivalentRead-OnlyDestructiveIdempotent
store_memoryPOST /memoryNoNoNo
recall_memoryGET /recallYesNoYes
associate_memoriesPOST /associateNoNoYes
update_memoryPATCH /memory/:idNoNoYes
delete_memoryDELETE /memory/:idNoYesYes
check_database_healthGET /healthYesNoYes

MCP tool annotations provide semantic hints to AI platforms about tool behavior:

AnnotationTypeMeaningApplied To
readOnlyHintbooleanTool only reads datarecall_memory, check_database_health
destructiveHintbooleanTool permanently removes or modifies datadelete_memory only
idempotentHintbooleanSame args always produce same resultAll except store_memory
openWorldHintbooleanTool may access external resourcesfalse for all tools

MCP Tool Input Schema:

ParameterTypeRequiredConstraintsDescription
contentstringYesRuntime: ≤2000 charsMemory content to store
tagsarray[string]NoCategorization tags
importancenumberNo0–1Significance score
embeddingarray[number]NoOptional pre-computed vector
metadataobjectNoStructured additional data
timestampstringNoISO formatCreation timestamp

MCP Tool Output:

FieldTypeRequiredDescription
memory_idstringYesUnique identifier for stored memory
messagestringYesConfirmation message

HTTP API equivalent:

Terminal window
curl -X POST https://your-automem-instance/memory \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "User prefers TypeScript for new projects",
"tags": ["preference", "language:typescript"],
"importance": 0.85
}'

Content Size Governance (MCP layer adds two-tier validation):

LimitValueBehavior
Target150–300 charsOptimal embedding quality
Soft limit500 charsWarning; backend may auto-summarize
Hard limit2000 charsMCP layer rejects before sending to API

MCP Tool Input Schema:

ParameterTypeRequiredConstraintsDescription
querystringNoSemantic search query
queriesarray[string]NoMultiple queries for broader recall
limitintegerNo1–50, default 5Max results to return
tagsarray[string]NoFilter by tags
tag_modestringNo"any" | "all"Tag matching mode
tag_matchstringNo"exact" | "prefix"Tag matching strategy
time_querystringNoNatural language time filter
startstringNoISO timestampTime range start
endstringNoISO timestampTime range end
expand_entitiesbooleanNoEnable multi-hop entity expansion
expand_relationsbooleanNoFollow graph relationships
expansion_limitintegerNo1–500, default 25Max expanded results
relation_limitintegerNo1–200, default 5Relations per seed memory
expand_min_importancenumberNo0–1Filter expanded results by importance
expand_min_strengthnumberNo0–1Min relation strength to traverse
contextstringNoContext label for boosting
languagestringNoProgramming language hint

MCP Tool Output:

FieldTypeRequiredDescription
countintegerYesNumber of memories returned
resultsarray[object]YesArray of memory objects with scores
dedup_removedintegerNoDuplicates removed in multi-query mode

Parallel Query Optimization (MCP layer):

When tags are present, recall_memory executes two queries in parallel and merges results:

  1. Semantic search with tag filtering (query + tags)
  2. Pure tag matching (tags only, no semantic query)

This ensures comprehensive recall that neither pure vector search nor pure tag filtering achieves alone.

HTTP API equivalent:

Terminal window
curl "https://your-automem-instance/recall?query=typescript+preferences&tags=preference&limit=10" \
-H "Authorization: Bearer YOUR_API_TOKEN"

MCP Tool Input Schema:

ParameterTypeRequiredConstraintsDescription
memory1_idstringYesSource memory UUID
memory2_idstringYesTarget memory UUID
typestringYesenum: 11 typesRelationship type
strengthnumberYes0–1Relationship strength

Relationship Type Enum (all 11 values):

  1. RELATES_TO — General relationship
  2. LEADS_TO — Causal relationship
  3. OCCURRED_BEFORE — Temporal ordering
  4. PREFERS_OVER — Chosen alternative
  5. EXEMPLIFIES — Concrete example of a pattern
  6. CONTRADICTS — Conflicts with
  7. REINFORCES — Strengthens validity
  8. INVALIDATED_BY — Superseded by
  9. EVOLVED_INTO — Updated version
  10. DERIVED_FROM — Implementation of a decision
  11. PART_OF — Component of a larger effort

MCP Tool Output:

FieldTypeRequiredDescription
successbooleanYesWhether association was created
messagestringYesConfirmation message

HTTP API equivalent:

Terminal window
curl -X POST https://your-automem-instance/associate \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"memory1_id": "a1b2c3d4-...",
"memory2_id": "b2c3d4e5-...",
"type": "INVALIDATED_BY",
"strength": 0.95
}'

MCP Tool Input Schema:

ParameterTypeRequiredConstraintsDescription
memory_idstringYesID of memory to update
contentstringNoNew content (replaces existing)
tagsarray[string]NoNew tags (replaces existing)
importancenumberNo0–1New importance score
metadataobjectNoMetadata (merged with existing)
timestampstringNoISO formatOverride creation timestamp
updated_atstringNoISO formatExplicit update timestamp
last_accessedstringNoISO formatLast access timestamp
typestringNoMemory type classification
confidencenumberNo0–1Confidence score

MCP Tool Output:

FieldTypeRequiredDescription
memory_idstringYesID of updated memory
messagestringYesConfirmation message

HTTP API equivalent:

Terminal window
curl -X PATCH https://your-automem-instance/memory/a1b2c3d4-... \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"importance": 0.95, "tags": ["preference", "language:typescript", "reviewed"]}'

MCP Tool Input Schema:

ParameterTypeRequiredDescription
memory_idstringYesID of memory to delete

MCP Tool Output:

FieldTypeRequiredDescription
memory_idstringYesID of deleted memory
messagestringYesConfirmation message

HTTP API equivalent:

Terminal window
curl -X DELETE https://your-automem-instance/memory/a1b2c3d4-... \
-H "Authorization: Bearer YOUR_API_TOKEN"

MCP Tool Input Schema: Empty object — no parameters required.

MCP Tool Output:

FieldTypeRequiredDescription
statusstringYes"healthy" or "error"
backendstringYesBackend type (always "automem")
statisticsobjectNoDatabase statistics (memory counts, etc.)
errorstringNoError message if status is "error"

Difference from GET /health: The check_database_health MCP tool returns a simplified status object suitable for AI platform consumption. The HTTP /health endpoint returns the full response with enrichment queue metrics, individual component statuses, and timestamps. Use the HTTP endpoint directly for detailed monitoring dashboards.

HTTP API equivalent:

Terminal window
curl https://your-automem-instance/health

MCP tool handlers return dual-representation responses conforming to the MCP protocol:

  1. content array — Human-readable text (type: "text") for display in chat interfaces
  2. structuredContent object — Machine-readable data matching the tool’s outputSchema

Example from store_memory:

return {
content: [{ type: "text", text: `Memory stored with ID: ${result.memory_id}` }],
structuredContent: { memory_id: result.memory_id, message: result.message }
};

This dual format ensures:

  • AI platforms can parse structured data programmatically via structuredContent
  • Users viewing responses in chat see clean, formatted text via content
  • Tools remain compatible with both chat interfaces and API clients

ScenarioUse HTTP APIUse MCP Tools
AI agent integration (Claude, Cursor, etc.)Preferred — native JSON-RPC
Custom application or scriptPreferred — direct control
Bulk operations (migration, reprocessing)Preferred — no overhead
Content size validation before storageBuilt-in two-tier limits
Parallel tag+semantic recallManual implementationBuilt-in optimization
Admin operations (reembed, reprocess)Preferred — admin endpointsNot available
Health monitoring dashboardsPreferred — full responseSimplified output only
Process supervision (stable PID)Supported via PROCESS_TITLE env var

The mcp-automem server registers tools via the MCP SDK’s schema-based routing:

ListToolsRequestSchema handler (line 874–876): Returns the complete tools array when AI platforms query available tools via MCP introspection. AI platforms call this once at startup to discover what tools are available.

CallToolRequestSchema handler (lines 878–1223): Executes tool logic based on the name parameter using a switch-based dispatcher, then delegates to the corresponding AutoMemClient method.

The tools array (lines 319–872) contains six static tool definitions with extensive inline documentation in the description field. This documentation is directly visible to AI platforms via MCP introspection, informing the model when and how to invoke each tool.