Keep big MCP responses out of your context window. Query them.
Project description
Sift
Sift is a local, single-tenant gateway for AI agent tool work. It reduces context bloat by persisting tool output as artifacts and returning only what the agent needs inline.
Use it with agents over MCP, or run it directly in CLI workflows.
One Command, Two Modes
Sift uses one command handle: sift-gateway.
| Mode | How you run it | What it does |
|---|---|---|
| MCP gateway mode | sift-gateway |
Mirrors upstream MCP tools and persists outputs as artifacts |
| CLI mode | sift-gateway run / sift-gateway code |
Captures command output and runs Python over persisted artifacts |
These modes are independent. You can run only MCP mode, only CLI mode, or both.
MCP Gateway Mode
Use this when an agent/client talks to tools over MCP.
Quick start
pipx install sift-gateway
sift-gateway init --from claude
sift-gateway --check
Then restart your MCP client.
--from shortcuts:
claude, claude-code, cursor, vscode, windsurf, zed, auto
(or pass an explicit config path).
Common gateway commands
sift-gateway --help
sift-gateway upstream add '<json>' --from claude
sift-gateway install pandas
sift-gateway uninstall pandas
sift-gateway --transport sse --host 127.0.0.1 --port 8080
Runtime behavior
- Mirrors upstream MCP tools with original schemas.
- Persists mirrored outputs as artifacts.
- Returns either:
response_mode="full"(inline payload), orresponse_mode="schema_ref"(artifact_id+ compact schema).
- For paginated upstream results, always returns
schema_refandpagination.next_actionwithartifact(action="next_page", ...).
CLI Mode
Use this when you want artifact workflows directly in terminal automation.
Quick start
pipx install sift-gateway
sift-gateway run -- echo '{"items":[{"id":1,"name":"a"}]}'
Capture sources
# Capture command output
sift-gateway run -- git status --porcelain
# Capture stdin
cat payload.json | sift-gateway run --stdin
Continuing paginated captures
If sift-gateway run reports pagination.has_next_page=true, continue with:
# first capture
sift-gateway run -- gh api repos/org/repo/pulls --limit 100 --after CUR_1
# follow-up capture linked to previous page
sift-gateway run --continue-from art_123 -- gh api repos/org/repo/pulls --limit 100 --after CUR_2
In MCP mode, continuation is artifact(action="next_page", artifact_id=...).
In CLI mode, continuation is manual via run --continue-from.
Analyze artifacts with Python
# single-artifact expression
sift-gateway code art_123 '$.items' --expr 'len(df)'
# single-artifact full function
sift-gateway code art_123 '$.items' --code 'def run(data, schema, params): return {"rows": len(data)}'
# multi-artifact expression
sift-gateway code --artifact-id art_users --artifact-id art_orders --root-path '$.items' --expr 'len(df)'
# multi-artifact file mode
sift-gateway code --artifact-id art_users --artifact-id art_orders --root-path '$.users' --root-path '$.orders' --file ./join.py
--expr always receives a pandas df DataFrame. In multi-artifact mode,
df is the concatenation of requested artifact rows, and
artifact_frames is available as a {artifact_id: DataFrame} mapping.
CLI mode uses local state in .sift-gateway by default.
Use --data-dir to target a different instance.
MCP Artifact Tool Contract
MCP retrieval is through the artifact tool:
action="query"withquery_kind="code"only.action="next_page"to fetch the next upstream page for an artifact chain.
Example query_kind="code":
artifact(
action="query",
query_kind="code",
artifact_id="art_123",
root_path="$.items",
code="def run(data, schema, params): return {'rows': len(data)}",
)
Example next_page:
artifact(
action="next_page",
artifact_id="art_123",
)
Response Modes
Sift chooses between two response modes:
full: inline payloadschema_ref:artifact_id+schemas_compact+schema_legend
Selection rules:
- If pagination exists: always
schema_ref. - Else if full response exceeds
SIFT_GATEWAY_PASSTHROUGH_MAX_BYTES:schema_ref. - Else return
schema_refonly when schema payload is at least 50% smaller. - Otherwise return
full.
Configuration Highlights
| Env var | Default | Description |
|---|---|---|
SIFT_GATEWAY_DATA_DIR |
.sift-gateway |
Instance root directory |
SIFT_GATEWAY_PASSTHROUGH_MAX_BYTES |
8192 |
Inline response cap used by full/schema_ref mode selection |
SIFT_GATEWAY_CODE_QUERY_ENABLED |
true |
Enable code queries |
SIFT_GATEWAY_SECRET_REDACTION_ENABLED |
true |
Redact likely outbound secrets |
SIFT_GATEWAY_AUTH_TOKEN |
unset | Required for non-local HTTP binds |
Full reference: docs/config.md
Security Notes
- Code queries use AST/import/time/memory guardrails, not full OS sandboxing.
- Outbound secret redaction is enabled by default.
Disable code queries if needed:
export SIFT_GATEWAY_CODE_QUERY_ENABLED=false
More: SECURITY.md
Documentation
docs/quickstart.mddocs/config.mddocs/api_contracts.mddocs/recipes.mddocs/deployment.mddocs/errors.mddocs/observability.mddocs/architecture.mddocs/openclaw/README.md
Development
git clone https://github.com/lourencomaciel/sift-gateway.git
cd sift-gateway
uv sync --extra dev
UV_CACHE_DIR=/tmp/uv-cache uv run python -m ruff check src tests
UV_CACHE_DIR=/tmp/uv-cache uv run python -m mypy src
UV_CACHE_DIR=/tmp/uv-cache uv run python -m pytest tests/unit/ -q
License
MIT - see LICENSE.
Project details
Release history Release notifications | RSS feed
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 sift_gateway-0.2.5.tar.gz.
File metadata
- Download URL: sift_gateway-0.2.5.tar.gz
- Upload date:
- Size: 254.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c48d23e10cc17c7acd978864965a5d3c4bd5751630b8eae56352aaed558beb41
|
|
| MD5 |
3092add086dee260f0c3d27eece232ea
|
|
| BLAKE2b-256 |
6f990392f3a1d63c2fcda8c30e981844b93eaadbae325916619b5163d98bb50d
|
Provenance
The following attestation bundles were made for sift_gateway-0.2.5.tar.gz:
Publisher:
release.yml on lourencomaciel/sift-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sift_gateway-0.2.5.tar.gz -
Subject digest:
c48d23e10cc17c7acd978864965a5d3c4bd5751630b8eae56352aaed558beb41 - Sigstore transparency entry: 972556354
- Sigstore integration time:
-
Permalink:
lourencomaciel/sift-gateway@d389c0c56320a4ec76a19c902fa66d4d52335990 -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/lourencomaciel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d389c0c56320a4ec76a19c902fa66d4d52335990 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sift_gateway-0.2.5-py3-none-any.whl.
File metadata
- Download URL: sift_gateway-0.2.5-py3-none-any.whl
- Upload date:
- Size: 328.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f52f67762281070110c38baea72fe05ca3df778b58578164d6edc09599b7c3ea
|
|
| MD5 |
831b5bb8664041c6d3fec18db8360c5b
|
|
| BLAKE2b-256 |
43489b7a2b0094b836da08e7eae7741c2db2b8619801e534834eb013da2255ed
|
Provenance
The following attestation bundles were made for sift_gateway-0.2.5-py3-none-any.whl:
Publisher:
release.yml on lourencomaciel/sift-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sift_gateway-0.2.5-py3-none-any.whl -
Subject digest:
f52f67762281070110c38baea72fe05ca3df778b58578164d6edc09599b7c3ea - Sigstore transparency entry: 972556383
- Sigstore integration time:
-
Permalink:
lourencomaciel/sift-gateway@d389c0c56320a4ec76a19c902fa66d4d52335990 -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/lourencomaciel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d389c0c56320a4ec76a19c902fa66d4d52335990 -
Trigger Event:
push
-
Statement type: