MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / findChannelWithAccess

Function findChannelWithAccess

server/src/slack/client.ts:802–835  ·  view source on GitHub ↗
(
  channelName: string,
  slackUserId: string
)

Source from the content-addressed store, hash-verified

800 * Returns channel info if found and accessible
801 */
802export async function findChannelWithAccess(
803 channelName: string,
804 slackUserId: string
805): Promise<{ channel: SlackChannel; hasAccess: boolean; reason?: string } | null> {
806 try {
807 // Get all channels the bot can see
808 const allChannels = await getSlackChannels({
809 types: 'public_channel,private_channel',
810 exclude_archived: true,
811 });
812
813 // Find channel by name (case-insensitive partial match)
814 const normalizedName = channelName.toLowerCase();
815 const matchedChannel = allChannels.find(
816 (c) => c.name.toLowerCase().includes(normalizedName)
817 );
818
819 if (!matchedChannel) {
820 return null;
821 }
822
823 // Check access
824 const access = await checkChannelAccess(matchedChannel.id, slackUserId);
825
826 return {
827 channel: matchedChannel,
828 hasAccess: access.hasAccess,
829 reason: access.reason,
830 };
831 } catch (error) {
832 logger.warn({ error, channelName, slackUserId }, 'Failed to find channel with access check');
833 return null;
834 }
835}
836
837/**
838 * Get the list of private channel IDs the user has access to

Callers 1

Calls 3

getSlackChannelsFunction · 0.85
checkChannelAccessFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected