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:
- 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.
- 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
- Configure a GitHub PAT in Trinity settings
- Via MCP, call
create_agent with template: "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/agents endpoint
agent_ownership table
- Subscription assignment endpoint
PUT /api/subscriptions/agents/{name}
Summary
When creating an agent via the MCP server using a
github:owner/repotemplate, the agent container is created and the repo is cloned correctly, but the agent is not registered in the backend'sagent_ownershiptable. 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 handlegithub:templates (no repo cloning).Component
MCP Server / Backend — Agent Creation
Priority
P2
Error
Occurs when calling
PUT /api/subscriptions/agents/{name}on an agent created via MCPcreate_agentwith a GitHub template.Location
create_agenttool — creates Docker container directly without notifying the backend DBPOST /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:
create_agent: Creates Docker container, clones GitHub repo into workspace, sets up.claude/config. Does NOT insert a row intoagent_ownershipin the backend DB.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
create_agentwithtemplate: "github:owner/repo"PUT /api/subscriptions/agents/{name}GET /api/agents— the MCP-created agent is not listedSuggested 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/repotemplate format inPOST /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
f50ee3eRelated
POST /api/agentsendpointagent_ownershiptablePUT /api/subscriptions/agents/{name}