Skip to content

bug: MCP sync execution recorded as triggered_by=manual instead of mcp #473

Closed

Description

@vybe

Summary

When an agent execution is triggered via MCP in synchronous mode, the execution is recorded in schedule_executions with triggered_by = 'manual' and no MCP source fields populated (source_mcp_key_id, source_mcp_key_name are null). This breaks the audit trail — executions triggered by external MCP clients are indistinguishable from manual UI triggers.

Component

Backend / MCP Server / Execution Attribution

Priority

P2

Error

# schedule_executions row for an MCP sync execution:
triggered_by = "manual"
source_mcp_key_id = null
source_mcp_key_name = null
source_agent_name = null
source_user_email = null

Expected:

triggered_by = "mcp"
source_mcp_key_id = <key_id>
source_mcp_key_name = <key_name>

Root Cause

MCP synchronous mode likely passes the task dispatch through a different code path than async MCP execution, missing the step that sets triggered_by = 'mcp' and populates the MCP key source fields. The async MCP path presumably sets these correctly; the sync path does not.

Reproduction Steps

  1. Configure an MCP client with a valid MCP API key
  2. Call a chat_with_agent or equivalent MCP tool in synchronous mode (blocking, awaits result)
  3. After the execution completes, query schedule_executions for that execution
  4. Observe triggered_by = 'manual' and null MCP source fields

Suggested Fix

Identify where the sync MCP path dispatches the task and ensure it passes the same source context (MCP key ID + name) as the async path. The execution creation call should include triggered_by='mcp', source_mcp_key_id, and source_mcp_key_name.

Environment

  • Trinity version: 615a266
  • OS: Ubuntu 22.04

Related

  • schedule_executions table columns: triggered_by, source_mcp_key_id, source_mcp_key_name
  • Execution origin tracking documented in CLAUDE.md

Activity

  1. added
    priority-p2
    type-bug
    status-in-progress
    and removed on Apr 23, 2026
  2. added
    complexity-low
    on Jun 3, 2026
  3. removed
    status-in-progress
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowpriority-p2type-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions