Repository navigation
Closed
Description
Context
The trigger primitive must be reachable over the ProPR MCP as well as HTTP and CLI, so a chat client ("run my competitor-scan agent now", "what did last night's triage agent report?") and external MCP-capable automation can drive Agents. MCP tools reuse all existing guarantees: scope checks, per-call repository authorization (McpPolicy.repository), owner scoping, durable idempotent receipts for mutations (McpOperations.run) and the access log (toolExecution.ts).
Requirements
New packages/api/mcp/toolsAgentRuns.ts (addAgentRunTools(tools, deps)), registered in createToolCatalog (packages/api/mcp/tools.ts):
| Tool | Scope | Notes |
|---|---|---|
list_agent_definitions |
read | Owner's definitions; optional repository filter; paged |
get_agent_definition |
read | Full definition incl. schedule, next run, capabilities, autonomy |
get_agent_definition_contract |
read | AGENT_DEFINITION_CONTRACT |
list_agent_runs |
read | Per definition, newest first, no report bodies |
get_agent_run |
read | Run incl. report (bounded by the 256 KB MCP result limit — truncate to 200 KB with reportTruncated: true and point to the UI link) |
trigger_agent_run |
execute | The trigger primitive. definitionId, optional source (≤255), idempotencyKey (mutation shape). Trigger kind mcp, cost-gated. |
approve_agent_run |
execute | runId, optional note; preview mode only |
reject_agent_run |
execute | runId |
Rules:
- Every tool that touches a definition authorizes every repository of the definition with
deps.policy.repository(principal, repo, isMutation); failure surfaces as the standardREPOSITORY_FORBIDDEN/NOT_FOUNDenvelope. A definition invisible to the owner →NOT_FOUND. trigger_agent_runpassesidempotencyKey: 'mcp:' + args.idempotencyKeytotriggerAgentRunso retries of the same MCP call map to the same run, and returns{ runId, state, created, continuation: { agentRunId } }with status 202.- No recursion: if the calling grant is an agent-run grant (
principal.grant.clientId === AGENT_RUN_MCP_CLIENT_ID),trigger_agent_run,approve_agent_runandreject_agent_runfail withAGENT_RECURSION_FORBIDDEN. An acting agent must never start or approve agent runs. - Receipt tracking: extend
get_operationsotrigger_agent_run/approve_agent_runreceipts reporttargetStatefrom the run (state,reportedAt,finishedAt) and the operation lifecycle becomescompletedwhen the run is terminal (completed/rejected/skipped) andfailedwhen the runfailed. - Add the tools to
docs/mcp-coverage.mdand a short section todocs/mcp.md(issue 17 covers the full docs). - Tests
packages/api/test/mcpAgentRuns.test.tsusing the fixture style frommcpTaskSubmissions.test.ts.
Implementation Specification
- Read tools are
readOnly: true; mutations go throughMcpOperations.runautomatically viaexecuteTool. - Reuse core functions; no SQL in the tool module beyond what the store exposes.
- Tool descriptions must state that runs produce a free-form report, that
trigger_agent_runis cost-gated and may returndeferred/skipped, and that acting depends on the agent's autonomy mode.
Acceptance Criteria
-
trigger_agent_runtwice with the sameidempotencyKeyreturns the same receipt and creates one run. - A grant without access to one of the definition's repositories cannot read or trigger it.
- A token issued for an agent run cannot call
trigger_agent_run(AGENT_RECURSION_FORBIDDEN). -
get_operationon a trigger receipt reachescompletedonce the run completes. -
tools/listshows the new tools only for grants with the right scopes.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 6, 2026
Suggested Implementation:
Implementation Approach
The MCP surface is a thin adapter over the same core functions the REST routes use, registered in the central catalog so dispatch, authorization, receipts and access logging come for free from
executeTool. Idempotency maps the MCP mutation key onto the core run idempotency key (prefixedmcp:to keep namespaces apart from REST/CLI keys), so a chat client retry after a dropped connection cannot start a second run.The recursion guard is the one Agents-specific rule: the acting agent holds
executescope (issue 9) and could otherwise trigger agents, including itself, creating unbounded spend loops.File:
packages/api/mcp/toolsAgentRuns.ts(new file)Why this file: Registers every Agents MCP tool in one module, mirroring
toolsTaskSubmissions.ts.Note:
startActingandsetAgentRunOperatorNotemust be exported from@propr/core(moved there in issue 10). UnusedidSchemaimport can be dropped.File:
packages/api/mcp/tools.tsWhy this file: Central catalog registration and
get_operationreceipt tracking.syncReceiptLifecyclethen persists the terminal lifecycle exactly as it does for goals.File:
packages/api/test/mcpAgentRuns.test.ts(new file)Why this file: Verifies authorization, idempotency and the recursion guard through
executeTool.propr-dev commentedon Oct 7, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52812/claude-opus-5-5-agents-v1-13-17-propr-mcp-20261007-0822-duh2800-epic-agents-v1-y7tissue-2812-20261007-0822-claude-opus-5-5-duh🔍 Track Task Execution
propr-dev commentedon Oct 7, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52812/claude-opus-5-5-agents-v1-13-17-propr-mcp-20261007-0826-cxt2800-epic-agents-v1-y7tissue-2812-20261007-0826-claude-opus-5-5-cxt🔍 Track Task Execution
I've added the eight agent MCP tools for issue #2812 in a new `packag…
I've added the eight agent MCP tools for issue #2812 in a new `packag…