Skip to main content
Glama
README.md
# workorder-mcp

Repository-local workorder tracking for coding agents over the Model Context
Protocol.

Each project stores its workorders in:

```text
<project-root>/.agents/workorders.sqlite
```

The project root is found by walking upward from the server process's current
working directory to the nearest directory containing `.git` or an
`.agents/workorders.sqlite` database. If neither marker exists, the current
working directory is used.

A fresh project without Git starts from the current directory on first run.
After the database exists, launches from nested directories resolve back to that
project root. The search stops before the user's home directory, so a global
`~/.agents` directory or a dotfiles Git repository cannot capture unrelated
projects.

## Features

- Named workorder groups with generated shorthands: `A`, `B`, ... `Z`, `AA`,
  `AB`, ...
- Per-group workorder IDs such as `A-1`, `A-2`, and `B-1`
- Workorder kinds: `feature`, `bug`, `task`, `chore`
- Workorder statuses: `open`, `in_progress`, `blocked`, `done`, `cancelled`
- Compact list responses with separately retrievable long descriptions
- Append-only workorder history enforced by SQLite triggers
- Editable observations with optional cross-workorder links
- Project-local isolation; no global database
- SQLite WAL mode, foreign keys, schema versioning, and transactional numbering

## Installation

Using a virtual environment:

```bash
git clone https://github.com/jlitewski/workorder-mcp.git
cd workorder-mcp
python -m venv .venv
source .venv/bin/activate
python -m pip install -e .
```

On Windows, activate with `.venv\Scripts\activate`.

After activation, run the server with:

```bash
workorder-mcp
```

You can also run the package directly:

```bash
python -m workorder_mcp
```

## Install once for all projects

For normal use, the server only needs to be installed once. Each OpenCode
workspace starts its own server process in that workspace, which gives each
project a separate database.

Option 1: install it on `PATH` and use the `workorder-mcp` command directly.

Option 2: install the built wheel into a stable per-user environment:

```bash
python -m venv ~/.local/share/workorder-mcp/venv
~/.local/share/workorder-mcp/venv/bin/python -m pip install \
  /path/to/workorder-mcp/dist/workorder_mcp-*.whl
mkdir -p ~/.local/bin
ln -sf ~/.local/share/workorder-mcp/venv/bin/workorder-mcp \
  ~/.local/bin/workorder-mcp
```

Then use `workorder-mcp` in OpenCode if `~/.local/bin` is on `PATH`; otherwise
use the absolute path to the executable. On Windows, use a normal per-user
virtual environment and add its `Scripts` directory to `PATH`.

### Build distributions

```bash
python -m build
```

This creates a wheel and source distribution under `dist/`.

## OpenCode configuration

Add the MCP server to the project or global OpenCode configuration. Leave the
working directory at its default so each workspace gets its own database.

```jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "workorder": {
        "type": "local",
        "command": ["workorder-mcp"]
      }
    }
  }
}
```

If `workorder-mcp` is not on `PATH`, replace the command with the absolute path
to the executable installed in your environment.

You can also add it with the OpenCode CLI:

```bash
opencode mcp add workorder --global -- "$(command -v workorder-mcp)"
```

Do not set `pool: true` for this server. A shared connection would prevent each
workspace from resolving its own project-local database. OpenCode starts local
MCP servers in the workspace directory by default, which is the intended
behavior. Do not set `cwd` to the server repository or another fixed directory.

## Database override

`WORKORDER_DB_PATH` overrides the automatically discovered location:

```bash
WORKORDER_DB_PATH=/path/to/workorders.sqlite workorder-mcp
```

The CLI also supports an explicit path:

```bash
workorder-mcp --db /path/to/workorders.sqlite
```

## Tools

| Tool | Purpose |
| --- | --- |
| `createGroup` | Create a group and return its generated shorthand |
| `getGroupBrief` | Return only a group's brief |
| `getGroupDesc` | Return a group's long description, or `""` |
| `listGroups` | List compact group summaries |
| `createWorkorder` | Create a workorder with a group-number ID |
| `getWorkorder` | Return full workorder details |
| `listWorkorders` | List compact summaries, filterable by group, status, and kind |
| `updateWorkorder` | Update fields and append history |
| `getWorkorderHistory` | Return immutable history, newest first |
| `addObservation` | Attach durable context to a workorder |
| `updateObservation` | Edit observation text or its related-workorder link |
| `listObservations` | List observations chronologically |

### Group shorthands

Shorthands use bijective base-26 numbering:

```text
A ... Z, AA ... AZ, BA ... ZZ, AAA ...
```

Group names are case-insensitive. Existing shorthands are reserved as group
names, and a generated shorthand skips names already used by other groups. A
group may share its own shorthand.

### Workorder IDs

Workorders use a stable, immutable public ID composed of the group shorthand and
a per-group sequence:

```text
A-1
A-2
B-1
```

### History

History is append-only and enforced with SQLite triggers. Updates record only
the fields that changed. Observation events record the observation ID and
changed field names without duplicating observation text.

### Observations

Observations are editable but cannot be deleted. Each observation can
optionally link to a related workorder:

```text
addObservation(
  workorder_id="C-4",
  observation="A-1 implemented the shared parser API that this task should reuse.",
  related_workorder_id="A-1"
)
```

Set `clear_related_workorder=true` on `updateObservation` to remove an
existing link.

### Limits

| Field | Limit |
| --- | --- |
| Group name | 100 characters |
| Group brief | 500 characters |
| Group description | 100,000 characters |
| Workorder title | 200 characters |
| Workorder brief | 500 characters |
| Workorder description | 100,000 characters |
| Observation | 20,000 characters |
| Page size | 100 items maximum |

Text fields reject NUL characters. IDs and pagination offsets are bounded to
safe SQLite ranges.

## Agent workflow

See [docs/agent-usage.md](docs/agent-usage.md) for a recommended workflow. A
project instruction template is available at
[docs/project-AGENTS.md](docs/project-AGENTS.md).

## Backup

The database is a normal SQLite file. Use SQLite's backup command while the
server is idle:

```bash
sqlite3 .agents/workorders.sqlite \
  ".backup '.agents/workorders-backup.sqlite'"
```

The `-wal` and `-shm` files are part of normal WAL operation and should not be
copied independently while the server is running.

## Development

```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'
pytest
ruff check .
```

On Windows, activate with `.venv\Scripts\activate`.

The test suite includes:

- Shorthand boundary and round-trip tests
- Project-root and database-isolation tests
- Schema, migration, and integrity tests
- Group, workorder, history, and observation behavior
- In-memory MCP tool tests
- Real stdio subprocess tests
- Concurrent group and workorder creation tests

## Requirements

- Python 3.11 or newer
- SQLite with `STRICT` table and JSON function support

## License

MIT. See [LICENSE](LICENSE).

TDQS

A3.6/5.0

Scored across 12 tools

Disambiguation4/5

Three clear resource families (groups, workorders, observations) each have distinct list/get/create/update operations. The only mild overlap is getGroupBrief vs getGroupDesc, which are separated by an explicit note pointing to each other, and getWorkorder vs getWorkorderHistory is well clarified by the guidance in descriptions.

Naming Consistency5/5

All twelve tools follow a consistent camelCase verb_noun pattern (createGroup, getGroupDesc, listGroups, updateObservation, etc.). Plural list vs singular get conventions are applied uniformly across all three resource families.

Tool Count4/5

Twelve tools is well within the sensible range for a workorder domain spanning groups, workorders, and observations. The one minor excess is splitting group retrieval into brief/desc/list variants, which could arguably be a single call with a verbosity flag.

Completeness3/5

Read and create/update coverage is solid, including history and cross-workorder links, but there is no delete or archive operation for groups, workorders, or observations, and no explicit status/close transition for workorders. Agents can append history and edit fields but cannot remove stale records, creating dead ends for lifecycle management.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues