# Run MCP Action

**Action ID:** `mcp_run_action`

## Description

Run any action on MCP.

## Connection

| Name           | Description                               | Required | Category |
| -------------- | ----------------------------------------- | -------- | -------- |
| MCP Connection | The MCP connection to use for the action. | True     | mcp      |

## Input Parameters

| Name          | Type   | Required | Default | Description                                        |
| ------------- | ------ | :------: | ------- | -------------------------------------------------- |
| action        | string |     ✓    | -       | The name of the action to run on MCP               |
| input\_params | object |     ✓    | -       | Input parameters for the action (varies by action) |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Run MCP run action node input.",
  "properties": {
    "action": {
      "description": "The action to run. This is the name of the action to run.",
      "title": "Action",
      "type": "string"
    },
    "input_params": {
      "additionalProperties": true,
      "description": "The input parameters for the model. These vary depending on the model you're using. Check the model's documentation for details.",
      "title": "Input Parameters",
      "type": "object"
    }
  },
  "required": [
    "action",
    "input_params"
  ],
  "title": "MCPRunActionInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name    | Type    | Description                                             |
| ------- | ------- | ------------------------------------------------------- |
| success | boolean | Whether the MCP action was successful                   |
| result  | any     | The output from the MCP action (varies by action)       |
| error   | string  | Error message if the action failed (null if successful) |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Output from a MCP run action.",
  "properties": {
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The error from the MCP action.",
      "title": "Error"
    },
    "success": {
      "description": "Whether the MCP action was successful.",
      "title": "Success",
      "type": "boolean"
    },
    "result": {
      "description": "The output from the FAL model. This can be text, URLs to generated images, or other data depending on the model.",
      "title": "Result"
    }
  },
  "required": [
    "success",
    "result"
  ],
  "title": "MCPRunActionOutput",
  "type": "object"
}
```

</details>

## How It Works

This node provides a generic interface to execute any action available on the MCP (Model Context Protocol) platform. You select an action by name from the available options, provide the required input parameters as a JSON object, and the node executes that action through your configured MCP connection. The response includes success status, result data, and error information if applicable. This flexible approach allows you to access various MCP capabilities without needing separate nodes for each action.

## Usage Examples

### Example 1: Run Text Generation Action

**Input:**

```
action: "text-generation"
input_params: {
  "prompt": "Write a product description for wireless headphones",
  "max_length": 150
}
```

**Output:**

```
success: true
result: "Premium wireless headphones with active noise cancellation..."
error: null
```

### Example 2: Run Image Processing Action

**Input:**

```
action: "image-enhance"
input_params: {
  "image_url": "https://example.com/photo.jpg",
  "enhancement_type": "upscale",
  "factor": 2
}
```

**Output:**

```
success: true
result: {
  "enhanced_image_url": "https://mcp.com/enhanced/photo.jpg",
  "dimensions": "3840x2160"
}
error: null
```

### Example 3: Run Data Analysis Action

**Input:**

```
action: "sentiment-analysis"
input_params: {
  "text": "This product exceeded my expectations!",
  "language": "en"
}
```

**Output:**

```
success: true
result: {
  "sentiment": "positive",
  "confidence": 0.95
}
error: null
```

## Common Use Cases

* **AI Model Execution**: Run various AI models available on MCP for text, image, or audio processing
* **API Gateway**: Use MCP as a unified gateway to multiple third-party services and models
* **Dynamic Action Selection**: Programmatically choose which MCP action to run based on workflow logic
* **Model Comparison**: Execute the same operation across different models to compare results
* **Batch Processing**: Run multiple MCP actions sequentially or in parallel within a workflow
* **Custom Integrations**: Access specialized MCP actions for specific business requirements
* **Prototyping**: Quickly test different MCP capabilities without committing to specific implementations

## Error Handling

| Error Type           | Cause                                                | Solution                                                                 |
| -------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------ |
| Connection Failed    | Invalid or missing MCP connection credentials        | Verify your MCP connection is properly configured with valid credentials |
| Action Not Found     | Specified action name doesn't exist on MCP           | Check the available actions list and verify the action name spelling     |
| Invalid Parameters   | input\_params missing required fields or wrong types | Review the action's documentation for required parameter structure       |
| Authentication Error | MCP API key expired or invalid                       | Update your MCP connection with a valid API key                          |
| Rate Limit Exceeded  | Too many requests to MCP in short period             | Implement delays between requests or upgrade your MCP plan               |
| Timeout Error        | Action execution exceeded time limit                 | Simplify the request or increase timeout settings if available           |
| Insufficient Credits | MCP account has insufficient credits for the action  | Add credits to your MCP account or reduce action usage                   |

## Notes

* **Action-Specific Parameters**: Each MCP action has its own parameter requirements. Consult MCP documentation for specific action details.
* **Dynamic Discovery**: The action dropdown is populated from your MCP connection, showing only available actions for your account.
* **Error Checking**: Always check the `success` field in the output before using the `result` data.
* **Parameter Validation**: The input\_params must be valid JSON. Validate your JSON structure before execution.
* **Result Structure**: The `result` field structure varies by action. Handle different result types appropriately in subsequent nodes.
* **Cost Management**: Different MCP actions have different costs. Monitor your usage to control expenses.
* **Version Compatibility**: Ensure your MCP connection version is compatible with the actions you're trying to run.
* **Async Operations**: Some MCP actions may run asynchronously. Check the action documentation for completion handling.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agenticflow.ai/reference/nodes/mcp_run_action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
