Skip to content

bug: MCP-created agents not registered in backend DB (ownership table) #71

Description

@vybe

Summary

When creating an agent via the MCP server using a github:owner/repo template, the agent container is created and the repo is cloned correctly, but the agent is not registered in the backend's agent_ownership table. This means subscription assignment, auth reports, and other backend-managed features fail with "Agent not found in ownership table". Conversely, creating via the backend API registers in the DB but does not handle github: templates (no repo cloning).

Component

MCP Server / Backend — Agent Creation

Priority

P2

Error

{"detail": "Agent not found in ownership table"}

Occurs when calling PUT /api/subscriptions/agents/{name} on an agent created via MCP create_agent with a GitHub template.

Location

  • MCP Server: Agent creation via create_agent tool — creates Docker container directly without notifying the backend DB
  • Backend API: POST /api/agents — registers in DB but ignores github: template format (no repo cloning)

Root Cause

The MCP server and backend API have separate agent creation paths that are not synchronized:

  1. MCP create_agent: Creates Docker container, clones GitHub repo into workspace, sets up .claude/ config. Does NOT insert a row into agent_ownership in the backend DB.
  2. Backend POST /api/agents: Inserts into agent_ownership, creates Docker container. Does NOT handle github:owner/repo template format for cloning repos.

This means there is no single creation path that both registers the agent in the DB and clones from a GitHub template.

Reproduction Steps

  1. Configure a GitHub PAT in Trinity settings
  2. Via MCP, call create_agent with template: "github:owner/repo"
  3. Agent container is created with repo cloned into workspace
  4. Try to assign a subscription via PUT /api/subscriptions/agents/{name}
  5. Fails with "Agent not found in ownership table"
  6. Verify with GET /api/agents — the MCP-created agent is not listed

Suggested Fix

Two possible approaches:

Option A (Preferred): Have the MCP server call the backend API to create agents instead of creating Docker containers directly. This ensures the backend DB is always the source of truth.

Option B: Have the backend API support github:owner/repo template format in POST /api/agents, performing the same repo cloning that the MCP server does.

Either way, the goal is a single creation path that handles both DB registration and GitHub template cloning.

Environment

  • Trinity version: f50ee3e
  • Docker version: 24.0
  • OS: Ubuntu 22.04

Related

  • MCP server agent creation logic
  • Backend POST /api/agents endpoint
  • agent_ownership table
  • Subscription assignment endpoint PUT /api/subscriptions/agents/{name}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions