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 hooks that fetch Synap context for each prompt and inject it via additionalContext, record the user's prompt and the agent's reply (the Stop hook's last_assistant_message), and report tool calls and results.
The first hook to fire opens the gRPC stream (sdk.instance.listen()) if you have not, and everything goes on it. SYNAP_AUTO_LISTEN=false turns that off and the two turns go over REST.
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"],
)
3. Session store: resume from Synap's compaction
Claude Code owns its transcript, and a hook can add context to a prompt but not remove what the transcript holds. The one place the SDK lets you decide what a resumed session starts from is session_store:
from synap_claude_agent import create_synap_session_store
options = ClaudeAgentOptions(
resume=session_id,
session_store=create_synap_session_store(sdk),
hooks=create_synap_hooks(sdk, user_id="alice"),
)
Once Synap has compacted the conversation, the resumed session starts from Synap's compaction and the turns after it instead of the stored transcript. Before that, or if Synap cannot answer, it resumes from the transcript unchanged. Inside a running session Claude Code still compacts its own transcript; the PreCompact hook gives its summarizer Synap's compaction to build on.
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.
Metadata
Release files for maximem-synap-claude-agent 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| maximem_synap_claude_agent-0.2.2.tar.gz | 30.4 kB | Without provenance | Details for maximem_synap_claude_agent-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| maximem_synap_claude_agent-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for maximem_synap_claude_agent-0.2.2-py3-none-any.whl |
Total release size: 49.5 kB
Release files / maximem_synap_claude_agent-0.2.2.tar.gz
| Download URL | maximem_synap_claude_agent-0.2.2.tar.gz |
|---|---|
| Size | 30.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5f93d4f6bf211639a3826a1baee75b82fd6b6baa94ed56220de6c4e0ac5156d
|
|
BLAKE2b-256 checksum How to use checksums |
8e9bf0d7f762c11209f9286703b19f94b682a6dbe0aaef4573f04f1fda18b3f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Release files / maximem_synap_claude_agent-0.2.2-py3-none-any.whl
| Download URL | maximem_synap_claude_agent-0.2.2-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14db1ed229e7b7af1828a00d00c945ac3269c4c13c678c1cca051e4c43701663
|
|
BLAKE2b-256 checksum How to use checksums |
3ab8ec20d5bdbab97a0aa59ef04d50d8ec47f9717cca987a57e41bd77a263390
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Security for maximem-synap-claude-agent 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.