Warning, /swf-monitor/docs/MCP_TOOL_REFERENCE.md is written in an unsupported language. File is not indexed.
0001 # MCP Tool Reference
0002
0003 This document is the detailed tool reference for the SWF Monitor MCP server. The
0004 short operational overview is [MCP.md](MCP.md), client setup is
0005 [MCP_CLIENTS.md](MCP_CLIENTS.md), and the PanDA Mattermost bot client is
0006 documented in [PANDA_BOT.md](PANDA_BOT.md).
0007
0008 List tools use ISO datetime filters named `start_time` and `end_time` where
0009 applicable. Paginated list responses include `items`, `total_count`, `has_more`,
0010 and `monitor_urls` when web UI links are available.
0011
0012 ## Available Tools
0013
0014 ### Tool Discovery
0015
0016 | Tool | Parameters | Description |
0017 |------|------------|-------------|
0018 | `swf_list_available_tools` | - | List all available MCP tools with descriptions. Use to discover capabilities. |
0019
0020 ---
0021
0022 ### System State
0023
0024 | Tool | Parameters | Description |
0025 |------|------------|-------------|
0026 | `swf_get_system_state` | `username` | Comprehensive system state for a user: context from testbed.toml, agent manager status, workflow runner readiness, agent counts, execution stats. |
0027
0028 **Parameters:**
0029 - `username`: Optional. Username to get context for (reads their testbed.toml). If not provided, infers from SWF_HOME environment variable.
0030
0031 **Returns:**
0032 - `timestamp`: Current server time
0033 - `user_context`: namespace, workflow defaults from user's testbed.toml
0034 - `agent_manager`: Status of user's agent manager daemon (healthy/unhealthy/missing/exited)
0035 - `workflow_runner`: Status of healthy DAQ_Simulator that can accept swf_start_workflow
0036 - `ready_to_run`: Boolean - True if workflow_runner is healthy and can accept commands
0037 - `last_execution`: Most recent workflow execution for user's namespace
0038 - `errors_last_hour`: Count of ERROR logs in user's namespace
0039 - `agents`: Total, active, exited, healthy, unhealthy counts
0040 - `executions`: Running count, completed in last hour
0041 - `messages_last_10min`: Recent message count
0042 - `run_states`: Current fast processing run states
0043 - `persistent_state`: System-wide persistent state (next IDs, etc.)
0044 - `recent_events`: Last 10 system state events
0045
0046 ---
0047
0048 ### Agents
0049
0050 | Tool | Parameters | Description |
0051 |------|------------|-------------|
0052 | `swf_list_agents` | `namespace`, `agent_type`, `status`, `execution_id`, `start_time`, `end_time` | List agents with filtering. **Excludes EXITED agents by default.** |
0053 | `swf_get_agent` | `name` (required) | Full details for a specific agent including metadata. |
0054
0055 **`swf_list_agents` filters:**
0056 - `namespace`: Filter to agents in this namespace
0057 - `agent_type`: Filter by type (daqsim, data, processing, fastmon, workflow_runner, etc.)
0058 - `status`: Filter by status. Special values:
0059 - `None` (default): Excludes EXITED agents
0060 - `'EXITED'`: Show only exited agents
0061 - `'all'`: Show all agents regardless of status
0062 - `'OK'`, `'WARNING'`, `'ERROR'`: Filter to specific status
0063 - `execution_id`: Filter to agents that participated in this execution
0064 - `start_time`, `end_time`: Filter by heartbeat within date range
0065
0066 **Returns per agent:**
0067 - `name`, `agent_type`, `status`, `operational_state`, `namespace`
0068 - `last_heartbeat` (ISO timestamp)
0069 - `workflow_enabled`, `total_stf_processed`
0070
0071 ---
0072
0073 ### Namespaces
0074
0075 | Tool | Parameters | Description |
0076 |------|------------|-------------|
0077 | `swf_list_namespaces` | - | List all testbed namespaces with owners. |
0078 | `swf_get_namespace` | `namespace` (required), `start_time`, `end_time` | Details for a namespace including activity counts. |
0079
0080 **`swf_get_namespace` returns:**
0081 - `name`, `owner`, `description`
0082 - `agent_count`: Agents registered in namespace
0083 - `execution_count`: Workflow executions (in date range if specified)
0084 - `message_count`: Messages (in date range if specified)
0085 - `active_users`: Users who ran executions (in date range if specified)
0086
0087 ---
0088
0089 ### Workflow Definitions
0090
0091 | Tool | Parameters | Description |
0092 |------|------------|-------------|
0093 | `swf_list_workflow_definitions` | `workflow_type`, `created_by` | List available workflow definitions. |
0094
0095 **Returns per definition:**
0096 - `workflow_name`, `version`, `workflow_type`
0097 - `description`, `created_by`, `created_at`
0098 - `execution_count`: Number of times executed
0099
0100 ---
0101
0102 ### Workflow Executions
0103
0104 | Tool | Parameters | Description |
0105 |------|------------|-------------|
0106 | `swf_list_workflow_executions` | `namespace`, `status`, `executed_by`, `workflow_name`, `currently_running`, `start_time`, `end_time` | List workflow executions with filtering. |
0107 | `swf_get_workflow_execution` | `execution_id` (required) | Full details for a specific execution. |
0108
0109 **`swf_list_workflow_executions` filters:**
0110 - `namespace`: Filter to executions in this namespace
0111 - `status`: Filter by status (pending, running, completed, failed, terminated)
0112 - `executed_by`: Filter by user who started the execution
0113 - `workflow_name`: Filter by workflow definition name
0114 - `currently_running`: If True, return all running executions (ignores date range). Use for "What's running?"
0115 - `start_time`, `end_time`: Filter by execution start time
0116
0117 **Returns per execution:**
0118 - `execution_id`, `workflow_name`, `namespace`
0119 - `status`, `executed_by`
0120 - `start_time`, `end_time` (ISO timestamps)
0121 - `parameter_values`: Execution configuration
0122
0123 ---
0124
0125 ### Messages
0126
0127 | Tool | Parameters | Description |
0128 |------|------------|-------------|
0129 | `swf_list_messages` | `namespace`, `execution_id`, `agent`, `message_type`, `start_time`, `end_time` | List workflow messages with filtering. |
0130 | `swf_send_message` | `message` (required), `message_type`, `metadata` | Send a message to the monitoring stream. |
0131
0132 **Diagnostic use cases:**
0133 - Track workflow progress: `swf_list_messages(execution_id='stf_datataking-user-0044')`
0134 - See what an agent sent: `swf_list_messages(agent='daq_simulator-agent-user-123')`
0135 - Debug message flow: `swf_list_messages(namespace='torre1', start_time='2026-01-13T11:00:00')`
0136 - For workflow failures: use `swf_list_logs(level='ERROR')` instead
0137
0138 **Common message types:** `run_imminent`, `start_run`, `stf_gen`, `end_run`, `pause_run`, `resume_run`
0139
0140 **Filters:**
0141 - `namespace`: Filter to messages in this namespace
0142 - `execution_id`: Filter to messages for this execution
0143 - `agent`: Filter by sender agent name
0144 - `message_type`: Filter by type (stf_gen, start_run, etc.)
0145 - `start_time`, `end_time`: Filter by sent time (default: last 1 hour)
0146
0147 **Returns per message (max 200):**
0148 - `message_type`, `sender_agent`, `namespace`
0149 - `sent_at` (ISO timestamp)
0150 - `execution_id`, `run_id`
0151 - `payload_summary`: Truncated message content
0152
0153 **`swf_send_message` parameters:**
0154 - `message` (required): The message text to send
0155 - `message_type`: Type of message (default: 'announcement')
0156 - `'test'`: Namespace is omitted (for pipeline testing)
0157 - `'announcement'`, `'status'`, etc.: Uses configured namespace from testbed.toml
0158 - `metadata`: Optional dict of additional key-value data
0159
0160 **`swf_send_message` behavior:**
0161 - Sender is automatically identified as `{username}-personal-agent`
0162 - Messages are sent to `/topic/epictopic` and captured by the monitor
0163 - Use for: testing the message pipeline, announcements to colleagues, or any broadcast purpose
0164
0165 **Returns:**
0166 - `success`: Whether the message was sent
0167 - `sender`: The sender identifier (e.g., 'wenauseic-personal-agent')
0168 - `message_type`: The type of message sent
0169 - `namespace`: The namespace used (or null for test messages)
0170 - `content`: The message content
0171
0172 ---
0173
0174 ### Runs
0175
0176 | Tool | Parameters | Description |
0177 |------|------------|-------------|
0178 | `swf_list_runs` | `start_time`, `end_time` | List simulation runs with timing and file counts. |
0179 | `swf_get_run` | `run_number` (required) | Full details for a specific run. |
0180
0181 **`swf_list_runs` returns per run:**
0182 - `run_number`
0183 - `start_time`, `end_time`, `duration_seconds`
0184 - `stf_file_count`: Number of STF files in this run
0185
0186 **`swf_get_run` returns:**
0187 - All fields above plus:
0188 - `run_conditions`: JSON metadata
0189 - `file_stats`: STF file counts by status (registered, processing, done, failed)
0190
0191 ---
0192
0193 ### STF Files
0194
0195 | Tool | Parameters | Description |
0196 |------|------------|-------------|
0197 | `swf_list_stf_files` | `run_number`, `status`, `machine_state`, `start_time`, `end_time` | List STF files with filtering. |
0198 | `swf_get_stf_file` | `file_id` or `stf_filename` (one required) | Full details for a specific STF file. |
0199
0200 **`swf_list_stf_files` filters:**
0201 - `run_number`: Filter to files from this run
0202 - `status`: Filter by processing status (registered, processing, processed, done, failed)
0203 - `machine_state`: Filter by detector state (physics, cosmics, etc.)
0204 - `start_time`, `end_time`: Filter by creation time
0205
0206 **Returns per STF file:**
0207 - `file_id`, `stf_filename`, `run_number`
0208 - `status`, `machine_state`
0209 - `file_size_bytes`, `created_at`
0210 - `tf_file_count`: Number of TF files derived from this STF
0211
0212 **`swf_get_stf_file` returns:**
0213 - All fields above plus:
0214 - `checksum`, `metadata`
0215 - `workflow_id`, `daq_state`, `daq_substate`, `workflow_status`
0216
0217 ---
0218
0219 ### TF Slices (Fast Processing)
0220
0221 | Tool | Parameters | Description |
0222 |------|------------|-------------|
0223 | `swf_list_tf_slices` | `run_number`, `stf_filename`, `tf_filename`, `status`, `assigned_worker`, `start_time`, `end_time` | List TF slices for fast processing workflow. |
0224 | `swf_get_tf_slice` | `tf_filename`, `slice_id` (both required) | Full details for a specific TF slice. |
0225
0226 **`swf_list_tf_slices` filters:**
0227 - `run_number`: Filter to slices from this run
0228 - `stf_filename`: Filter to slices from this STF file
0229 - `tf_filename`: Filter to slices from this TF sample
0230 - `status`: Filter by status (queued, processing, completed, failed)
0231 - `assigned_worker`: Filter by worker assignment
0232 - `start_time`, `end_time`: Filter by creation time
0233
0234 **Returns per slice (max 200):**
0235 - `slice_id`, `tf_filename`, `stf_filename`, `run_number`
0236 - `tf_first`, `tf_last`, `tf_count` (TF range)
0237 - `status`, `assigned_worker`
0238 - `created_at`, `completed_at`
0239
0240 **`swf_get_tf_slice` returns:**
0241 - All fields above plus:
0242 - `retries`, `assigned_at`
0243 - `metadata`
0244
0245 ---
0246
0247 ### Logs
0248
0249 | Tool | Parameters | Description |
0250 |------|------------|-------------|
0251 | `swf_list_logs` | `app_name`, `instance_name`, `execution_id`, `level`, `search`, `start_time`, `end_time` | List log entries from all agents. |
0252 | `swf_get_log_entry` | `log_id` (required) | Full details for a specific log entry. |
0253
0254 **Diagnostic use cases:**
0255 - Workflow logs: `swf_list_logs(execution_id='stf_datataking-user-0044')`
0256 - Debug a specific agent: `swf_list_logs(instance_name='daq_simulator-agent-user-123')`
0257 - Find all errors: `swf_list_logs(level='ERROR')`
0258 - Search for specific issues: `swf_list_logs(search='connection failed')`
0259
0260 **`swf_list_logs` filters:**
0261 - `app_name`: Filter by application type (e.g., 'daq_simulator', 'data_agent')
0262 - `instance_name`: Filter by agent instance name
0263 - `execution_id`: Filter by workflow execution ID (e.g., 'stf_datataking-wenauseic-0044')
0264 - `level`: Minimum level threshold - returns this level and higher severity:
0265 - `DEBUG` -> all logs
0266 - `INFO` -> INFO, WARNING, ERROR, CRITICAL
0267 - `WARNING` -> WARNING, ERROR, CRITICAL
0268 - `ERROR` -> ERROR, CRITICAL
0269 - `CRITICAL` -> CRITICAL only
0270 - `search`: Case-insensitive text search in message
0271 - `start_time`, `end_time`: Filter by timestamp (default: last 24 hours)
0272
0273 **Returns per entry (max 200):**
0274 - `id`, `timestamp`, `app_name`, `instance_name`
0275 - `level`, `message`, `module`, `funcname`, `lineno`
0276 - `extra_data`: Additional context (execution_id, run_id, etc.)
0277
0278 ---
0279
0280 ### Workflow Control
0281
0282 | Tool | Parameters | Description |
0283 |------|------------|-------------|
0284 | `swf_start_workflow` | `workflow_name`, `namespace`, `config`, `realtime`, `duration`, `stf_count`, `physics_period_count`, `physics_period_duration`, `stf_interval` | Start a workflow by sending command to DAQ Simulator agent. |
0285 | `swf_stop_workflow` | `execution_id` (required) | Stop a running workflow gracefully. |
0286 | `swf_end_execution` | `execution_id` (required) | Mark a stuck execution as terminated (database state change only). |
0287
0288 **`swf_start_workflow` parameters:**
0289
0290 All parameters are optional - defaults are read from the user's `testbed.toml`:
0291 - `workflow_name`: Name of workflow (default: from config, typically 'stf_datataking')
0292 - `namespace`: Testbed namespace (default: from config)
0293 - `config`: Workflow config name (default: from config, e.g., 'fast_processing_default')
0294 - `realtime`: Run in real-time mode (default: from config, typically True)
0295 - `duration`: Max duration in seconds (0 = run until complete)
0296 - `stf_count`: Number of STF files to generate (overrides config)
0297 - `physics_period_count`: Number of physics periods (overrides config)
0298 - `physics_period_duration`: Duration of each physics period in seconds (overrides config)
0299 - `stf_interval`: Interval between STF generation in seconds (overrides config)
0300
0301 **Returns:** Success/failure status with execution details. Workflow runs asynchronously.
0302
0303 **After starting — ACTIVELY POLL, do not sleep:**
0304 - Poll `swf_get_workflow_monitor(execution_id)` every 10-15s until completion
0305 - Report progress to user as it evolves
0306 - Check `swf_list_logs(level='ERROR')` after completion
0307
0308 **`swf_stop_workflow`:** Sends a stop command to the DAQ Simulator agent. The workflow stops gracefully at the next checkpoint. Use `swf_list_workflow_executions(currently_running=True)` to find running execution IDs.
0309
0310 **`swf_end_execution`:** Use to clean up stale or stuck executions that are still marked as 'running' in the database. This is a state change only - no agent message is sent.
0311
0312 ---
0313
0314 ### Agent Process Management
0315
0316 | Tool | Parameters | Description |
0317 |------|------------|-------------|
0318 | `swf_kill_agent` | `name` (required) | Kill an agent process by sending SIGKILL to its PID. |
0319
0320 **`swf_kill_agent` behavior:**
0321 - Looks up the agent by `instance_name`
0322 - Retrieves its `pid` and `hostname`
0323 - Sends SIGKILL if the agent is on the current host
0324 - Always marks the agent's status and operational_state as `EXITED`
0325 - Agent will no longer appear in default `swf_list_agents` results
0326
0327 **Returns:**
0328 - `success`: Whether the operation completed
0329 - `killed`: Whether the process was actually killed (may be False if already dead or on different host)
0330 - `kill_error`: Error message if kill failed (permission denied, process not found, remote host)
0331 - `old_state`, `new_state`: State transition
0332
0333 ---
0334
0335 ### User Agent Manager
0336
0337 The User Agent Manager is a per-user daemon that enables MCP-driven testbed control. It listens for commands on a user-specific queue and manages supervisord-controlled agents.
0338
0339 | Tool | Parameters | Description |
0340 |------|------------|-------------|
0341 | `swf_check_agent_manager` | `username` | Check if a user's agent manager daemon is alive. |
0342 | `swf_get_testbed_status` | `username` | Comprehensive testbed status: agent manager, agents, running workflows, readiness. |
0343 | `swf_start_user_testbed` | `username`, `config_name` | Start a user's testbed via their agent manager. |
0344 | `swf_stop_user_testbed` | `username` | Stop a user's testbed via their agent manager. |
0345
0346 **`swf_check_agent_manager` returns:**
0347 - `alive`: True if agent manager has recent heartbeat (within 5 minutes)
0348 - `username`: The user being checked
0349 - `instance_name`: The agent manager's instance name (e.g., 'agent-manager-wenauseic')
0350 - `last_heartbeat`: When it last checked in
0351 - `operational_state`: Current state (READY, EXITED, etc.)
0352 - `control_queue`: The queue to send commands to (e.g., '/queue/agent_control.wenauseic')
0353 - `agents_running`: Whether testbed agents are currently running
0354 - `how_to_start`: Instructions if not alive
0355
0356 **`swf_get_testbed_status` returns:**
0357 - `agent_manager`: alive, namespace, operational_state, status, last_heartbeat
0358 - `agents`: List of workflow agents with running/stopped status
0359 - `summary`: Running and stopped agent counts
0360 - `running_workflows`: Count of currently executing workflows
0361 - `ready`: True when agent manager alive, agents running, and no workflow executing
0362 - `note`: Human-readable status summary
0363
0364 **`swf_start_user_testbed`:**
0365 - Sends `start_testbed` command to the user's agent manager
0366 - Agent manager must be running first (use `swf_check_agent_manager` to verify)
0367 - `config_name`: Optional config name (e.g., 'fast_processing'). Uses default if not specified.
0368 - Agents start asynchronously - use `swf_list_agents` to verify
0369
0370 **`swf_stop_user_testbed`:**
0371 - Sends `stop_testbed` command to the user's agent manager
0372 - If agent manager is not running, use `swf_kill_agent` to stop agents directly
0373
0374 **Starting the agent manager:**
0375 ```bash
0376 cd /data/<username>/github/swf-testbed
0377 source .venv/bin/activate && source ~/.env
0378 testbed agent-manager
0379 ```
0380
0381 ---
0382
0383 ### Workflow Monitoring
0384
0385 | Tool | Parameters | Description |
0386 |------|------------|-------------|
0387 | `swf_get_workflow_monitor` | `execution_id` (required) | Get aggregated status and events for a workflow execution. |
0388 | `swf_list_workflow_monitors` | - | List recent executions that can be monitored. |
0389
0390 **`swf_get_workflow_monitor` returns:**
0391 - `execution_id`: The execution being monitored
0392 - `status`: Current workflow status (running/completed/failed/terminated)
0393 - `phase`: Current phase (imminent/running/ended/unknown)
0394 - `run_id`: The run number for this execution
0395 - `stf_count`: Number of STF files generated
0396 - `events`: List of key events with timestamps (run_imminent, start_run, end_run)
0397 - `errors`: List of any errors encountered (from messages and logs)
0398 - `start_time`, `end_time`: Execution timestamps
0399 - `duration_seconds`: How long the workflow ran (if completed)
0400
0401 This tool aggregates information from workflow messages and logs, providing a single-call summary of workflow progress without needing to poll multiple tools.
0402
0403 **`swf_list_workflow_monitors` returns:**
0404 - List of executions from last 24 hours with: `execution_id`, `status`, `start_time`, `end_time`, `stf_count`
0405 - Use to pick an execution for detailed monitoring with `swf_get_workflow_monitor`
0406
0407 ---
0408
0409 ### AI Content
0410
0411 | Tool | Parameters | Description |
0412 |------|------------|-------------|
0413 | `epic_register_ai_assessment` | `subject_type`, `subject_key`, `assessment`, `username`, `ai`, `subject_label`, `subject_url`, `data` | Register append-only AI assessment content as a corun-ai Page and link it from the target object JSON when the subject is known locally. |
0414 | `epic_get_ai_content` | `ids`, `corun_page_group_ids` | Retrieve append-only AI assessment content by corun-ai Page group ids and/or legacy AIContent ids. Use the arguments supplied in a detail payload's `ai_content.retrieval.arguments`. |
0415 | `epicprod_list_actions` | `action`, `instance`, `subject_type`, `subject_key`, `username`, `outcome`, `start_time`, `end_time`, `min_sublevel`, `summarize`, `limit`, `offset` | Query the epicprod action stream (structured production-action records with outcome and duration). Prefer `summarize=True` for reporting: counts by action with ok/error split and duration statistics. Raw listings default to an importance floor of `normal` (excluded records counted in `excluded_below_floor`; floor lifts for action/subject/outcome drill-downs and summaries); `min_sublevel` sets it explicitly. See [ACTION_STREAM.md](ACTION_STREAM.md). |
0416
0417 **Known subject types:**
0418 - `campaign_task`: campaign/production task, keyed by composed task name.
0419 - `panda_task`: local PanDA-task association, keyed by JEDI task id or task name.
0420 - `panda_job`: local production job record, keyed by pandaid.
0421 - `panda_queue`: PanDA site/queue record, keyed by queue name. A row with `queue_name == site` represents site-level content.
0422 - `campaign`: production campaign, keyed by campaign name (e.g. `26.05.0`); the natural subject for campaign-level reports. Links into the campaign's `data` JSON.
0423
0424 **Behavior:**
0425 - AI content is append-only. Corrections and followups create new entries.
0426 - New registrations write corun-ai Pages in section `epicprod.assessment` and append the Page group id to the subject JSON field under `corun_page_group_ids`.
0427 - corun-ai Page metadata includes `artifact_type: "ai_assessment"`, `source_system: "swf-monitor"`, and `ui_visible: false`; the visibility flag hides service-owned artifacts from codoc browse UI but does not block REST API access or direct URLs.
0428 - Legacy local `AIContent` rows remain readable through `ids` and old object pointers under `ai_content_ids`.
0429 - MCP registrations stamp stored metadata with `registered_via: "mcp"` and `mcp_tool: "epic_register_ai_assessment"`.
0430 - Bot-originated registrations should be stamped by the bot harness with `username: "bot"`, `ai` set to the exact model, and `data.origin` including `type: "bot"` and the same model.
0431 - Detail-style production tools include an `ai_content` block when the object can have linked AI assessments. If `ai_content.available` is true, call the specified retrieval tool with the specified arguments:
0432
0433 ```json
0434 {
0435 "available": true,
0436 "count": 2,
0437 "ids": [],
0438 "corun_page_group_ids": ["5f7539aa-4b08-4d9c-9a3f-c36ca2fd6721"],
0439 "retrieval": {
0440 "tool": "epic_get_ai_content",
0441 "arguments": {
0442 "corun_page_group_ids": ["5f7539aa-4b08-4d9c-9a3f-c36ca2fd6721"]
0443 }
0444 }
0445 }
0446 ```
0447
0448 - Use the supplied `ids` and/or `corun_page_group_ids` directly. Do not reconstruct `subject_type` or `subject_key` from the parent object when a detail payload already includes this retrieval block.
0449 - Future subject types can be added without changing existing content references.
0450
0451 ---
0452
0453 ### AI Proposals
0454
0455 | Tool | Parameters | Description |
0456 |------|------------|-------------|
0457 | `ai_list_proposals` | `status`, `limit` | List AI proposals awaiting human decision (default `status='proposed'`), or by terminal status / `all` for history. Returns preformatted `display` text — one line per proposal, each starting with its ref (e.g. `cp-12`) — to show the human verbatim, plus structured items. See [AI_PROPOSALS.md](AI_PROPOSALS.md). |
0458 | `ai_decide_proposal` | `ref`, `decision`, `username`, `quality` | Relay one human's approve/deny on one proposal by ref. Approval executes the frozen payload through the deterministic service path; the calling LLM transmits the human's verdict and nothing more. `username` is the deciding human, who must be on the SysConfig approver list (`ai_proposal_mcp_approvers`, default empty). A ref whose prefix mismatches the row's category is refused, never reinterpreted. |
0459
0460 The bot flow: list, show `display` verbatim, and relay only explicit human
0461 instructions naming a ref ('approve cp-12'). On any refusal, report the error
0462 verbatim and re-list.
0463
0464 ---
0465
0466 ### PanDA Production Monitoring
0467
0468 Tools for querying the ePIC PanDA production database (`doma_panda` schema). Read-only access to jobs and JEDI tasks.
0469
0470 | Tool | Parameters | Description |
0471 |------|------------|-------------|
0472 | `panda_get_activity` | `days`, `username`, `site`, `workinggroup` | Pre-digested PanDA activity overview — aggregate counts only, no individual records. Use first for "What is PanDA doing?" |
0473 | `panda_list_jobs` | `days`, `status`, `username`, `site`, `taskid`, `reqid`, `limit`, `before_id` | List PanDA jobs with summary stats (default 200 jobs, 14 fields). Cursor-based pagination via before_id. |
0474 | `panda_diagnose_jobs` | `days`, `username`, `site`, `taskid`, `reqid`, `error_component`, `limit`, `before_id` | Diagnose failed/faulty PanDA jobs with full error details (7 error components). Cursor-based pagination via before_id. |
0475 | `panda_list_tasks` | `days`, `status`, `username`, `taskname`, `reqid`, `workinggroup`, `taskid`, `processingtype`, `limit`, `before_id` | List JEDI tasks with summary stats (default 500 tasks). Cursor-based pagination via before_id. |
0476 | `panda_error_summary` | `days`, `username`, `site`, `taskid`, `error_source`, `limit` | Aggregate error summary across failed jobs, ranked by frequency. |
0477 | `panda_study_job` | `pandaid` | Deep study of a single job — full record, files, errors, log URLs, harvester info, parent task. |
0478 | `panda_list_queues` | `vo`, `status`, `state`, `search` | List EIC PanDA queues from live schedconfig — site, status, corecount, resource type, capability flags. |
0479 | `panda_get_queue` | `panda_queue` (required) | Full detail for a single PanDA queue. |
0480 | `panda_resource_usage` | `days`, `site`, `username`, `taskid`, `start_time`, `end_time`, `bucket` | Allocated vs used core-hours by site for an exact time window, with optional daily or weekly site series. |
0481 | `panda_harvester_workers` | `site`, `hours` | Live Harvester pilot/worker counts (via bamboo `askpanda_atlas`) — totals + breakdown by status, site, and resourcetype. |
0482
0483 **`panda_get_activity`** — Pre-digested overview, no individual records:
0484 - `days`: Time window in days (default 1)
0485 - `username`: Filter by job owner / task owner (supports SQL LIKE with %)
0486 - `site`: Filter by computing site (supports SQL LIKE with %)
0487 - `workinggroup`: Filter tasks by working group (e.g. 'EIC')
0488
0489 Returns:
0490 - `jobs`: `{total, by_status, by_user, by_site}` — each with status breakdown
0491 - `tasks`: `{total, by_status, by_user}` — each with status breakdown
0492
0493 Use cases:
0494 - What's PanDA doing right now? `panda_get_activity()`
0495 - EIC activity this week? `panda_get_activity(days=7, workinggroup='EIC')`
0496 - Activity for a user? `panda_get_activity(username='Dmitrii Kalinkin')`
0497
0498 **`panda_list_tasks` filters:**
0499 - `days`: Time window in days (default 7)
0500 - `status`: Task status (done, failed, running, ready, broken, aborted, pending, finished)
0501 - `username`: Task owner (supports SQL LIKE with %)
0502 - `taskname`: Task name (supports SQL LIKE with %)
0503 - `reqid`: Request ID
0504 - `workinggroup`: Experiment affiliation (e.g. 'EIC', 'Rubin'). NULL for iDDS automation tasks.
0505 - `processingtype`: Processing type (e.g. 'epicproduction'). Supports SQL LIKE with %.
0506 - `taskid`: Specific JEDI task ID
0507 - `limit`: Max tasks to return (default 500)
0508 - `before_id`: Pagination cursor
0509
0510 **Returns per task:**
0511 - `jeditaskid`, `taskname`, `status`, `username`
0512 - `creationdate`, `starttime`, `endtime`, `modificationtime`
0513 - `reqid`, `processingtype`, `transpath`
0514 - `progress`, `failurerate`, `errordialog`
0515 - `site`, `corecount`, `taskpriority`, `currentpriority`
0516 - `gshare`, `attemptnr`, `parent_tid`, `workinggroup`
0517 - **`nactive`, `nfinished`, `nfailed`** — per-task job counts aggregated from `jobsactive4` + `jobsarchived4`, bucketed per `JOB_STATUS_CATEGORIES` in `panda/constants.py`. Cancelled and closed are deliberately excluded so alarm consumers see only what operators don't know.
0518 - **`nrunning`** — count of job records with `jobstatus='running'` (subset of `nactive`).
0519 - **`nretries`** — count of job records with `attemptnr > 1`. Every retry creates a new job record in the ePIC PanDA schema, so this is the total retry count for the task. Retry limit is 3.
0520 - When called with a specific `taskid`, task records include `ai_content`. If `ai_content.available` is true, call `ai_content.retrieval.tool` with `ai_content.retrieval.arguments`.
0521
0522 **Diagnostic use cases:**
0523 - Task overview: `panda_list_tasks(days=7)`
0524 - Failed tasks: `panda_list_tasks(status='failed')`
0525 - Tasks for a user: `panda_list_tasks(username='Dmitrii Kalinkin')`
0526 - EIC experiment tasks: `panda_list_tasks(workinggroup='EIC')`
0527 - Search by name pattern: `panda_list_tasks(taskname='%workflow%')`
0528
0529 **`panda_error_summary` filters:**
0530 - `days`: Time window in days (default 10)
0531 - `username`: Filter by job owner (supports SQL LIKE with %)
0532 - `site`: Filter by computing site (supports SQL LIKE with %)
0533 - `taskid`: Filter by JEDI task ID
0534 - `error_source`: Filter to one component (pilot, executor, ddm, brokerage, dispatcher, supervisor, taskbuffer)
0535 - `limit`: Max error patterns to return (default 20)
0536
0537 **Returns per error pattern:**
0538 - `error_source`: Component name (pilot, executor, ddm, etc.)
0539 - `error_code`: Numeric error code
0540 - `error_diag`: Diagnostic message (truncated to 256 chars)
0541 - `count`: Number of affected jobs
0542 - `task_count`: Number of affected tasks
0543 - `users`: List of affected users
0544 - `sites`: List of affected sites
0545
0546 **Diagnostic use cases:**
0547 - Top errors this week: `panda_error_summary(days=7)`
0548 - Errors for a specific user: `panda_error_summary(username='Dmitrii Kalinkin')`
0549 - Pilot errors only: `panda_error_summary(error_source='pilot')`
0550 - Errors for a specific task: `panda_error_summary(taskid=33824)`
0551
0552 **`panda_study_job`** — Deep study of a single job:
0553 - `pandaid`: PanDA job ID (required)
0554
0555 Returns:
0556 - `job`: Full record (~40 fields, nulls stripped) with structured `errors` list
0557 - `files`: All associated files from `filestable4` (log, output, input) with lfn, guid, scope, status
0558 - `log_urls`: Harvester log URLs — `pilot_stdout`, `pilot_stderr`, `batch_log` (require CILogon auth)
0559 - `log_file`: Log tarball metadata if registered (lfn, guid, scope for future rucio retrieval)
0560 - `harvester`: Condor worker details (workerid, status, error info)
0561 - `task`: Parent JEDI task context (name, status, error dialog)
0562 - `monitor_url`: Link to PanDA monitoring page
0563 - `ai_content`: Availability flag and exact retrieval tool/arguments for linked AI assessments
0564
0565 **`panda_get_queue`** returns:
0566 - `queue`: Full schedconfig record.
0567 - `ai_content`: Availability flag and exact retrieval tool/arguments for linked AI assessments on the local queue/site record.
0568
0569 Use cases:
0570 - Study a failed job: `panda_study_job(pandaid=130497)`
0571 - After `panda_diagnose_jobs` identifies failures, drill into specific jobs
0572
0573 ---
0574
0575 ### Rucio Data Catalogs
0576
0577 The authenticated SWF MCP endpoint exposes two independent, read-only Rucio
0578 catalogs. Credentials and the BNL X509 proxy remain on swf-testbed.
0579
0580 - `jlab_rucio_*` is the JLab science-data catalog. Begin with scope `epic` and
0581 campaign patterns such as `*26.06.0*`; dataset names commonly begin with
0582 `/RECO/` or `/SIMU/`.
0583 - `bnl_rucio_*` is the BNL PanDA production catalog. Begin with scope
0584 `group.EIC`; use it for output and log registration, rules, locks, replicas,
0585 and RSE diagnostics.
0586
0587 Each prefix exposes the complete 13-tool surface below:
0588
0589 | Suffix | Parameters | Purpose |
0590 |---|---|---|
0591 | `list_scopes` | - | Discover scopes available in that catalog. |
0592 | `list_dids` | `scope`, `name`, `type`, `filters`, `long`, `page`, `limit` | Search datasets, containers, or files by wildcard name and metadata. |
0593 | `list_files` | `scope`, `name`, `page`, `limit` | Recursively list files in a dataset or container. |
0594 | `list_content` | `scope`, `name`, `page`, `limit` | List immediate child DIDs. |
0595 | `get_did_metadata` | `scope`, `name`, `plugin` | Retrieve system and custom physics metadata. |
0596 | `get_account_limits` | `account` | Retrieve account storage limits. |
0597 | `get_account_usage` | `account`, `rse` | Retrieve account usage at one RSE. |
0598 | `list_rses` | - | List Rucio Storage Elements. |
0599 | `get_rse_usage` | `rse` | Retrieve used, free, and total storage for an RSE. |
0600 | `list_rules` | `scope`, `name`, `did`, `filters`, `page`, `limit` | Inspect replication rules, including stuck or replicating rules. |
0601 | `get_rule_locks` | `rule_id`, `page`, `limit` | Inspect replica locks belonging to a rule. |
0602 | `list_file_replicas` | `dids`, `page`, `limit` | Resolve file replicas to RSEs and PFNs. |
0603 | `extract_scope` | `did` | Parse an EIC DID or storage path into scope and name. |
0604
0605 The same suffix is called with the relevant prefix, for example:
0606
0607 ```text
0608 jlab_rucio_list_dids(scope="epic", name="*26.06.0*", type="DATASET")
0609 bnl_rucio_list_dids(scope="group.EIC", name="*26.06.0*", type="DATASET")
0610 ```
0611
0612 The two catalogs serve different purposes and are not expected to contain the
0613 same DIDs or counts. An empty result should trigger scope/name verification,
0614 not an immediate conclusion that data is absent.
0615
0616 ---
0617
0618 ## Tool Summary
0619
0620 | Category | Tools | Count |
0621 |----------|-------|-------|
0622 | Tool Discovery | `swf_list_available_tools`, `get_server_instructions` | 2 |
0623 | System State | `swf_get_system_state` | 1 |
0624 | Agents | `swf_list_agents`, `swf_get_agent` | 2 |
0625 | Namespaces | `swf_list_namespaces`, `swf_get_namespace` | 2 |
0626 | Workflow Definitions | `swf_list_workflow_definitions` | 1 |
0627 | Workflow Executions | `swf_list_workflow_executions`, `swf_get_workflow_execution` | 2 |
0628 | Messages | `swf_list_messages`, `swf_send_message` | 2 |
0629 | Runs | `swf_list_runs`, `swf_get_run` | 2 |
0630 | STF Files | `swf_list_stf_files`, `swf_get_stf_file` | 2 |
0631 | TF Slices | `swf_list_tf_slices`, `swf_get_tf_slice` | 2 |
0632 | Logs | `swf_list_logs`, `swf_get_log_entry` | 2 |
0633 | Workflow Control | `swf_start_workflow`, `swf_stop_workflow`, `swf_end_execution` | 3 |
0634 | Agent Management | `swf_kill_agent` | 1 |
0635 | User Agent Manager | `swf_check_agent_manager`, `swf_get_testbed_status`, `swf_start_user_testbed`, `swf_stop_user_testbed` | 4 |
0636 | Workflow Monitoring | `swf_get_workflow_monitor`, `swf_list_workflow_monitors` | 2 |
0637 | AI Memory | `swf_record_ai_memory`, `swf_get_ai_memory` | 2 |
0638 | AI Content | `epic_register_ai_assessment`, `epic_get_ai_content` | 2 |
0639 | AI Proposals | `ai_list_proposals`, `ai_decide_proposal` | 2 |
0640 | Campaign Status | `epicprod_campaign_status` | 1 |
0641 | Action Stream | `epicprod_list_actions` | 1 |
0642 | PCS Tags | `pcs_list_tags`, `pcs_get_tag`, `pcs_search_tags` | 3 |
0643 | PCS Datasets and Prod Tasks | `pcs_dataset_list`, `pcs_dataset_get`, `pcs_dataset_intake`, `pcs_prodtask_list`, `pcs_prodtask_get`, `pcs_prodtask_artifact`, `pcs_prodtask_intake`, `pcs_prodtask_link_input`, `pcs_prodtask_set_status` | 9 |
0644 | PanDA Production | `panda_get_activity`, `panda_list_jobs`, `panda_diagnose_jobs`, `panda_list_tasks`, `panda_error_summary`, `panda_study_job`, `panda_list_queues`, `panda_get_queue`, `panda_resource_usage`, `panda_harvester_workers` | 10 |
0645 | JLab Rucio | `jlab_rucio_*` | 13 |
0646 | BNL Rucio | `bnl_rucio_*` | 13 |
0647 | **Total** | | **86** |
0648
0649 ---
0650
0651 ## Quick Reference - Example Prompts
0652
0653 System Readiness
0654 - "What's the state of the testbed?"
0655 - "Am I ready to run a workflow?"
0656 - "Is my agent manager running?"
0657 - "Are there any errors in the system?"
0658
0659 Starting the Testbed
0660 - "Start my testbed"
0661 - "Start my testbed with the fast_processing config"
0662 - "Check if my agents are running"
0663
0664 Running Workflows
0665 - "Start a workflow"
0666 - "Run a workflow with 5 STF files"
0667 - "Start a workflow with 3 physics periods"
0668 - "What's running right now?"
0669
0670 Monitoring
0671 - "What's the status of my workflow?"
0672 - "Show me the progress of execution stf_datataking-wenauseic-0045"
0673 - "How many STF files have been generated?"
0674 - "Are there any errors in my workflow?"
0675
0676 Stopping
0677 - "Stop my running workflow"
0678 - "Stop the testbed"
0679
0680 Troubleshooting
0681 - "Why did my workflow fail?"
0682 - "Show me the logs for the DAQ simulator"
0683 - "What errors happened in the last hour?"
0684 - "Kill the stuck daq_simulator agent"
0685
0686 Combined Operations
0687 - "Start my testbed and run a workflow with 10 STF files"
0688 - "Check if I'm ready to run, and if so, start a workflow"
0689
0690 ---
0691
0692 ## Example Prompts - Detailed
0693
0694 ### What's Running?
0695
0696 > "What's running in the testbed?"
0697
0698 LLM calls `swf_list_workflow_executions(currently_running=True)` and summarizes the running executions by namespace and workflow type.
0699
0700 > "What's the state of my running workflow?"
0701
0702 LLM calls `get_workflow_monitor(execution_id='...')` for aggregated status, or `swf_list_workflow_executions(currently_running=True, namespace="user_namespace")`.
0703
0704 ### System Health
0705
0706 > "What's the current state of the testbed?"
0707
0708 LLM calls `swf_get_system_state(username='wenauseic')` and summarizes user context, agent health, running workflows, and system state.
0709
0710 > "Am I ready to run a workflow?"
0711
0712 LLM calls `swf_get_system_state(username='...')` and checks `ready_to_run` field. If False, explains what's missing (agent manager, workflow runner).
0713
0714 ### Starting and Stopping Workflows
0715
0716 > "Start a workflow with 5 STF files"
0717
0718 LLM calls `swf_start_workflow(stf_count=5)` - other parameters default from testbed.toml.
0719
0720 > "Stop my running workflow"
0721
0722 LLM calls `swf_list_workflow_executions(currently_running=True)` to find the execution_id, then `swf_stop_workflow(execution_id='...')`.
0723
0724 ### Error Discovery
0725
0726 > "Are there any errors in the system?"
0727
0728 LLM calls `swf_list_logs(level='ERROR')` to find error and critical log entries, then summarizes the issues found.
0729
0730 > "Why did my workflow fail?"
0731
0732 LLM calls:
0733 1. `swf_list_workflow_executions(status='failed', namespace="user_namespace")` - find failed executions
0734 2. `get_workflow_monitor(execution_id='...')` - get aggregated errors
0735 3. `swf_list_logs(execution_id='...', level='ERROR')` - detailed error logs
0736
0737 ### Activity Summary
0738
0739 > "Summarize testbed activity for the past week."
0740
0741 LLM makes multiple calls:
0742 1. `swf_list_workflow_executions(start_time="2026-01-06T00:00:00", end_time="2026-01-13T00:00:00")` - all executions
0743 2. `swf_list_agents()` - registered agents
0744 3. `swf_list_namespaces()` - active namespaces
0745 4. Synthesizes: "In the past week, 47 workflow executions ran across 3 namespaces..."
0746
0747 ### Investigating a Run
0748
0749 > "Show me details about run 100042 and its STF files."
0750
0751 LLM calls:
0752 1. `swf_get_run(run_number=100042)` - run details
0753 2. `list_stf_files(run_number=100042)` - associated STF files
0754
0755 ### Agent Troubleshooting
0756
0757 > "The fast_processing agent seems unresponsive. What's happening?"
0758
0759 LLM calls:
0760 1. `swf_get_agent(name="fast_processing-agent-wenauseic-123")` - agent status
0761 2. `swf_list_logs(instance_name="fast_processing-agent-wenauseic-123", level='WARNING')` - recent issues
0762 3. If needed: `kill_agent(name="...")` to terminate unresponsive agent
0763
0764 ### Managing User Testbed
0765
0766 > "Start my testbed"
0767
0768 LLM calls:
0769 1. `check_agent_manager(username='wenauseic')` - verify agent manager is running
0770 2. If alive: `start_user_testbed(username='wenauseic')`
0771 3. If not: Instructs user to run `testbed agent-manager`
0772
0773 ### Namespace Activity
0774
0775 > "What's happening in namespace torre1 today?"
0776
0777 LLM calls:
0778 1. `swf_get_namespace(namespace="torre1", start_time="2026-01-13T00:00:00")` - activity counts
0779 2. `swf_list_workflow_executions(namespace="torre1", start_time="2026-01-13T00:00:00")` - executions
0780 3. `swf_list_agents(namespace="torre1")` - agents
0781
0782 ### Fast Processing Status
0783
0784 > "What's the status of TF slice processing for run 100042?"
0785
0786 LLM calls:
0787 1. `list_tf_slices(run_number=100042)` - all slices
0788 2. Summarizes by status: "Run 100042 has 150 slices: 120 completed, 25 processing, 5 queued."
0789
0790 ---