Context Platform CLI
Project description
Context Platform CLI
Typer-powered command-line interface for managing Context Platform projects and items.
Note: Both
ctxandctxmecommands are available. They are identical - use whichever you prefer. Examples below usectx.
Installation
From the repo root (uv workspace):
uv sync --all-extras --all-groups
ctx will then be available via uv run ctx ... (or activate .venv and call directly).
Configuration
The CLI stores settings under the platform-specific config directory (see platformdirs). Override
the path in scripts/tests with the CTXME_CONFIG_DIR environment variable.
Key commands:
ctx config --api <url>– set the backend API base URL (switches to live mode)ctx config --mode mock|live– toggle between the built-in mock client and HTTP clientctx set-project <project>– set the default project keyctx auth login– device flow sign-in (opens browser, stores API key in keychain)ctx auth status– show stored API key prefix + backend metadatactx auth set-key <key>– manually persist API keys using the OS keychainctx auth logout– remove stored API key
API keys are never written to disk; only stored through keyring.
For local development, you can set CLI__API_KEY to override the keychain without
modifying OS credentials. This value is read from the process environment only
(not from .env files) and is visible in process listings, so use it for local
testing only.
Commands
ctx ls– list items for the default (set-project) or--projectprojectctx get <item>– download an item to the current directory (file items use original filename;--stdout/--clipboardonly for text MIME types)ctx put <item> --data "<text>"– create or update an item (--title,--tagoptional)ctx put <item> --file <path>– upload a file as a context itemctx remove <item>– delete an item (use--forceto skip confirmation)ctx search <query>– search for items (see Search Modes below)ctx projects list/ctx projects ls– list available projectsctx projects current– show the current default project (local only)ctx set-project <project>– set the default project keyctx status– show local config + auth status (no API call)
All commands emit Rich-formatted tables/panels with user-friendly messaging.
Search Modes
The search command intelligently determines which projects to search based on your configuration:
-
Explicit project search (using
--projectflag):ctx search "machine learning" --project my-research
Searches only the specified project.
-
Default project search (when default project is set):
ctx set-project my-main-project ctx search "API documentation"
Searches only your default project.
-
Implicit all-projects search (no default project configured):
# No default project set ctx search "kubernetes config" # Output: Searching across all projects (no default project set)
Automatically searches all projects with an informational message.
-
Explicit all-projects search (using
--allflag):ctx search "error handling" --all --limit 20
Searches across all projects regardless of default project configuration.
Note: The --project and --all flags are mutually exclusive. Use one or the other, not both.
If you have no projects yet, the search command will prompt you to create one:
ctx search "test"
# Output: No projects found. Create one with: ctx projects create <name>
Unified Context Items
The CLI uses a unified API that handles both inline text and file uploads:
- Inline content: Use
--datato provide text content directly - File uploads: Use
--fileto upload files (text files and PDFs supported)
When listing items, you'll see:
content_type: Whether the item isinlinetext or afileprocessing_status:ready(searchable),processing(being indexed), orfailed
Example:
# Create inline item
ctx put my-notes --data "Meeting notes from today"
# Upload a PDF file
ctx put quarterly-report --file ./report.pdf
# List items with processing status
ctx ls
Polling for Processing Status
When uploading PDFs, processing happens asynchronously. You can poll for completion:
# Upload a PDF (returns 202 Accepted with processing status)
ctx put my-document --file document.pdf
# Use ctx ls to check processing status
ctx ls
Alternatively, rerun ctx ls until the status shows ready or failed.
Environment Variables
| Variable | Description |
|---|---|
CTXME_DEBUG |
Set to 1 to enable debug output (shows API URL, mode, and full tracebacks on errors) |
CTXME_CONFIG_DIR |
Override the default config directory path |
CTXME_CACHE_DIR |
Override the default cache directory path |
CTXME_UPDATE_CHECK |
Set to 0, false, or no to disable automatic update checks at startup |
CTXME_UPDATE_CHECK_INTERVAL |
Override the update check interval in seconds (default: 86400 / 24 hours) |
CLI__API_BASE_URL |
Override the backend API URL (takes precedence over config file) |
CLI__API_KEY |
Override the API key (process env only; takes precedence over keychain) |
CLI__DEFAULT_PROJECT |
Override the default project (takes precedence over config file) |
CLI__USE_MOCK_CLIENT |
Set to true to use the mock client |
Example: Use CLI__API_KEY for local testing
# Local testing without touching the keychain
export CLI__API_KEY="ctxme_a74558fa64f4a99a5666a47b4954ea99"
export CLI__API_BASE_URL="http://localhost:8000"
uv run ctx ls
# Return to keychain-based auth
unset CLI__API_KEY
Example: View full configuration details
CTXME_DEBUG=1 ctx status
# Output:
# API: https://api.example.com
# Mode: live
# Auth: Signed in
# Project: my-project (default)
When ctx get saves to a directory, it sanitizes item keys into safe filenames (no path
separators or ..).
Tests
uv run pytest cli/tests
Tests cover configuration round-trips, keyring helpers (via an in-memory backend), and representative Typer command flows.
Shell Completion
Enable tab completion for commands, subcommands, and flags. Works for both ctx and ctxme.
Installation
Bash:
ctx --install-completion bash
# or: ctxme --install-completion bash
Zsh:
ctx --install-completion zsh
Fish:
ctx --install-completion fish
PowerShell:
ctx --install-completion powershell
Usage
ctx <TAB> # Shows: auth, config, get, ls, put, ...
ctx auth <TAB> # Shows: login, logout, status, set-key
ctx get --<TAB> # Shows: --project, --dest, --stdout, --force, ...
Troubleshooting
- Restart shell after installation
- Ensure completion script is sourced in shell config
- Check
ctx --show-completion <shell>for manual setup
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 ctxme-0.1.7.tar.gz.
File metadata
- Download URL: ctxme-0.1.7.tar.gz
- Upload date:
- Size: 84.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9e1b4b67e553ff464f2e822ed717527c61b86e5a6b66f48c98e86e8363e2895
|
|
| MD5 |
596185ecb3726e2cc1776deeae19b1a6
|
|
| BLAKE2b-256 |
746c38e7b0d07c6b11cc842d5df94b24f239f4598cecc8490d5075dae8a1fa11
|
File details
Details for the file ctxme-0.1.7-py3-none-any.whl.
File metadata
- Download URL: ctxme-0.1.7-py3-none-any.whl
- Upload date:
- Size: 59.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6013c2b6a0e6925f6a20b13b0f219672632c547b2771f42de5668929440b935
|
|
| MD5 |
a1328843453888693cb4d719b6478029
|
|
| BLAKE2b-256 |
ec146739967ec5004082b49d09f23128803ef11f50e5f8ff1a0ec5045d0116ca
|