Skip to content

About

APM is a self-hosted, SQLite-backed MCP server with an optional embedded Web UI for coordinating coding-agent work across projects, milestones, and tasks.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

APM — Agent Project Manager

APM is a self-hosted, SQLite-backed MCP server with an optional embedded Web UI for coordinating coding-agent work across projects, milestones, and tasks.

Projects are uniquely identified by their folder path on your machine. Agents check or create a project by path, plan milestones and task dependencies, claim ready tasks, and report completion evidence. Enable the built-in Web UI when you want live visibility, project import/export, archiving, trash recovery, and permanent deletion.

APM is designed for trusted users and agents. A token grants access to the MCP tools; it is not a per-project authorization boundary. Protect the endpoint and the database as you would the project information they contain.

Features

  • Single Rust binary & tiny Docker image: Streamable HTTP MCP server (/mcp), bundled SQLite in WAL mode, and embedded Web UI with zero external runtime dependencies.
  • Bearer-token MCP access: /mcp requires a named, revocable token by default. Create tokens in the Web UI or with the CLI; only their SHA-256 hashes are stored. Optional IP/CIDR allowlist (APM_ALLOWED_IPS) and TLS enforcement (APM_REQUIRE_TLS) add further protection.
  • Folder path as project UID: Agents pass the workspace folder path (project_path) to get_project and receive full project state or { "exists": false }.
  • Optional Web UI (off by default): Disabled by default (APM_WEB_UI=false) so the first-visit admin setup form is never left exposed accidentally. When enabled, first visit prompts you to create an admin username and password (PBKDF2-HMAC-SHA256 salted hash in SQLite).
  • Safe deletion model: Agent deletions (delete_project) are always soft-deletions (moved to Trash). Only an admin in the Web UI (or CLI) can restore or permanently delete a project.
  • Real-time UI updates: Server-Sent Events (/api/events) push live workspace updates and in-app notifications while the Web UI is open.
  • Portable JSON export & import: Transfer projects (briefs, plans, dependencies, completion evidence, commit hashes) via the Web UI, MCP tools, or CLI without overwriting existing IDs.

Quick Start (Docker Compose)

Requirements

  • Docker and Docker Compose

Run

  1. Copy .env.example to .env and adjust settings if needed:

    cp .env.example .env

    To enable the Web UI, set APM_WEB_UI=true in .env.

  2. Build and start the container (configured with restart: always and a persistent /data volume):

    docker compose up -d --build
  3. Create an access token for each agent or machine (see MCP Integration). With the Web UI off, run:

    docker exec apm apm token-create laptop
  4. Connect your MCP client to http://127.0.0.1:39271/mcp (or your reverse-proxy HTTPS URL, e.g. https://apm.example.com/mcp) with the token in an Authorization: Bearer header.

Baremetal Installation

Requirements

  • Rust and Cargo
  • A C compiler (for the bundled SQLite library)

Build and Run

cargo build --release
cp .env.example .env
./target/release/apm

apm automatically reads .env from the current working directory (without overriding already-exported environment variables). Override the .env file location with APM_ENV_FILE=/path/to/.env.

Reverse Proxy with HTTPS (Nginx)

APM works out of the box behind custom-domain reverse proxies such as Nginx, Caddy, or Traefik.

  1. Set the following in .env:

    APM_HOST_BIND=127.0.0.1
    APM_WEB_UI=true
    APM_TRUST_PROXY=true
    APM_REQUIRE_TLS=true
  2. Proxy to 127.0.0.1:39271 with standard forwarding headers and SSE buffering disabled:

    server {
        listen 443 ssl http2;
        server_name apm.example.com;
    
        # ssl_certificate / ssl_certificate_key ...
    
        location / {
            proxy_pass http://127.0.0.1:39271;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host;
            proxy_buffering off;
            proxy_read_timeout 3600s;
        }
    }

With APM_REQUIRE_TLS=true and APM_TRUST_PROXY=true, APM rejects plain HTTP requests on both the Web UI and /mcp, sends Strict-Transport-Security, and marks session cookies Secure.

APM itself does not terminate TLS. Enable APM_TRUST_PROXY only when clients cannot bypass a trusted proxy, and configure that proxy to replace forwarded headers rather than trusting values supplied by clients. Other processes that can connect directly to the listening socket can also supply those headers. The unauthenticated /healthz endpoint is exempt from the TLS and IP checks.

Configuration (.env)

Variable Default Description
APM_BIND 127.0.0.1 Bind address for baremetal (compose.yaml binds 0.0.0.0 inside the container).
APM_HOST_BIND 127.0.0.1 Host interface Docker Compose publishes the port on.
APM_PORT 39271 HTTP listening port.
APM_DB_PATH ./apm.db SQLite database path (/data/apm.db in Docker).
APM_WEB_UI false Enable (true) or disable (false) the Web UI.
APM_REQUIRE_TLS false Reject non-HTTPS connections for both Web UI and /mcp.
APM_TRUST_PROXY false Trust X-Forwarded-Proto, X-Real-IP, X-Forwarded-For, and X-Forwarded-Host.
APM_MCP_AUTH true Require a valid bearer token for /mcp. Set false to allow unauthenticated agents (only if access is controlled elsewhere).
APM_ALLOWED_IPS (empty) Optional comma-separated IPv4/IPv6 addresses or CIDR blocks (e.g. 127.0.0.1,::1,192.0.2.0/24).
APM_ALLOWED_HOSTS (empty) Optional comma-separated Host allowlist for /mcp. Empty accepts any host.
APM_ALLOW_AGENT_LIST_PROJECTS true Allow agents to call list_projects and export_all_projects. When false, agents can only access projects by project_path.

Web UI & Admin Recovery

When APM_WEB_UI=true:

  • On first visit, APM prompts you to create an admin username and password (minimum 8 characters).
  • Credentials are salted and hashed with PBKDF2-HMAC-SHA256 (600,000 iterations) in SQLite. No admin credentials are stored in .env.
  • Sessions use HttpOnly, SameSite=Strict cookies (plus Secure under TLS), and mutating API routes enforce same-origin CSRF checks and login rate-limiting.

Resetting Admin Credentials

If you forget your Web UI password, reset the admin account via CLI:

# Docker
docker exec apm apm reset-admin

# Baremetal
./target/release/apm reset-admin

This clears the stored admin account and invalidates all active sessions so your next visit shows the setup form again.

MCP Integration

Point your MCP client at the Streamable HTTP endpoint and send a bearer token:

{
  "mcpServers": {
    "apm": {
      "type": "http",
      "url": "http://127.0.0.1:39271/mcp",
      "headers": {
        "Authorization": "Bearer apm_..."
      }
    }
  }
}

Access Tokens

  • Create: Open MCP endpoint in the Web UI, name the token (for example, the machine or agent), and copy it. The secret is shown once.

  • Manage: The same dialog lists tokens with their prefix and last-used date. Revoke one to cut off that client immediately.

  • CLI: Use this when the Web UI is off or you are running headless:

    apm token-create NAME [DATABASE_PATH]     # prints the secret once
    apm token-list [DATABASE_PATH]
    apm token-revoke TOKEN_ID [DATABASE_PATH]
  • Storage: Tokens are 256-bit random values with an apm_ prefix. APM stores only their SHA-256 hashes, so a copy of the database does not reveal usable tokens.

  • Missing or invalid tokens receive 401 Unauthorized with a WWW-Authenticate: Bearer header.

  • Disabling: Set APM_MCP_AUTH=false to turn off token checks. Do this only when the endpoint is reachable only by clients you trust.

Exposed MCP Tools

  • Discovery: get_project(project_path), list_projects(include_archived?)
  • Project setup & brief: create_project, update_brief, record_brief_approval, set_commit_policy
  • Planning & dependencies: add_milestone, add_task, update_task, add_dependency, remove_dependency, revise_plan, record_plan_approval, list_milestones, list_tasks, list_dependencies
  • Execution: list_ready_tasks, claim_task, release_task, complete_task, complete_milestone
  • Lifecycle & portability: archive_project, unarchive_project, delete_project (soft-delete to Trash), export_project, export_all_projects, import_projects

Brief/plan approvals, completion evidence, and commit hashes are agent-reported and not independently verified against Git.

Backups and upgrades

The SQLite database contains projects, admin credentials and token hashes. Keep backups private. The database uses WAL mode, so do not copy just the main database file while APM or another process has it open.

For Docker Compose, stop APM and any other process accessing the volume, then copy the entire data directory, including any SQLite sidecar files:

docker compose stop
docker cp apm:/data ../apm-backup
docker compose start

Store the backup outside the repository. To restore, stop all database users and restore the complete data directory to the volume, preserving permissions so the container's user (UID 10001) can read and write it. For bare-metal installs, stop all database users and back up the directory containing APM_DB_PATH, including its sidecar files. Test restoration in a separate environment before relying on a backup.

The JSON export/import tools are useful for transferring projects, but are not a full database backup: exports omit deleted projects and active task claims, and do not include admin accounts or MCP tokens. Imports do not overwrite existing project paths or IDs.

Before upgrading, take a database backup and review the release notes. Rebuild the Compose image with docker compose up -d --build, or rebuild and replace the bare-metal binary. Keep the backup until the upgraded installation has been verified.

CLI Administration

All administrative commands read APM_DB_PATH from .env by default, or accept an explicit database path as the final argument:

apm reset-admin [DATABASE_PATH]
apm export-all [DATABASE_PATH] > projects.json
apm export-project /path/to/project [DATABASE_PATH] > project.json
apm import projects.json [DATABASE_PATH]
apm archive /path/to/project [DATABASE_PATH]
apm unarchive /path/to/project [DATABASE_PATH]
apm soft-delete /path/to/project [DATABASE_PATH]
apm restore /path/to/project [DATABASE_PATH]
apm hard-delete /path/to/project [DATABASE_PATH]
apm release-task TASK_ID [DATABASE_PATH]
apm set-commit-policy /path/to/project required|optional [DATABASE_PATH]
apm token-create NAME [DATABASE_PATH]
apm token-list [DATABASE_PATH]
apm token-revoke TOKEN_ID [DATABASE_PATH]

Development

Run the unit and integration tests:

cargo test

See CONTRIBUTING.md for the full set of checks and SECURITY.md for private vulnerability reporting.

Troubleshooting

  • MCP returns 401: Create a token and send it as a Bearer token. Check that it has not been revoked and that the client reaches the intended server.
  • Requests return 403 behind a proxy: Check the IP and host allowlists and, if TLS is required, the trusted proxy configuration and forwarded headers.
  • The Web UI is unavailable: Set APM_WEB_UI=true and restart APM. Check the bind address and port if the server cannot be reached at all.
  • Docker cannot write the database: Check ownership and permissions on the data volume; the container runs as UID 10001.

License

MIT

About

APM is a self-hosted, SQLite-backed MCP server with an optional embedded Web UI for coordinating coding-agent work across projects, milestones, and tasks.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages