Skip to main content

OmniFocus MCP server and CLI tool for macOS task management with AI assistants

Project description

pymnifocus

A Python toolkit for OmniFocus on macOS: an MCP server for AI assistant integration (Cursor, Claude, Gemini) and a standalone CLI query tool.

Inspired by themotionmachine/OmniFocus-MCP, rebuilt in Python with security hardening, a CLI, and PyPI packaging.

Prerequisites

  • macOS with OmniFocus installed and running
  • Python 3.10+
  • uv (recommended) or pip

Installation

# From PyPI
pip install pymnifocus

# Or with uv
uv pip install pymnifocus

# For development
git clone https://github.com/vdanen/pymnifocus.git
cd pymnifocus
uv sync
pip install -e .

CLI Query Tool

Query OmniFocus directly from your terminal with pymnifocus-query:

# Shorthand flags
pymnifocus-query --overdue
pymnifocus-query --flagged --sort dueDate
pymnifocus-query --inbox
pymnifocus-query --due-within 7 --limit 10
pymnifocus-query --project "Weekly Review"
pymnifocus-query --tag work --tag urgent
pymnifocus-query --available --summary
pymnifocus-query --today

# JSON input (same format as MCP query_omnifocus tool)
pymnifocus-query '{"entity": "tasks", "filters": {"status": ["Overdue", "DueSoon"]}, "sortBy": "dueDate"}'

# Pipe from stdin
echo '{"entity": "projects", "filters": {"status": ["Active"]}}' | pymnifocus-query

# Other tools
pymnifocus-query --tags
pymnifocus-query --perspectives
pymnifocus-query --dump

# Raw JSON output (for scripting)
pymnifocus-query --overdue --json

Run pymnifocus-query --help for full usage.

MCP Server

The MCP server enables AI assistants to interact with OmniFocus through natural language.

Running the Server

# Stdio transport (for Cursor/Claude/Gemini)
pymnifocus-server

# Or via module
python -m pymnifocus

Cursor Integration

Edit ~/.cursor/mcp.json:

{
  "mcpServers": {
    "omnifocus": {
      "command": "pymnifocus-server"
    }
  }
}

Or if using uv from a local clone:

{
  "mcpServers": {
    "omnifocus": {
      "command": "uv",
      "args": [
        "run",
        "--project",
        "/path/to/pymnifocus",
        "python",
        "-m",
        "pymnifocus.server"
      ]
    }
  }
}

Restart Cursor or reload MCP servers (Cmd+Shift+P -> "MCP: Restart Servers").

Claude Code Integration

Same as above, just edit ~/.claude.json.

Claude Desktop Integration

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "omnifocus": {
      "command": "pymnifocus-server"
    }
  }
}

Restart Claude Desktop.

Google AI Studio / Gemini

For MCP-compatible Gemini clients, the server uses stdio transport by default:

  • Command: pymnifocus-server

For Streamable HTTP (web-based clients):

python -c "from pymnifocus.server import mcp; mcp.run(transport='streamable-http')"

Then connect to http://localhost:8000/mcp.

Available MCP Tools

Tool Description
query_omnifocus Query tasks, projects, or folders with filters
dump_database Get full OmniFocus database state
add_omnifocus_task Add a new task
add_project Add a new project
remove_item Remove a task or project
edit_item Edit a task or project
batch_add_items Add multiple items at once (max 100)
batch_remove_items Remove multiple items at once (max 100)
list_perspectives List available perspectives
get_perspective_view Get items from a perspective
list_tags List all tags with hierarchy

MCP Resources

URI Description
omnifocus://inbox Current inbox items
omnifocus://today Today's agenda (due, planned, overdue)
omnifocus://flagged All flagged items
omnifocus://stats Database statistics
omnifocus://project/{name} Tasks in a project
omnifocus://perspective/{name} Items in a perspective

Example Prompts

  • "Show me all flagged tasks due this week"
  • "Add a task 'Review quarterly report' to my Work project, due Friday"
  • "What's in my inbox?"
  • "List all my projects"
  • "Create a project called 'Website Redesign' with 3 tasks"

How It Works

The server communicates with OmniFocus using:

  • OmniJS scripts executed via JXA (osascript -l JavaScript) for queries, dumps, perspectives, and tags
  • AppleScript for add/edit/remove operations

OmniFocus must be running for either the MCP server or the CLI tool to function.

Security

  • All user input is validated and escaped before embedding in generated scripts
  • Entity names, sort fields, and field names are whitelisted
  • Numeric parameters are validated as integers
  • AppleScript strings are sanitized against injection (quotes, backslashes, newlines)
  • Script paths are constrained to prevent directory traversal
  • Batch operations are capped at 100 items
  • Query results are capped at 5000 items
  • All communication is local (no network traffic)

License

MIT

Credits

Inspired by themotionmachine/OmniFocus-MCP. OmniJS scripts are adapted from that project.

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

pymnifocus-0.1.1.tar.gz (90.1 kB view details)

Uploaded Source

Built Distribution

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

pymnifocus-0.1.1-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file pymnifocus-0.1.1.tar.gz.

File metadata

  • Download URL: pymnifocus-0.1.1.tar.gz
  • Upload date:
  • Size: 90.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pymnifocus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d17c766913993197a77ebdbf876c4f453a289c9f4cc23c0736f89b5ed7dd60ff
MD5 4fbf135f55cb8a97f10fc271709d1501
BLAKE2b-256 01de52d16e88dd167176d65e9ea5933ab516a340718527726ead9774014a3c5d

See more details on using hashes here.

File details

Details for the file pymnifocus-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pymnifocus-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 35.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pymnifocus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c53392ec34f05cd2019f842e1d9716f726f7886b261f24155158a96e8f7d5fc4
MD5 07dfeb0145782d98761a4163280b0ad6
BLAKE2b-256 0977313e53851c6665cbb6f497eb238a207cfc2ceeddd2c1eb1c023aa89ee031

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