Skip to content

Conversation

@jtcorbett
Copy link
Contributor

@jtcorbett jtcorbett commented Sep 8, 2025

TL;DR

Reorganized workflow commands

mcp-agent cloud workflows runs
mcp-agent cloud workflows list
mcp-agent cloud server workflows (alias of workflows list)

What changed?

  • Moved list_workflows_for_server from the servers module to the workflows module as list_workflow_runs
  • Added new workflow commands: list_workflows and list_workflow_runs
  • Updated CLI command structure to make workflows commands more intuitive
  • Applied consistent code formatting with black across all server and workflow related files

How to test?

Test the new and reorganized workflow commands:

# List available workflow definitions
mcp-agent cloud workflows list app_abc123

# List workflow runs (previously under servers workflows)
mcp-agent cloud workflows runs app_abc123

# Test with different output formats
mcp-agent cloud workflows list app_abc123 --format json
mcp-agent cloud workflows runs app_abc123 --format yaml

# Verify existing commands still work
mcp-agent cloud servers list
mcp-agent cloud workflows describe app_abc123 run_xyz789

Summary by CodeRabbit

  • New Features

    • Added workflows list and workflows runs commands with text/JSON/YAML output.
    • Introduced apps alias for the servers command group.
  • Refactor

    • Renamed server-scoped listing to list_workflow_runs; servers workflows now aliases the shared listing. JSON/YAML now use workflow_runs as the root key.
  • Bug Fixes

    • More reliable server list filtering/sorting across deployed and configured apps.
    • Clearer errors when resolving servers; stricter format validation in workflow describe; better handling of empty workflow status.
  • Documentation

    • Updated help text for workflows status and servers workflows (alias descriptions).

@coderabbitai
Copy link

coderabbitai bot commented Sep 8, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Caution

Review failed

The pull request is closed.

Walkthrough

Removes server-scoped workflow listing exports, adds new workflows commands (list_workflows, list_workflow_runs), rewires CLI entry points, and updates models to include richer workflow/log structures. Several modules receive formatting-only edits. Utilities add safer error wrapping in resolve_server. Workflow describe adds format validation and an empty-status check.

Changes

Cohort / File(s) Summary
Servers CLI exports cleanup
src/mcp_agent/cli/cloud/commands/servers/__init__.py, src/mcp_agent/cli/cloud/commands/servers/workflows/__init__.py
Remove list_workflows_for_server from servers package exports; delete servers/workflows subpackage initializer that re-exported it.
Workflows CLI surface expansion
src/mcp_agent/cli/cloud/commands/workflows/__init__.py, src/mcp_agent/cli/cloud/commands/workflows/list/__init__.py, src/mcp_agent/cli/cloud/commands/workflows/list/main.py, src/mcp_agent/cli/cloud/commands/workflows/runs/__init__.py, src/mcp_agent/cli/cloud/commands/workflows/runs/main.py
Add list_workflows and list_workflow_runs commands; introduce new list implementation; rename list_workflows_for_server → list_workflow_runs; update outputs/keys and help text accordingly.
Cloud CLI wiring
src/mcp_agent/cli/cloud/main.py
Register new workflows list and runs commands; remove import of server-scoped listing; add “apps” alias for servers; adjust help text for workflows status alias.
Servers commands formatting and robustness
src/mcp_agent/cli/cloud/commands/servers/delete/main.py, src/mcp_agent/cli/cloud/commands/servers/describe/main.py, src/mcp_agent/cli/cloud/commands/servers/list/main.py
Reformat function signatures and calls; list command now safely accesses status via appServerInfo for MCPApp/MCPAppConfiguration; otherwise behavior unchanged.
Workflows commands adjustments
src/mcp_agent/cli/cloud/commands/workflows/cancel/main.py, src/mcp_agent/cli/cloud/commands/workflows/describe/main.py, src/mcp_agent/cli/cloud/commands/workflows/resume/main.py
Mostly formatting; describe adds output-format validation and an empty-status check; cancel/resume refactors are stylistic only.
Cloud command utilities
src/mcp_agent/cli/cloud/commands/utils.py
Predominantly formatting; resolve_server now wraps unknown exceptions into CLIError with contextual message.
Core utilities styling
src/mcp_agent/cli/core/utils.py
Formatting-only changes; no logic changes.
API client model expansions
src/mcp_agent/cli/mcp_app/api_client.py
Extend enums and data models: new WorkflowExecutionStatus member; WorkflowInfo gains workflow_id, created_at, principal_id, execution_status; ListWorkflowsResponse holds workflows; log models enriched (LogEntry fields, GetAppLogsResponse logEntries and log_entries_list).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant CLI as cloud workflows list
  participant Utils as resolve_server/URL
  participant App as MCPApp (quiet)
  participant Client as gen_client
  participant Server as MCP Server

  User->>CLI: list_workflows(server_id_or_url, format)
  CLI->>Utils: resolve server ID/URL
  Utils-->>CLI: server_url or error
  CLI->>App: start + register workflow_server (SSE URL)
  CLI->>Client: gen_client(workflow_server)
  Client->>Server: tool call "workflows-list"
  Server-->>Client: workflows data
  Client-->>CLI: result payload
  CLI->>User: print (text/json/yaml)
  Note over CLI: Errors wrapped in CLIError
