Skip to content

Add real MCP client identity instead of hardcoding all edits to agent 1 #37

@justrach

Description

@justrach

Problem

The HTTP interface supports agent registration, heartbeat, and advisory locking. The MCP interface does not expose agent identity and hardcodes all edits to agent 1.

This collapses multiple MCP clients into one logical writer and undermines the multi-agent coordination model already present in the codebase.

Why this matters

A core purpose of codedb2 is agent-driven codebase work. If MCP clients cannot identify themselves separately, lock ownership and provenance are not trustworthy under concurrent use.

Evidence

  • src/agent.zig has agent IDs, cursor/state, heartbeat, and advisory locks
  • src/mcp.zig hardcodes agent_id = 1 in handleEdit()
  • HTTP has explicit /agent/register, /agent/heartbeat, /lock, and /unlock

Expected outcome

Introduce proper MCP-side agent identity, either by:

  • exposing agent lifecycle/lock tools directly, or
  • binding a stable agent identity to each MCP session/connection

Acceptance

  • separate MCP clients do not share a synthetic writer identity
  • lock contention is enforced correctly across MCP clients
  • edit provenance records the real agent/session identity
  • tests cover concurrent MCP edit scenarios

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions