# List Channels — Slack

> Return a list of channels in a workspace. Pass fields (e.g. ["id","name"]) to limit the returned properties — a full channel object is ~1KB, so a workspace of any real size can return a payload large enough to be truncated. Omit fields…

- Key: `slack_v2-list-channels`
- Type: Action (Read-only)
- Version: 0.4.0
- App: Slack (`slack_v2`) — https://pipedream.com/apps/slack-v2.md
- This page (HTML): https://pipedream.com/apps/slack-v2/actions/list-channels
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/slack_v2/actions/list-channels/list-channels.mjs

## Description

Return a list of channels in a workspace. Pass `fields` (e.g. `["id","name"]`) to limit the returned properties — a full channel object is ~1KB, so a workspace of any real size can return a payload large enough to be truncated. Omit `fields` when you need the complete channel objects. Use `namePrefix` to filter results to channels whose names start with a given string (e.g. `dev-`) without a client-side filter loop. Set `memberOnly: true` to return only channels the authenticated user is a member of — on a large workspace this shrinks the result from thousands of channels to the handful that matter, and it is usually what you want when acting on the user's behalf. Returns `has_more: true` and `next_cursor` when more channels exist than were fetched — when you see that, raise `numPages` (or pass `cursor`) before answering any 'how many' or 'list every' question, otherwise your answer is silently incomplete. [See the documentation](https://api.slack.com/methods/conversations.list)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `channelTypes` | `string` | No | Which channel types to list. Pass public_channel for public channels only, private_channel for private channels only, or public_channel,private_channel for both (default). |
| `memberOnly` | `boolean` | No | Return only channels the authenticated user is a member of (uses users.conversations instead of conversations.list). Recommended for large workspaces: the full channel list can run to thousands of entries, while the user's own channels are usually a small fraction of that. Channel Types, Fields, Name Prefix, and pagination all still apply. |
| `fields` | `string[]` | No | Channel properties to return, e.g. id, name, is_private, is_archived, num_members, topic, purpose, created. Strongly recommended: ["id", "name"] is enough for almost every task and keeps the response small. Omit ONLY when you genuinely need the full channel objects — the response is then ~1KB per channel and may be truncated. |
| `pageSize` | `integer` | No | The number of results to include in a page. Default: 250 |
| `numPages` | `integer` | No | The number of pages to retrieve. Default: 1 |
| `cursor` | `string` | No | Resume from a previous call's next_cursor to fetch the following page. |
| `namePrefix` | `string` | No | Return only channels whose names start with this prefix (case-insensitive). Example: dev-. When set, ALL pages are fetched regardless of Number of Pages so the filter is applied across the full workspace channel list. |

## 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": "slack_v2",
      },
    },
  },
)

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: "slack_v2-list-channels",
  arguments: {
    channelTypes: "Channel Types",
    memberOnly: true,
  },
})
```

**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: "slack_v2-list-channels",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    slack_v2: { authProvisionId: "apn_xxxxxxx" },
    channelTypes: "Channel Types",
    memberOnly: true,
  },
})

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": "slack_v2-list-channels",
    "configured_props": {
      "slack_v2": { "authProvisionId": "apn_xxxxxxx" },
      "channelTypes": "Channel Types",
      "memberOnly": true
    }
  }'
```

---

- App: https://pipedream.com/apps/slack-v2.md · All apps: https://pipedream.com/apps
