# Tuya — Pipedream Connect

> Global AI Cloud Platform Service Provider

- API slug: `tuya` (use in MCP headers and tool keys)
- Auth: API key (Pipedream-managed)
- Categories: Smart Home Automation
- Website: https://tuya.com/
- This page (HTML): https://pipedream.com/apps/tuya
- Tools: 3 actions · 1 trigger

## Connect via MCP (recommended)

- Endpoint: `https://remote.mcp.pipedream.net/v3`
- Headers: `Authorization: Bearer <token>` · `x-pd-project-id` · `x-pd-environment` · `x-pd-external-user-id` · `x-pd-app-slug: tuya`

```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": "tuya",
      },
    },
  },
)

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

const { tools } = await mcp.listTools()

// e.g. run List Devices:
const result = await mcp.callTool({
  name: "tuya-list-devices",
  arguments: {
    userId: "User ID",
    homeId: "Home ID",
  },
})
```

Docs: [MCP guide](https://pipedream.com/docs/connect/mcp/developers.md)

## SDK

```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: "tuya-list-devices",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    tuya: { authProvisionId: "apn_xxxxxxx" },
    userId: "User ID",
    homeId: "Home ID",
  },
})
```

Docs: [Managed auth guide](https://pipedream.com/docs/connect/managed-auth/quickstart.md) · [Tools guide](https://pipedream.com/docs/connect/components.md)

## Actions (3)

### `tuya-list-devices` — List Devices (Read-only)

Get a list of devices associated with a home. See the documentation

Full schema: https://pipedream.com/apps/tuya/actions/list-devices.md

### `tuya-list-homes` — List Homes (Read-only)

Based on the user ID, query the list of homes where the specified user belongs. See the documentation

Full schema: https://pipedream.com/apps/tuya/actions/list-homes.md

### `tuya-send-instructions-to-device` — Send Instructions to Device (Write)

Send an instruction to the specified device. See the documentation

Full schema: https://pipedream.com/apps/tuya/actions/send-instructions-to-device.md

## Triggers (1)

### `tuya-new-device-parameter-updated` — New Device Parameter Updated (Polling)

Emit new event when the specified device parameter is updated. See the documentation

Full schema: https://pipedream.com/apps/tuya/triggers/new-device-parameter-updated.md

---

- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
