Skip to content

Commit 82cb711

Browse files
authored
Merge pull request #45 from arvoreeducacao/joaobarrs-/-fix-slack-channel-resolve
fix(slack-advanced): resolve channel name com scopes separados
2 parents 8e8dbad + 8976527 commit 82cb711

2 files changed

Lines changed: 28 additions & 18 deletions

File tree

packages/slack-advanced/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@arvoretech/slack-advanced-mcp",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Advanced Slack MCP Server with semantic user search, smart DMs, style analysis, thread extraction, audio transcription, and image analysis",
55
"main": "dist/index.js",
66
"type": "module",

packages/slack-advanced/src/slack-client.ts

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -212,25 +212,35 @@ export class SlackClient {
212212

213213
const name = identifier.replace(/^#/, "");
214214

215-
let cursor: string | undefined;
216-
do {
217-
const params: Record<string, unknown> = { limit: 200, types: "public_channel,private_channel" };
218-
if (cursor) params.cursor = cursor;
219-
220-
const res = await this.request<{
221-
ok: boolean;
222-
channels: Array<{ id: string; name: string }>;
223-
response_metadata?: { next_cursor?: string };
224-
}>("conversations.list", params);
225-
226-
const match = res.channels.find((c) => c.name === name);
227-
if (match) return match.id;
228-
229-
cursor = res.response_metadata?.next_cursor || undefined;
230-
} while (cursor);
215+
const channelTypes = ["public_channel", "private_channel"];
216+
217+
for (const type of channelTypes) {
218+
try {
219+
let cursor: string | undefined;
220+
do {
221+
const params: Record<string, unknown> = { limit: 200, types: type };
222+
if (cursor) params.cursor = cursor;
223+
224+
const res = await this.request<{
225+
ok: boolean;
226+
channels: Array<{ id: string; name: string }>;
227+
response_metadata?: { next_cursor?: string };
228+
}>("conversations.list", params);
229+
230+
const match = res.channels.find((c) => c.name === name);
231+
if (match) return match.id;
232+
233+
cursor = res.response_metadata?.next_cursor || undefined;
234+
} while (cursor);
235+
} catch (error) {
236+
const isScopeError =
237+
error instanceof SlackAdvancedMCPError && error.message.includes("missing_scope");
238+
if (!isScopeError) throw error;
239+
}
240+
}
231241

232242
throw new SlackAdvancedMCPError(
233-
`Could not resolve channel: ${identifier}`,
243+
`Could not resolve channel: ${identifier}. Tried public and private channel lists. Ensure the token has channels:read and/or groups:read scopes.`,
234244
"CHANNEL_NOT_FOUND"
235245
);
236246
}

0 commit comments

Comments
 (0)