ensure_project
Create or confirm a project from an absolute path-like human key, ensuring a stable project record and archive for agents to share the same workspace identity.
Instructions
Idempotently create or ensure a project exists for the given human key.
When to use
First call in a workflow targeting a new repo/path identifier.
As a guard before registering agents or sending messages.
How it works
Validates that
human_keyis an absolute path-like project key (typically the agent's working directory). It need not exist on the local filesystem: it is an opaque project KEY, and collaborating agents may not share a filesystem.Computes a stable slug from
human_key(lowercased, safe characters) so multiple agents can refer to the same project consistently.Ensures DB row exists and that the on-disk archive is initialized (e.g.,
messages/,agents/,file_reservations/directories).
CRITICAL: Project Identity Rules
The
human_keyMUST be an absolute path-like project key (typically the agent's working directory path)Two agents working in the SAME directory path are working on the SAME project
Example: Both agents in /data/projects/smartedgar_mcp → SAME project
Sibling projects are DIFFERENT directories (e.g., /data/projects/smartedgar_mcp vs /data/projects/smartedgar_mcp_frontend)
Parameters
human_key : str An absolute path-like project key (e.g., "/data/projects/backend"), typically the agent's working directory. This MUST be an absolute path, not a relative path or arbitrary slug, but it does NOT need to exist on the local filesystem - it is an opaque project KEY (collaborating agents may not share a filesystem). This is the canonical identifier for the project - all agents using the same key share the same project identity. identity_mode : str, optional Per-call override of the server's PROJECT_IDENTITY_MODE setting; one of "dir", "git-remote", "git-common-dir", "git-toplevel". Only takes effect when worktree-friendly identity is enabled (WORKTREES_ENABLED=1).
Returns
dict Minimal project descriptor: { id, slug, human_key, created_at }.
Examples
JSON-RPC:
{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/call",
"params": {"name": "ensure_project", "arguments": {"human_key": "/data/projects/backend"}}
}Common mistakes
Passing a relative path (e.g., "./backend") instead of an absolute path
Using arbitrary slugs instead of the actual working directory path
Creating separate projects for the same directory with different slugs
Idempotency
Safe to call multiple times. If the project already exists, the existing record is returned and the archive is ensured on disk (no destructive changes).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | ||
| human_key | Yes | ||
| identity_mode | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||