Loading
sequenceDiagram
  autonumber
  participant User
  participant CLI as cloud workflows runs
  participant Utils as resolve_server/URL
  participant App as MCPApp (quiet)
  participant Client as gen_client
  participant Server as MCP Server

  User->>CLI: list_workflow_runs(server_id_or_url, format)
  CLI->>Utils: resolve server ID/URL
  Utils-->>CLI: server_url or error
  CLI->>App: start + register workflow_server (SSE URL)
  CLI->>Client: gen_client(workflow_server)
  Client->>Server: tool call "workflows-get_runs" (implicit)
  Server-->>Client: runs data
  Client-->>CLI: result payload
  CLI->>User: print runs (text/json/yaml)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • rholinshead
  • saqadri

Poem

A bunny taps the CLI keys, hop-hop!
New workflows bloom; old routes, we drop.
Lists and runs in tidy rows,
SSE breeze where data flows.
Models grow whiskers—fields anew—
Thump! The clouds reply, “Reviewed!” 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28a0822 and fad795d.

📒 Files selected for processing (17)
  • src/mcp_agent/cli/cloud/commands/servers/__init__.py (1 hunks)
  • src/mcp_agent/cli/cloud/commands/servers/delete/main.py (3 hunks)
  • src/mcp_agent/cli/cloud/commands/servers/describe/main.py (6 hunks)
  • src/mcp_agent/cli/cloud/commands/servers/list/main.py (8 hunks)
  • src/mcp_agent/cli/cloud/commands/servers/workflows/__init__.py (0 hunks)
  • src/mcp_agent/cli/cloud/commands/utils.py (6 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/__init__.py (1 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/cancel/main.py (1 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/describe/main.py (4 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/list/__init__.py (1 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/list/main.py (1 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/resume/main.py (2 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/runs/__init__.py (1 hunks)
  • src/mcp_agent/cli/cloud/commands/workflows/runs/main.py (7 hunks)
  • src/mcp_agent/cli/cloud/main.py (3 hunks)
  • src/mcp_agent/cli/core/utils.py (2 hunks)
  • src/mcp_agent/cli/mcp_app/api_client.py (5 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 09-08-add_workflow_list_and_runs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor Author

jtcorbett commented Sep 8, 2025

@jtcorbett jtcorbett marked this pull request as ready for review September 8, 2025 21:30
Comment on lines +172 to +175
app_cmd_servers.command(
name="workflows",
help="List available workflows for a server (alias for 'workflows list')",
)(list_workflows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic Mismatch in Server Workflows Command Alias

There appears to be a functional regression in the server workflows command alias. The mcp-agent cloud servers workflows command previously called list_workflows_for_server which showed workflow runs, but now it's aliased to list_workflows which shows workflow definitions instead.

This creates inconsistent behavior where:

mcp-agent cloud servers workflows app_123

Now returns a different result than before (workflow definitions instead of runs).

To maintain backward compatibility and expected behavior, this alias should point to list_workflow_runs instead, which is the renamed version of the original list_workflows_for_server function.

Suggested change
app_cmd_servers.command(
name="workflows",
help="List available workflows for a server (alias for 'workflows list')",
)(list_workflows)
app_cmd_servers.command(
name="workflows",
help="List available workflow runs for a server (alias for 'workflows runs')",
)(list_workflow_runs)

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jtcorbett jtcorbett changed the base branch from add_server_workflow to graphite-base/430 September 8, 2025 21:32
@jtcorbett jtcorbett force-pushed the 09-08-add_workflow_list_and_runs branch from 30d4438 to 9fdf4b8 Compare September 8, 2025 21:34
@jtcorbett jtcorbett changed the base branch from graphite-base/430 to add_server_workflow September 8, 2025 21:35
@jtcorbett jtcorbett changed the base branch from add_server_workflow to graphite-base/430 September 8, 2025 21:36
@jtcorbett jtcorbett force-pushed the 09-08-add_workflow_list_and_runs branch from 9fdf4b8 to fad795d Compare September 8, 2025 21:45
@jtcorbett jtcorbett changed the base branch from graphite-base/430 to main September 8, 2025 21:45
Copy link
Contributor Author

jtcorbett commented Sep 8, 2025

Merge activity

  • Sep 8, 9:50 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Sep 8, 9:50 PM UTC: @jtcorbett merged this pull request with Graphite.

@jtcorbett jtcorbett merged commit 078b11a into main Sep 8, 2025
6 of 7 checks passed
andrew-lastmile added a commit that referenced this pull request Sep 11, 2025
* Temporarily exclude CLI from test coverage (#429)

### TL;DR

Exclude CLI code from test coverage metrics for now. Will add tests when we're done sprinting 10000 mph 

![Added via Giphy](https://media4.giphy.com/media/v1.Y2lkPWM5NDg3NzQzOTNudmtpNXcyazNnZWo2enIzem5neXR2a3l0cGx5aWFlbDB6ZTA1dyZlcD12MV9naWZzX3NlYXJjaCZjdD1n/sRKg9r2YWeCTG5JTTo/giphy.gif)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Tests**
  * Adjusted test coverage collection to exclude non-critical CLI components, resulting in more accurate coverage metrics for core functionality.

* **Chores**
  * Updated coverage reporting configuration to align with the new exclusion rules, ensuring consistent results across local and CI runs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* Add workflow commands to CLI (#424)

### TL;DR

Added workflow management commands to the MCP Agent CLI, including describe, suspend, resume, and cancel operations.

### What changed?

- Added four new workflow management commands:
    - `describe_workflow`: Shows detailed information about a workflow execution
    - `suspend_workflow`: Pauses a running workflow execution
    - `resume_workflow`: Resumes a previously suspended workflow
    - `cancel_workflow`: Permanently stops a workflow execution
- Implemented corresponding API client methods in `WorkflowAPIClient`:
    - `suspend_workflow`
    - `resume_workflow`
    - `cancel_workflow`
- Updated the CLI structure to expose these commands under `mcp-agent cloud workflows`
- Added an alias for `describe_workflow` as `status` for backward compatibility

### How to test?

Test the new workflow commands with a running workflow:

```
# Get workflow details
mcp-agent cloud workflows describe run_abc123
mcp-agent cloud workflows status run_abc123  # alias

# Suspend a workflow
mcp-agent cloud workflows suspend run_abc123

# Resume a workflow (with optional payload)
mcp-agent cloud workflows resume run_abc123
mcp-agent cloud workflows resume run_abc123 --payload '{"data": "value"}'

# Cancel a workflow (with optional reason)
mcp-agent cloud workflows cancel run_abc123
mcp-agent cloud workflows cancel run_abc123 --reason "User requested cancellation"
```

### Why make this change?

These commands provide essential workflow lifecycle management capabilities to users, allowing them to monitor and control workflow executions through the CLI. The ability to suspend, resume, and cancel workflows gives users more control over long-running operations and helps manage resources more efficiently.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- New Features
  - Introduced “workflows” CLI group with commands: describe (alias: status), resume, suspend, and cancel.
  - Describe supports text, JSON, and YAML output; all commands work with server ID or URL and include improved error messages.

- Refactor
  - Renamed CLI group from “workflow” to “workflows” and reorganized command registrations.
  - Consolidated internal utility imports (no behavior change).

- Chores
  - Updated module descriptions.
  - Removed legacy workflow status package/exports in favor of the new workflows commands.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* add servers workflow subcommand (#428)

# Add servers workflows subcommand

This PR adds a new `workflows` subcommand to the `mcp-agent cloud servers` command that allows users to list workflows associated with a specific server. The command supports:

- Filtering by workflow status
- Limiting the number of results
- Multiple output formats (text, JSON, YAML)
- Accepting server IDs, app config IDs, or server URLs as input

Examples:
```
mcp-agent cloud servers workflows app_abc123
mcp-agent cloud servers workflows https://server.example.com --status running
mcp-agent cloud servers workflows apcnf_xyz789 --limit 10 --format json
```

The PR also cleans up the examples in the existing workflow commands and adds the necessary API client support for listing workflows.

* add workflow list and runs (#430)

### TL;DR

Reorganized workflow commands

`mcp-agent cloud workflows runs`
`mcp-agent cloud workflows list`
`mcp-agent cloud server workflows` (alias of workflows list)

### What changed?

- Moved `list_workflows_for_server` from the servers module to the workflows module as `list_workflow_runs`
- Added new workflow commands: `list_workflows` and `list_workflow_runs`
- Updated CLI command structure to make workflows commands more intuitive
- Applied consistent code formatting with black across all server and workflow related files

### How to test?

Test the new and reorganized workflow commands:

```bash
# List available workflow definitions
mcp-agent cloud workflows list app_abc123

# List workflow runs (previously under servers workflows)
mcp-agent cloud workflows runs app_abc123

# Test with different output formats
mcp-agent cloud workflows list app_abc123 --format json
mcp-agent cloud workflows runs app_abc123 --format yaml

# Verify existing commands still work
mcp-agent cloud servers list
mcp-agent cloud workflows describe app_abc123 run_xyz789
```

* [ez] Move deploy command to cloud namespace (#431)

### TL;DR

Added `cloud deploy` command as an alias for the existing `deploy` command.

* First pass at implementing the mcp-agent CLI (#409)

* Initial scaffolding

* initial CLI

* checkpoint

* checkpoint 2

* various updates to cli

* fix lint and format

* fix: should load secrets.yaml template instead when running init cli command

* fix: prevent None values in either mcp-agent secrets and config yaml files from overwriting one another when merging both

* fix: when running config check, use get_settings() instead of Settings() to ensure settings are loaded.

* fix: handle None values for servers in MCPSettings so it defaults to empty dict and update secrets.yaml template so it does not overwrite mcp servers in config

* Inform users to save and close editor to continue when running config edit command

* fix: Update openai, anthropic and azure regex for keys cli command

* Sort model list by provider and model name

* Add filtering support for models list cli command

* disable untested commands

* lint, format, gen_schema

* get rid of accidental otlp exporter changes from another branch

* get rid of accidental commit from other branch

---------

Co-authored-by: StreetLamb <[email protected]>

* Docs MVP (#436)

* Initial scaffolding

* initial CLI

* checkpoint

* checkpoint 2

* various updates to cli

* fix lint and format

* fix: should load secrets.yaml template instead when running init cli command

* fix: prevent None values in either mcp-agent secrets and config yaml files from overwriting one another when merging both

* fix: when running config check, use get_settings() instead of Settings() to ensure settings are loaded.

* fix: handle None values for servers in MCPSettings so it defaults to empty dict and update secrets.yaml template so it does not overwrite mcp servers in config

* Inform users to save and close editor to continue when running config edit command

* fix: Update openai, anthropic and azure regex for keys cli command

* Sort model list by provider and model name

* Add filtering support for models list cli command

* disable untested commands

* Fixes to docs

* Updating the main.py and !developer_secrets for secrets

* updating python entry files to main.py

* Fix tracer.py

---------

Co-authored-by: StreetLamb <[email protected]>
Co-authored-by: Andrew Hoh <[email protected]>

* fix: max complete token for openai gen structured (#438)

* Fix regression in CLI ("cloud cloud")

* docs fixes

* Fix top-level cli cloud commands (deploy, login, etc)

* Add eager tool validation to ensure json serializability of input params/result types

* More docs updates

* Refactor workflow runs list to use MCP tool calls (#439)

### TL;DR

Refactored the workflow runs listing command to use MCP tool calls instead of direct API client calls.

### What changed?

- Replaced the direct API client approach with MCP tool calls to retrieve workflow runs
- Added a new `_list_workflow_runs_async` function that uses the MCP App and gen_client to communicate with the server
- Improved status filtering and display logic to work with both object and dictionary response formats
- Enhanced error handling and formatting of workflow run information
- Updated the workflow data processing to handle different response formats more robustly

### How to test?

```bash
# List workflow runs from a server
mcp-agent cloud workflows runs <server_id_or_url>

# Filter by status
mcp-agent cloud workflows runs <server_id_or_url> --status running

# Limit results
mcp-agent cloud workflows runs <server_id_or_url> --limit 10

# Change output format
mcp-agent cloud workflows runs <server_id_or_url> --format json
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- New Features
  - Add status filtering for workflow runs, with common aliases (e.g., timeout → timed_out).
  - Add an optional limit to constrain the number of results.
  - Allow server selection via direct URL or config-based server ID.

- Refactor
  - Update text output: columns now show Workflow ID, Name, Status, Run ID, Created; Principal removed.
  - Improve date formatting and consistent JSON/YAML/Text rendering.

- Bug Fixes
  - Clearer error messages and safer handling when server info is missing or no data is returned.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* Update workflows commands UI to be more consistant with the rest of the CLI (#432)

### TL;DR

Improved CLI workflow command output formatting with better visual indicators and consistent styling.

### How to test?

```
mcp-agent cloud workflows cancel <run-id>
mcp-agent cloud workflows describe <run-id>
mcp-agent cloud workflows resume <run-id>
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Style**
  * Cancel workflow: added a blank line before the status and changed the success icon to 🚫 (yellow).
  * Describe workflow: replaced panel UI with a clean, header-based text layout (“🔍 Workflow Details”), showing name with colorized status and fields for Workflow ID, Run ID, and Created. Updated status indicators with emojis and colors; timestamp is now plain text on its own line.
  * Resume workflow: success message now applies consistent coloring to the entire line for improved readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* Feature: Update Workflow Tool Calls to Work with workflow_id (#435)

* Support for workflow_id and run_id

* Update temporal workflow registry

* tests

* Update LLMS.txt

* Fix config

* Return bool for cancel result

* Validate ids provided

* Fix cancel workflow id

* Fix workflows-resume response

* Add workflow-name specific resume and cancel tools

* Fix return type

* Fix examples

* Remove redundant workflows-{name}-tool tool calls

* Add _workflow_status back

* Use registry helper

* Changes from review

* Add back evaluator_optimizer enum fix

* Fix a hang that can happen at shutdown (#440)

* Fix a shutdown hang

* Fix tests

* fix taskgroup closed in a different context than when it was started in error

* some PR feedback fixes

* PR feedback

* Fix random failures of server aggregator not found for agent in temporal (#441)

* Fix a shutdown hang

* Fix tests

* fix taskgroup closed in a different context than when it was started in error

* some PR feedback fixes

* Fix random failures of server aggregator not found for agent in temporal environment

* Bump pyproject version

* Fix gateway URL resolution (#443)

* Fix gateway URL resolution

Removed incorrect dependence on ServerRegistry for gateway URLs; the gateway is not an MCP server.
App server (src/mcp_agent/server/app_server.py) builds workflow memo with:
- gateway_url precedence: X-MCP-Gateway-URL or X-Forwarded-Url → reconstruct X-Forwarded-Proto/Host/Prefix → request.base_url → MCP_GATEWAY_URL env.
- gateway_token precedence: X-MCP-Gateway-Token → MCP_GATEWAY_TOKEN env.
Worker-side (SystemActivities/SessionProxy) uses memo.gateway_url and gateway_token; falls back to worker env.
Client proxy helpers (src/mcp_agent/mcp/client_proxy.py):
- _resolve_gateway_url: explicit param → context → env → local default.
- Updated public signatures to drop server_registry parameter.

* Cloud/deployable temporal example (#395)

* Move workflows to workflows.py file

* Fix router example

* Add remaining dependencies

* Update orchestrator to @app.async_tool example

* Changes from review

* Fix interactive_workflow to be runnable via tool

* Fix resume tool params

* Fix: Use helpful typer and invoke for root cli commands (#444)

* Use helpful typer and invoke for root cli commands

* Fix lint

* Fix enum check (#445)

* Fix/swap relative mcp agent dependency on deploy (#446)

* Update wrangler wrapper to handle requirements.txt processing

* Fix backup handling

* pass api key to workflow (#447)

* pass api key to workflow

* guard against settings not existing

---------

Co-authored-by: John Corbett <[email protected]>
Co-authored-by: Sarmad Qadri <[email protected]>
Co-authored-by: StreetLamb <[email protected]>
Co-authored-by: Yi <[email protected]>
Co-authored-by: Ryan Holinshead <[email protected]>
Co-authored-by: roman-van-der-krogt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants