Synap memory integration for Anthropic's Claude Agent SDK
Project description
synap-claude-agent
Synap memory integration for Anthropic's Claude Agent SDK (Python).
A TypeScript sibling package with the same API is published as @maximem/synap-claude-agent.
Install
pip install synap-claude-agent
Requires claude-agent-sdk>=0.1, maximem-synap>=0.2.0.
Two plug points
1. Hooks — automatic context injection
create_synap_hooks(...) installs a UserPromptSubmit hook that fetches Synap context for each prompt and injects it via additionalContext. Optionally records the user prompt to conversation history for future recall.
from claude_agent_sdk import query, ClaudeAgentOptions
from maximem_synap import MaximemSynapSDK
from synap_claude_agent import create_synap_hooks
sdk = MaximemSynapSDK(api_key="sk-...")
async for message in query(
prompt="What did I tell you about my trial?",
options=ClaudeAgentOptions(
hooks=create_synap_hooks(sdk, user_id="alice", customer_id="acme"),
),
):
print(message)
2. MCP tools — explicit read/write
create_synap_mcp_server(...) returns an in-process MCP server with two tools:
synap_search(query, max_results?)— semantic search over the user's memorysynap_remember(content, metadata?)— persist an explicit fact
options = ClaudeAgentOptions(
mcp_servers={"synap": create_synap_mcp_server(sdk, user_id="alice")},
allowed_tools=["mcp__synap__synap_search", "mcp__synap__synap_remember"],
)
Use both together for the full experience: automatic context injection plus agent-initiated read/write.
Error policy
- Hooks never raise — SDK failures log at
ERRORand fall through to no-op (no context injected, no prompt recorded). Context-provider style. synap_searchtool returns a "no context available" message on SDK failure — the tool call succeeds so the agent loop keeps going.synap_remembertool returnsisError=trueon ingestion failure — silent drops would hide ingestion outages, so we surface them to the agent explicitly.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maximem_synap_claude_agent-0.1.2.tar.gz.
File metadata
- Download URL: maximem_synap_claude_agent-0.1.2.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba547a535d4496e7f9db779865c38804adc464b7a8a9289923a38bcaa0887ac1
|
|
| MD5 |
46c21294961e1ac356419e275f462e0a
|
|
| BLAKE2b-256 |
2ce9e29bd66ad8557495b67f90c301a174b1e14961291de23885287762a09d52
|
File details
Details for the file maximem_synap_claude_agent-0.1.2-py3-none-any.whl.
File metadata
- Download URL: maximem_synap_claude_agent-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a94d08dcfc3d6c9a8be64f46b2133a7d5364edf7f2aa3640cee7d69d5b9602c
|
|
| MD5 |
543ad24479bb309352ecb05eec4ffe83
|
|
| BLAKE2b-256 |
f2c7480f33481e4238872e53db429d931a215147f0535322decf7bf3afa52af8
|