Code and repositories / Monorepos
Let an agent open a monorepo pull request
Your agent changed several members, and you want to review its changes as one monorepo pull request. The agent opens it with one MCP call, and only a person merges it.
2 min read
You need an agent with a session on the monorepo.
1. The agent pushes a branch to each member
The agent pushes a branch to each member that it changes. A session pushes only to agent/<session>/... branches.
2. The agent opens the monorepo pull request
The agent calls the MCP tool create_monorepo_pull, with one part for each folder:
{
"owner": "acme",
"repo": "platform",
"title": "Add the field",
"body": "The API gets the field, and the docs explain it.",
"parts": [
{ "folder": "web", "head": "agent/3f9c2a1b7d4e6f80/add-field", "title": "Add the field to the API" },
{ "folder": "docs", "head": "agent/3f9c2a1b7d4e6f80/add-field", "title": "Document the field" }
]
}
3. You review and merge it
Review the parts and merge them, as in steps 3 and 4 of Change several members in one pull request.
Important
Only a person merges it. The forge refuses a merge or a retry from an agent.
Done
The changes of your agent are one monorepo pull request, and you merge all its parts with one action.
Tools and routes
The agent can use these tools and routes:
| What | MCP tool | REST route |
|---|---|---|
| Open one | create_monorepo_pull | POST /api/v1/repos/acme/platform/monorepo-pulls |
| Read one, with each part | get_monorepo_pull | GET /api/v1/repos/acme/platform/monorepo-pulls/12 |
| List them | list_monorepo_pulls | GET /api/v1/repos/acme/platform/monorepo-pulls |
| Add an open pull request as a part | add_monorepo_part | POST /api/v1/repos/acme/platform/monorepo-pulls/12/parts |
| Close one | close_monorepo_pull | PATCH /api/v1/repos/acme/platform/monorepo-pulls/12 with {"state": "closed"} |
The tools for people only are merge_monorepo_pull (PUT .../monorepo-pulls/12/merge) and retry_monorepo_merge (POST .../monorepo-pulls/12/retry).