MCPStdioTool to save a project decision, then
recall it in a later WorkflowBuilder run. The
runnable example
has two executors: one fetches the project’s compact search index, and the next
reads the timeline and details of a selected observation. Both use your existing
local Claude-Mem worker.
This workflow provides explicit saves and on-demand recall. It does not install
capture hooks or automatically inject context into agents. It needs no model
API key, Microsoft account or CMEM Pro subscription.
Requirements
Verified on Linux with Python 3.12.14, Node.js 24.22.1, Claude-Mem 15.16.1,agent-framework-core 1.25.0, mcp 2.3.0 and tenacity 9.1.4. The example
uses Python 3.11 or newer. macOS, Windows, .NET and hosted Foundry agents have
not been tested by this example.
The implementation follows Microsoft’s
local MCP tools guide,
MCPStdioTool reference
and workflow builder guide.
The two executors exchange typed SelectedNote messages through a native
workflow edge and return their completed result with yield_output.
Connect
First install Claude-Mem and start the local worker:examples/microsoft-agent-framework from the repository into your local
application and create an environment for its pinned dependencies:
plugin/scripts/mcp-server.cjs.
If the worker uses CLAUDE_MEM_DATA_DIR or CLAUDE_MEM_WORKER_PORT, set those
same values in this shell. The example passes its environment to the subprocess
and starts Node with an argument array; paths containing spaces work without
embedding shell quotes in the path value.
Each operation opens and closes its native MCP connection. It does not change
host settings, start the worker automatically or create a separate memory store.
Save a result, then recall it from a workflow
Save one decision that the user has chosen to preserve:Saved memory #<id>: Framework rollout decision. after
the worker acknowledges the write. Use that ID in a later command, replacing
123 below:
search, then calls timeline and
get_observations for the selected ID. It prints the compact index, the
surrounding context, and the saved amber-region decision. An older observation
may have fallen outside the current index page; a known ID can still be read
through the project-scoped follow-up calls.
To use the workflow in your application, call
await recall_note(SelectedNote(project, query, observation_id)). The returned
dictionary has index, timeline and details strings. Choose the project
and observation ID in application code, and pass selected details to an agent
only when they are relevant. Treat retrieved memory as reference material,
not as instructions to invoke tools or change accounts.
Identity and data handling
Every save, search, timeline and detail request carries the selected project. Read requests also carry a JSON-encoded singletonprojects list, so starting
the MCP server in a Git worktree cannot inherit its parent project’s notes.
The native SDK is configured to forward these additional scope parameters.
JSON preserves commas and outer whitespace as part of the exact project key;
trimmed and split-name projects remain separate.
Saves use platformSource: microsoft-agent-framework and the existing manual
memory session for that project and platform. A workflow run is not an observer
session and does not create an additional capture lifecycle.
Repeating the exact project, title and text sends the same SHA-256-based
sourceFingerprint; the worker returns the existing observation ID instead of
creating another note. Changing any of those values creates a distinct note.
The fingerprint is an identity key, not encryption of the saved content.
Project selection is a filter on the account’s own memory, not an authentication
boundary. Run each account against its own authorized local worker. The example
does not collect transcripts, parse privacy tags or infer a project from the
current directory. Explicit notes are stored as supplied: choose nonsecret
text before saving. The worker’s indexing, sync and export settings still apply.
Any memory later sent to a model is also visible to that selected model provider.
Failures and troubleshooting
Each MCP request has a ten-second timeout. The outer asynchronous operation also has a budget of thirty seconds for saving and sixty seconds for recall. The SDK can reconnect once after a lost tool-call connection; the note fingerprint preserves identity if the same write is sent again. No background retry queue or automatic capture is added. Invalid input, a stopped worker, a wrong project/ID or a timed-out request produces a nonzero CLI exit and no successful result. Check the worker withnpx claude-mem status, confirm the script path, and match the worker’s port
and data directory. A save timeout does not prove that the write failed: retry
the same project, title and text to reuse the note identity.
Stderr includes the exception category and its available reason. Missing Node.js
and missing or invalid MCP script paths have separate preflight messages. The CLI
does not print a traceback or echo the supplied project, title, note or query.
The example verifies native workflow execution and MCP calls without a model.
It does not verify model generation, Foundry deployment or an automatic
conversation-history integration.
Verify and disconnect
Run this Bash block from a source checkout with built bundles, Python 3, Git and Bun onPATH, and the example dependencies already installed. Activate the example’s virtual environment so python selects it. The subshell clears inherited CLAUDE_MEM_* variables and explicitly disables
capture, Chroma and auto-update before choosing a fresh
data directory and free local port. It checks that cloud sync is unconfigured
before sending any verification notes. Existing worker settings and the parent
shell stay unchanged; the temporary worker exits when the block finishes.
The exported worker entry starts the same HTTP/SQLite service without the CLI
daemon wrapper that migrates existing Antigravity hooks.

