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.
Metadata
Release files for maximem-synap-claude-agent 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| maximem_synap_claude_agent-0.2.1.tar.gz | 23.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| maximem_synap_claude_agent-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.4 kB
Release files / maximem_synap_claude_agent-0.2.1.tar.gz
| Download URL | maximem_synap_claude_agent-0.2.1.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01af66076f52e0dae44985d4d4c3ce56529641df7caa2cc11fba0c5feaf3e104
|
|
BLAKE2b-256 checksum How to use checksums |
e42cf4ac2658e580ccdadb509c6f7e9255f9295217bc49e0204ed90804374596
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / maximem_synap_claude_agent-0.2.1-py3-none-any.whl
| Download URL | maximem_synap_claude_agent-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
197099fd8272795605bd230e7e528849e6ee2fdb304de1817da810514d7f660f
|
|
BLAKE2b-256 checksum How to use checksums |
238ed8cbc061d756a055fd0b8bcafe3db99309d6eddcab74345822450fcfc2ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|