Python SDK
Unified Python SDK for Snipara. One config file, one CLI, one API. Context optimization, agent memory, file sync, and code execution — all from a single snipara package.
New in v0.1.0
The snipara package consolidates 5 separate configuration systems into a single .snipara.toml file, provides a unified async/sync Python API wrapping the Snipara MCP server, event-driven file synchronization, and an auto-feedback loop (query → execute → remember).
Installation
Core (context queries, memory, config)
pip install sniparaWith file watcher
pip install snipara[watch]With RLM code execution
pip install snipara[runtime]Everything
pip install snipara[all]Requirements
- Python 3.10+ (3.11+ recommended for native TOML support)
- snipara-mcp >= 2.3.0 (installed automatically)
- watchfiles >= 0.21.0 (optional, for
snipara watch) - rlm-runtime >= 0.1.0 (optional, for
snipara execute)
Quick Start
1. Initialize Configuration
snipara initThis creates .snipara.toml in your project root interactively. You'll be prompted for your project slug, API key, default token budget, search mode, and optional runtime settings.
2. Query Context (Async)
from snipara import Sniparaasync with Snipara() as s: result = await s.query("how does authentication work?") for section in result.get("sections", []): print(f"[{section['relevance']:.0%}] {section['title']}") print(section["content"][:200])3. Query Context (Sync)
from snipara import SniparaSyncwith SniparaSync() as s: result = s.query("how does authentication work?") print(result)Sync client works in Jupyter
SniparaSync handles nested event loops automatically, so it works in Jupyter notebooks without any special setup.
4. Full Feedback Loop
from snipara import Sniparaasync with Snipara() as s: # query -> execute -> remember (all in one call) result = await s.run( "fix the rate limiting bug in the API", remember_learnings=True, ) print(f"Context tokens: {result.context.total_tokens}") print(f"Execution: {result.execution.summary}") print(f"Memories stored: {len(result.memories_stored)}")Configuration
The .snipara.toml file is the single source of truth for all Snipara settings. Place it in your project root (alongside .git/).
PROJECT - Authentication and API connection[project]slug = "my-project"api_key = "rlm_abc123def456..."api_url = "https://api.snipara.com"CONTEXT - Query defaults[context]max_tokens = 4000search_mode = "hybrid"include_summaries = trueshared_context = trueRUNTIME - rlm-runtime code execution[runtime]backend = "anthropic"model = "claude-sonnet-4-20250514"environment = "local"max_depth = 4SYNC - File watcher patterns[sync]include = ["docs/**/*.md", "*.md"]exclude = ["node_modules/**", ".git/**"]debounce_ms = 500Resolution Order
Configuration is resolved with layered priority (highest wins):
| Priority | Source | Description |
|---|---|---|
| 1 (highest) | Environment variables | SNIPARA_API_KEY, SNIPARA_PROJECT_ID, etc. |
| 2 | .snipara.toml (project) | Walk up from CWD to git root |
| 3 | ~/.config/snipara/config.toml | Global user defaults |
| 4 | rlm.toml (legacy) | Deprecated — emits warning |
| 5 (lowest) | Built-in defaults | Hardcoded in Pydantic models |
Environment variablesSNIPARA_API_KEY, SNIPARA_PROJECT_ID, etc.
.snipara.toml (project)Walk up from CWD to git root
~/.config/snipara/config.tomlGlobal user defaults
rlm.toml (legacy)Deprecated - emits warning
Built-in defaultsHardcoded in Pydantic models
SDK API Reference
The SDK provides both async (Snipara) and sync (SniparaSync) clients with the same API surface. All methods below are shown in async form.
Context Optimization
| Method | Description | Key Parameters |
|---|---|---|
query(query) | Query for optimized, ranked context sections | max_tokens, search_mode |
search(pattern) | Search documentation with regex patterns | max_results |
plan(query) | Generate execution plan for complex queries | strategy, max_tokens |
multi_query(queries) | Execute multiple queries with shared budget | max_tokens |
shared_context() | Get merged team shared context | categories, max_tokens |
query(query)Query for optimized, ranked context sections
Params: max_tokens, search_mode
search(pattern)Search documentation with regex patterns
Params: max_results
plan(query)Generate execution plan for complex queries
Params: strategy, max_tokens
multi_query(queries)Execute multiple queries with shared budget
Params: max_tokens
shared_context()Get merged team shared context
Params: categories, max_tokens
Document Management
| Method | Description | Key Parameters |
|---|---|---|
upload(path, content) | Upload or update a single document | path, content |
sync_documents(documents) | Bulk sync multiple documents | delete_missing |
upload(path, content)Upload or update a single document
Params: path, content
sync_documents(documents)Bulk sync multiple documents
Params: delete_missing
Agent Memory
| Method | Description | Key Parameters |
|---|---|---|
remember(content) | Store a memory for later semantic recall | type, scope, category, ttl_days |
recall(query) | Semantically recall relevant memories | limit, min_relevance, type |
remember(content)Store a memory for later semantic recall
Params: type, scope, category, ttl_days
recall(query)Semantically recall relevant memories
Params: limit, min_relevance, type
Code Execution & Feedback Loop
| Method | Description | Key Parameters |
|---|---|---|
execute(task) | Execute a task via rlm-runtime (requires [runtime]) | context, environment, max_depth |
run(task) | Complete feedback loop: query → execute → remember | context_query, remember_learnings, memory_types |
execute(task)Execute a task via rlm-runtime (requires [runtime])
Params: context, environment, max_depth
run(task)Complete feedback loop: query > execute > remember
Params: context_query, remember_learnings, memory_types
Result Types
| Type | Key Fields | Description |
|---|---|---|
QueryResult | sections, total_tokens, suggestions | Context query result |
SearchResult | matches, total_matches | Regex search result |
PlanResult | steps, total_tokens | Execution plan |
ExecuteResult | response, trajectory, total_cost | Code execution result |
RunResult | context, execution, memories_stored | Full feedback loop result |
MemoryResult | memory_id, memories | Remember/recall result |
SyncResult | created, updated, deleted | Bulk sync result |
QueryResultContext query result
Fields: sections, total_tokens, suggestions
SearchResultRegex search result
Fields: matches, total_matches
PlanResultExecution plan
Fields: steps, total_tokens
ExecuteResultCode execution result
Fields: response, trajectory, total_cost
RunResultFull feedback loop result
Fields: context, execution, memories_stored
MemoryResultRemember/recall result
Fields: memory_id, memories
SyncResultBulk sync result
Fields: created, updated, deleted
CLI Reference
The snipara CLI is installed automatically with the SDK. All commands work from any directory within a project that has a .snipara.toml.
| Command | Description | Example |
|---|---|---|
snipara init | Create or migrate .snipara.toml | snipara init --migrate |
snipara config | View resolved config or file path | snipara config show |
snipara status | Show auth, config, and runtime status | snipara status |
snipara login | Authenticate via browser (device flow) | snipara login |
snipara logout | Clear stored tokens | snipara logout |
snipara query | Query documentation from the CLI | snipara query "auth" --max-tokens 8000 |
snipara sync | One-shot sync of local files | snipara sync --dry-run |
snipara watch | Watch and sync changes in real-time | snipara watch |
snipara initCreate or migrate .snipara.toml
Example: snipara init --migrate
snipara configView resolved config or file path
Example: snipara config show
snipara statusShow auth, config, and runtime status
Example: snipara status
snipara loginAuthenticate via browser (device flow)
Example: snipara login
snipara logoutClear stored tokens
Example: snipara logout
snipara queryQuery documentation from the CLI
Example: snipara query "auth" --max-tokens 8000
snipara syncOne-shot sync of local files
Example: snipara sync --dry-run
snipara watchWatch and sync changes in real-time
Example: snipara watch
File Watcher
The snipara watch command uses watchfiles (Rust-based, cross-platform, async) to monitor your project for file changes and automatically sync them to Snipara.
snipara watchWatching /project (2 include, 4 exclude patterns)Synced: docs/api.mdSynced: docs/auth.mdConfigure patterns in the [sync] section of .snipara.toml:
[sync]include = ["docs/**/*.md", "*.md", "src/**/*.py"]exclude = ["node_modules/**", ".git/**", "dist/**"]debounce_ms = 500Dry run
Lists files, no uploads
snipara sync --dry-runOne-shot
Syncs all files once, then exits
snipara syncWatch
Continuous sync on file changes
snipara watchKey behaviors
- Debounce: Configurable via
sync.debounce_ms(default 500ms) - Binary files: Automatically skipped with a warning
- Upload errors: Logged but don't stop the watcher
- Exclude patterns checked first, then include patterns
Relationship to snipara-mcp
The snipara SDK wraps the snipara-mcp HTTP client internally. All API calls go through snipara_mcp.rlm_tools.SniparaClient — there is no HTTP duplication.
The SDK adds on top of snipara-mcp: unified .snipara.toml configuration, the snipara CLI, file watcher/sync, rlm-runtime integration, and the auto-feedback loop. It is not a replacement but a higher-level abstraction. You can still use snipara-mcp directly for MCP server connections (Claude Code, VS Code, Cursor, etc.).