Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Memory MCP Integration
MCP (Model Context Protocol) server integration for the self-learning memory system. The server exposes episode lifecycle, memory retrieval, pattern analysis, embeddings, and monitoring tools over JSON-RPC on stdio.
Agent code execution is fail-closed.
execute_agent_codeis not a working execution backend. It is absent from tool discovery and direct calls are rejected. There is no WASM/Wasmtime/Javy sandbox in production. See ADR-073 and ADR-052.
Features
- MCP Server: JSON-RPC over stdio with tool discovery and a shared tool registry
- Episode Lifecycle Management: Programmatic episode creation, tracking, and completion
- Episode Relationships, Tags, and Handoffs: Knowledge-graph links, tag filtering, checkpoints
- Memory Integration: Query episodic and semantic memory; analyze learned patterns
- Pattern Analysis: Pattern extraction, search, recommendations, and playbooks
- Embeddings Support: Multiple providers (local, OpenAI, Mistral)
- Progressive Tool Disclosure: Tools prioritized based on usage patterns
- Monitoring: Health checks, metrics, rate limiting, and audit logging
- Fail-Closed Code Execution:
execute_agent_codeis unavailable in production
Code Execution Status
execute_agent_code is a fail-closed, unavailable tool in production:
- It is not advertised by
tools/list(no working backend is registered). - Direct
tools/callfor it is rejected by the dispatcher insrc/bin/server_impl/handlers/call_tool.rswith a JSON-RPC error and the detail"execute_agent_code tool is not available due to WASM sandbox compilation issues". - The batch dispatcher rejects it identically
(
src/bin/server_impl/handlers/batch_execute.rs). - The handler in
src/bin/server_impl/tools/memory_handlers.rsadditionally audit-logs the attempt and returns"Code execution is no longer available. The WASM sandbox was removed in v0.1.29." - The WASM/Wasmtime/Javy/rquickjs dependencies and the
wasmtime-backend,javy-backend, andwasm-rquickjsfeature names were removed in v0.1.29 (ADR-052). They do not exist in this crate today.
Use the supported episode and memory tools instead (see Available Tools), or run agent code in an external runner that you control outside this MCP server.
sandbox-dev (trusted local experimentation only)
A legacy Node.js CodeSandbox still lives in src/sandbox/, but it is
compiled only when the non-default sandbox-dev feature is enabled:
sandbox-dev is not a production sandbox and MUST NOT be enabled for
untrusted input. It exists solely for trusted local experimentation.
Limits that ARE enforced in this path:
- Execution timeout (
max_execution_time_ms) via a Tokio timeout; the child process is killed on drop (kill_on_drop(true)). - Maximum code length (100 KB) checked before execution.
- Static regex screening of the source for filesystem, network, subprocess, and
obvious malicious patterns (see
src/sandbox/mod.rs). - Global shadowing/deletion in the JavaScript wrapper (
process,require,module,__dirname,__filename) when those capabilities are disabled.
Limits that are NOT enforced (do not rely on them):
- OS-level isolation:
src/sandbox/isolation.rsprovidesapply_isolation(privilege drop,ulimit, namespaces), but the execution path does not call it. - Memory limits (
max_memory_mb) and CPU limits (max_cpu_percent/max_cpu_seconds) are configuration-only; they are not applied to the child process. - Output sanitization: stdout/stderr are returned as-is.
- The Node.js process itself is a full interpreter; regex screening is heuristic and can be bypassed by runtime obfuscation.
- There is no runtime capability enforcement for network/filesystem/subprocess; the settings only drive source-pattern checks.
Usage
The server is constructed with a memory system and a sandbox configuration, then served over stdio:
use SelfLearningMemory;
use ;
use Arc;
use Mutex;
async
SelfLearningMemory and its storage backends are initialized by
src/bin/server_impl; see src/bin/memory-mcp-server.rs for the full startup
path and stdio JSON-RPC loop.
Calling a supported tool
Use episode and memory tools rather than code execution:
Calling execute_agent_code (fails closed)
Observed response (production build):
Sandbox configuration
SandboxConfig is still accepted at construction (the server is built with
SandboxConfig::restrictive() by default) but, without a registered execution
backend, it no longer governs any production code path. Treat the timeout,
memory, and CPU fields as advisory configuration only.
Available Tools
The MCP server exposes tools grouped into categories, defined in the shared
registry (src/server/tools/registry/). Consult the registry and
docs/API_REFERENCE.md for the authoritative,
current surface.
Episode Lifecycle Management
create_episode- Start tracking a new task with metadataadd_episode_step- Log execution steps to track progresscomplete_episode- Finalize episode and trigger learning cycleget_episode- Retrieve complete episode detailsget_episode_timeline- Visualize chronological task progressionupdate_episode- Update episode detailsdelete_episode- Remove episodes permanently (with safeguards)checkpoint_episode- Create mid-task checkpointsget_handoff_pack/resume_from_handoff- Multi-agent handoff
📖 Complete Episode Lifecycle Documentation
Episode Relationships & Tags
add_episode_relationship,get_episode_relationships,remove_episode_relationshipfind_related_episodes,check_relationship_existsadd_episode_tags,get_episode_tags,set_episode_tags,remove_episode_tagssearch_episodes_by_tagsget_dependency_graph,get_topological_order,validate_no_cycles
Memory & Query Tools
query_memory- Query episodic memory for relevant past experiencesquery_semantic_memory- Semantic search using embeddingsbulk_episodes- Retrieve multiple episodes efficiently
Pattern Analysis
analyze_patterns- Analyze patterns from past episodesadvanced_pattern_analysis- Deep pattern analysis with statistical methodssearch_patterns- Search for specific patternsrecommend_patterns- Get pattern recommendations for tasksrecommend_playbook- Get actionable playbooks for tasksexplain_pattern- Explain a specific pattern
Embeddings & Configuration
configure_embeddings- Configure embedding providers (local, OpenAI, Mistral)test_embeddings- Test embedding generationgenerate_embedding- Generate an embedding for supplied textsearch_by_embedding- Search by embedding vectorembedding_provider_status- Report active provider health
Monitoring & Health
health_check- Server health and statusget_metrics- Performance metrics and statisticsquality_metrics- Episode quality assessmentrecord_recommendation_session,record_recommendation_feedback,get_recommendation_stats
Code Execution (fail-closed)
execute_agent_code- Unavailable / fail-closed. Not a working execution backend; calls are rejected. Use the tools above instead.
Batch Operations Contract Status
The MCP JSON-RPC endpoint supports batch/execute (multi-operation transport).
Tool-level batch analytics names are intentionally deferred and not
advertised:
batch_query_episodesbatch_pattern_analysisbatch_compare_episodes
These names return Tool not found until dedicated handlers are implemented.
Security
Production security boundaries, authentication, isolation, and audit logging are described in SECURITY.md. In brief:
- Transport is JSON-RPC over stdio; there is no network listener by default.
- OAuth 2.1 bearer-token validation is opt-in via the
oauthfeature andMCP_OAUTH_*environment variables; when disabled the server logs that OAuth is disabled. - Per-client token-bucket rate limiting protects against DoS.
- Structured audit logging records security-relevant events, including rejected
execute_agent_codeattempts. - Agent code execution is fail-closed; the only in-tree executor is the
non-default, trusted-local
sandbox-devpath documented above.
Testing
# Run the crate tests
# Include the trusted-development sandbox path (local experimentation only)
Contributing
- Security first: keep
execute_agent_codefail-closed unless an approved backend with enforced controls exists (ADR-073). - Test coverage: add tests for both success and failure cases.
- Documentation: update this README and inline docs; do not reintroduce WASM/Javy production claims.
- Performance: profile memory/query paths.
License
MIT License - See the repository LICENSE file for details.