# Run AI Command — HARPA AI

> Run an AI command. See the documentation

- Key: `harpa_ai-run-ai-command`
- Type: Action (Write)
- Version: 0.0.2
- App: HARPA AI (`harpa_ai`) — https://pipedream.com/apps/harpa-ai.md
- This page (HTML): https://pipedream.com/apps/harpa-ai/actions/run-ai-command
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/harpa_ai/actions/run-ai-command/run-ai-command.mjs

## Description

Run an AI command. [See the documentation](https://harpa.ai/grid/grid-rest-api-reference#run-ai-command)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `url` | `string` | Yes | the page to run the AI command over |
| `name` | `string` | No | A command name to execute such as Summary |
| `inputs` | `string[]` | No | An array of Strings, each one passed down into command in place of the user input. Inputs are used to bypass waiting for the user input in multi-step commands. For example [ "REPORT", "DONE" ] for the Summary command. |
| `resultParam` | `string` | No | A HARPA {{parameter}} to interpret as the command result. By default is set to "message" to take the last chat message. Supports dot notation, e.g. "g.data.email". Refer to AI Commands Guide for more details. |
| `node` | `string` | No | A target Node ID which should run the command. If omitted, the first available Node will be used. |
| `timeout` | `string` | No | Synchronous action execution timeout |
| `resultsWebhook` | `string` | No | An asynchronous webhook URL to send the results to upon completion |
| `connection` | `string` | No | The title or ID of AI connection to use for AI actions. If not specified or connection not found, default connection is used. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "harpa_ai",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "harpa_ai-run-ai-command",
  arguments: {
    url: "URL",
    name: "Name",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "harpa_ai-run-ai-command",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    harpa_ai: { authProvisionId: "apn_xxxxxxx" },
    url: "URL",
    name: "Name",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "harpa_ai-run-ai-command",
    "configured_props": {
      "harpa_ai": { "authProvisionId": "apn_xxxxxxx" },
      "url": "URL",
      "name": "Name"
    }
  }'
```

---

- App: https://pipedream.com/apps/harpa-ai.md · All apps: https://pipedream.com/apps
