Skip to main content

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 memory
  • synap_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 ERROR and fall through to no-op (no context injected, no prompt recorded). Context-provider style.
  • synap_search tool returns a "no context available" message on SDK failure — the tool call succeeds so the agent loop keeps going.
  • synap_remember tool returns isError=true on 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

maximem_synap_claude_agent-0.1.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maximem_synap_claude_agent-0.1.4-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file maximem_synap_claude_agent-0.1.4.tar.gz.

File metadata

File hashes

Hashes for maximem_synap_claude_agent-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e40588b3f770d520f00baf4facbe8a219f5b680654b7caa00b7d03b2cfd9d541
MD5 49549a52c2134170a1b46b072a16139b
BLAKE2b-256 c30c76ebf061a1fab1cc43d4d694a2c1e2cfa2fa30b5662f82be7d1f2504114c

See more details on using hashes here.

File details

Details for the file maximem_synap_claude_agent-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for maximem_synap_claude_agent-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 75a2b50b0542db089c8531c868568a5206399ba470a4928c07f6c955eff0e87d
MD5 673dbda69be1081028459ea6655a9b4a
BLAKE2b-256 5a095dd5dd379e5951582378b96b3d477564a62fb6aebd8b7decf69c415c3b0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page