Repository navigation
Description
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_agenttool — creates Docker container directly without notifying the backend DB - Backend API:
POST /api/agents— registers in DB but ignoresgithub:template format (no repo cloning)
Root Cause
The MCP server and backend API have separate agent creation paths that are not synchronized:
- MCP
create_agent: Creates Docker container, clones GitHub repo into workspace, sets up.claude/config. Does NOT insert a row intoagent_ownershipin the backend DB. - Backend
POST /api/agents: Inserts intoagent_ownership, creates Docker container. Does NOT handlegithub:owner/repotemplate 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
- Configure a GitHub PAT in Trinity settings
- Via MCP, call
create_agentwithtemplate: "github:owner/repo" - Agent container is created with repo cloned into workspace
- Try to assign a subscription via
PUT /api/subscriptions/agents/{name} - Fails with "Agent not found in ownership table"
- 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/agentsendpoint agent_ownershiptable- Subscription assignment endpoint
PUT /api/subscriptions/agents/{name}
Activity
vybe commentedon Mar 21, 2026
Closing — fixed since commit b457b1d (Dec 2025). MCP create_agent now calls the same POST /api/agents endpoint, ensuring register_agent_owner() runs for all creation paths.
fix(brain-orb): preserve selection across refresh + validate link end…
chore(.claude): bump the submodule pointer to main (f7ff3e7 -> 60ddc16)
chore(.claude): bump the submodule pointer to main (f7ff3e7 -> 60ddc1…