Agent-first IMAP CLI for safe email search, read, attachment download, and draft creation
Project description
imap-agent-cli
imap-agent-cli is an agent-first IMAP CLI for safe email search, read, attachment download, and draft creation.
It can inspect mailboxes and append messages to Drafts. It cannot send email, delete messages, move messages, archive messages, change labels, alter flags, or mark messages read/unread.
Using imap-agent-cli
Quick Start
Install or update the imap agent skill:
uvx imap-agent-cli install-skill
Configure the default IMAP account with environment variables:
IMAP_AGENT_CLI_HOST=imap.example.com
IMAP_AGENT_CLI_PORT=993
IMAP_AGENT_CLI_USERNAME=me@example.com
IMAP_AGENT_CLI_PASSWORD=your-password-or-app-password
IMAP_AGENT_CLI_TLS=true
Then ask your agentic tool to use the imap skill for mailbox search, email reading, attachment inspection/download, or draft creation.
Use From PyPI
Use the published CLI directly with uvx:
uvx imap-agent-cli --help
uvx imap-agent-cli folders
uvx imap-agent-cli search --subject invoice
Install it as a persistent uv tool when you want to call imap-agent-cli directly:
uv tool install imap-agent-cli
uv tool update-shell
imap-agent-cli --help
Restart your shell after uv tool update-shell if imap-agent-cli is not found.
Or install it into a Python environment:
python -m pip install imap-agent-cli
imap-agent-cli --help
All command payloads are JSON on stdout. Diagnostics and errors go to stderr.
Use imap-agent-cli --about for project URL and license attribution. Use imap-agent-cli --version to print only the version number.
Configuration
For a single account, environment variables are enough:
IMAP_AGENT_CLI_HOST=imap.example.com
IMAP_AGENT_CLI_PORT=993
IMAP_AGENT_CLI_USERNAME=me@example.com
IMAP_AGENT_CLI_PASSWORD=your-password-or-app-password
IMAP_AGENT_CLI_TLS=true
IMAP_AGENT_CLI_DRAFTS_FOLDER=Drafts
IMAP_AGENT_CLI_DRAFTS_FOLDER is optional. When omitted, the CLI tries to auto-detect the Drafts folder.
For multiple accounts, create a config file:
imap-agent-cli config init
imap-agent-cli config add-profile work --host imap.example.com --port 993 --username me@example.com --password-env IMAP_AGENT_CLI_WORK_PASSWORD
imap-agent-cli config set-default-profile work
The config file is stored at:
~/.imap-agent-cli/config.toml
Keep secrets in environment variables. The config file should reference password environment variable names, not contain passwords.
Agent Skill
The installed skill teaches an agentic tool how to use imap-agent-cli safely and effectively.
Install or update the user-scoped imap skill:
uvx imap-agent-cli install-skill
This writes:
~/.agents/skills/imap/SKILL.md
Remove the managed skill:
uvx imap-agent-cli remove-skill
Use --skills-dir PATH to install into a nonstandard skills directory:
uvx imap-agent-cli install-skill --skills-dir ~/.agents/skills
Safety Boundary
Allowed:
- list folders
- search messages
- read messages with no-seen fetch behavior
- list/download attachments only when requested
- append new messages to Drafts
Not allowed:
- send
- delete
- move
- archive
- flag/star
- mark read/unread
- create/delete/rename folders
Example Commands
These examples are mostly useful for validating configuration or debugging what an agentic tool is doing:
imap-agent-cli folders
imap-agent-cli search --folder INBOX --subject "invoice" --max-results 10
imap-agent-cli read --folder INBOX --uid 12345 --body-format html
imap-agent-cli attachments --folder INBOX --uid 12345
imap-agent-cli attachments download --folder INBOX --uid 12345 --part-id 2 --output-dir ./email-attachments
imap-agent-cli draft create --to person@example.com --subject "Hello" --body "Draft only."
imap-agent-cli draft reply --folder INBOX --uid 12345 --body "Thanks. I will review this."
Development
Local Development
Run the CLI from the repository:
uv run ./imap_agent_cli.py --help
uv run ./imap_agent_cli.py folders
uv run ./imap_agent_cli.py search --subject invoice
Build the package:
uv build --no-sources
Testing
Run no-network unit tests:
python -m unittest discover -v
Run the opt-in local IMAP integration test:
Set IMAP_AGENT_CLI_TEST_PYMAP=1 in your shell, then run:
uv run --extra test python -m unittest tests.test_pymap_integration -v
The integration test starts pymap dict --demo-data locally and logs in with demouser / demopass.
Project Status
This repo is under active development. The behavior target is defined in spec.md.
Publishing
The GitHub Actions workflow is .github/workflows/publish.yml.
PyPI Trusted Publishing values:
Project: imap-agent-cli
Owner: pseudosavant
Repository: imap-agent-cli
Workflow: publish.yml
Environment: pypi
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
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 imap_agent_cli-0.1.4.tar.gz.
File metadata
- Download URL: imap_agent_cli-0.1.4.tar.gz
- Upload date:
- Size: 32.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dff8d31939d3704a209213de613f7a042a8a123e24c3af7d491a7622998939ae
|
|
| MD5 |
1c731fe6a47d3662a25f249ca260c77f
|
|
| BLAKE2b-256 |
dba3e7691a15975dc13cc5649559a60329fb192cb919810719b3ae6dc27fc43e
|
Provenance
The following attestation bundles were made for imap_agent_cli-0.1.4.tar.gz:
Publisher:
publish.yml on pseudosavant/imap-agent-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imap_agent_cli-0.1.4.tar.gz -
Subject digest:
dff8d31939d3704a209213de613f7a042a8a123e24c3af7d491a7622998939ae - Sigstore transparency entry: 2028628373
- Sigstore integration time:
-
Permalink:
pseudosavant/imap-agent-cli@fa2163b56ff031886d11effab909d8296ea4a8eb -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/pseudosavant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fa2163b56ff031886d11effab909d8296ea4a8eb -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file imap_agent_cli-0.1.4-py3-none-any.whl.
File metadata
- Download URL: imap_agent_cli-0.1.4-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b63cdbb1889b840a32c322c0510480cc54a02abe8b08a73266834b4cd21d8ca
|
|
| MD5 |
7704b7c22dca1dfefb88ec9d8026843a
|
|
| BLAKE2b-256 |
f5fed777a847476f9b12a682613d93f1ac534f13e5a5d4e84336c17539a9e920
|
Provenance
The following attestation bundles were made for imap_agent_cli-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on pseudosavant/imap-agent-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imap_agent_cli-0.1.4-py3-none-any.whl -
Subject digest:
2b63cdbb1889b840a32c322c0510480cc54a02abe8b08a73266834b4cd21d8ca - Sigstore transparency entry: 2028628774
- Sigstore integration time:
-
Permalink:
pseudosavant/imap-agent-cli@fa2163b56ff031886d11effab909d8296ea4a8eb -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/pseudosavant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fa2163b56ff031886d11effab909d8296ea4a8eb -
Trigger Event:
workflow_dispatch
-
Statement type: