MCPcopy Create free account
hub / github.com/codeaashu/claude-code / fetchChannels

Function fetchChannels

src/utils/suggestions/slackChannelSuggestions.ts:29–65  ·  view source on GitHub ↗
(
  clients: MCPServerConnection[],
  query: string,
)

Source from the content-addressed store, hash-verified

27}
28
29async function fetchChannels(
30 clients: MCPServerConnection[],
31 query: string,
32): Promise<string[]> {
33 const slackClient = findSlackClient(clients)
34 if (!slackClient || slackClient.type !== 'connected') {
35 return []
36 }
37
38 try {
39 const result = await slackClient.client.callTool(
40 {
41 name: SLACK_SEARCH_TOOL,
42 arguments: {
43 query,
44 limit: 20,
45 channel_types: 'public_channel,private_channel',
46 },
47 },
48 undefined,
49 { timeout: 5000 },
50 )
51
52 const content = result.content
53 if (!Array.isArray(content)) return []
54
55 const rawText = content
56 .filter((c): c is { type: 'text'; text: string } => c.type === 'text')
57 .map(c => c.text)
58 .join('\n')
59
60 return parseChannels(unwrapResults(rawText))
61 } catch (error) {
62 logForDebugging(`Failed to fetch Slack channels: ${error}`)
63 return []
64 }
65}
66
67// The Slack MCP server wraps its markdown in a JSON envelope:
68// {"results":"# Search Results...\nName: #chan\n..."}

Callers 1

Calls 5

findSlackClientFunction · 0.85
parseChannelsFunction · 0.85
unwrapResultsFunction · 0.85
logForDebuggingFunction · 0.85
callToolMethod · 0.80

Tested by

no test coverage detected