search-channels
Search for social platform channels using platform-specific queries. Input platform name, search term, and optional parameters like limit, cursor, and channel inclusion for targeted results.
Instructions
Search for channels on a social platform
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Cursor for pagination | |
| includeChannels | No | Whether to include channel information in results | |
| limit | No | Maximum number of results to return | |
| platform | Yes | The platform to search on (e.g., 'farcaster') | |
| query | Yes | The search query |
Implementation Reference
- src/mcp/tools/contentTools.ts:63-121 (registration)Registration of the 'search-channels' MCP tool, including description, input schema, and inline handler function that delegates to platform provider's searchChannels method and formats results.server.tool( "search-channels", "Search for channels on a social platform", { platform: z.string().describe("The platform to search on (e.g., 'farcaster')"), query: z.string().describe("The search query"), limit: z.number().optional().describe("Maximum number of results to return"), cursor: z.string().optional().describe("Cursor for pagination"), includeChannels: z.boolean().optional().describe("Whether to include channel information in results") }, async ({ platform, query, limit, cursor, includeChannels }) => { try { const provider = providerRegistry.getProviderForPlatform(platform); if (!provider) { throw new Error(`Provider for platform '${platform}' not found`); } // Check if the provider supports channel search if (!provider.searchChannels) { throw new Error(`Channel search is not supported for platform '${platform}'`); } const results = await provider.searchChannels(query, { limit, cursor, includeChannels }); // Format the results const formattedResults = results.channels.map(channel => `Channel: ${channel.name}\n` + `Description: ${channel.description || 'No description'}\n` + `Followers: ${channel.followerCount}\n` + `Created: ${channel.createdAt}\n` + `URL: ${channel.parentUrl || 'N/A'}\n` ).join('\n'); let response = `Found ${results.channels.length} channels:\n\n${formattedResults}`; if (results.nextCursor) { response += `\n\nUse the cursor "${results.nextCursor}" to fetch more results.`; } return { content: [{ type: "text", text: response }], isError: false }; } catch (error) { console.error(`Error in search-channels tool:`, error); return { content: [{ type: "text", text: `Error searching channels on ${platform} for '${query}': ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/mcp/tools/contentTools.ts:73-120 (handler)The execution handler for the 'search-channels' tool. Retrieves the platform provider, validates support for channel search, invokes provider.searchChannels, formats channel details (name, desc, followers, created, URL), handles pagination cursor, and returns formatted text response or error.async ({ platform, query, limit, cursor, includeChannels }) => { try { const provider = providerRegistry.getProviderForPlatform(platform); if (!provider) { throw new Error(`Provider for platform '${platform}' not found`); } // Check if the provider supports channel search if (!provider.searchChannels) { throw new Error(`Channel search is not supported for platform '${platform}'`); } const results = await provider.searchChannels(query, { limit, cursor, includeChannels }); // Format the results const formattedResults = results.channels.map(channel => `Channel: ${channel.name}\n` + `Description: ${channel.description || 'No description'}\n` + `Followers: ${channel.followerCount}\n` + `Created: ${channel.createdAt}\n` + `URL: ${channel.parentUrl || 'N/A'}\n` ).join('\n'); let response = `Found ${results.channels.length} channels:\n\n${formattedResults}`; if (results.nextCursor) { response += `\n\nUse the cursor "${results.nextCursor}" to fetch more results.`; } return { content: [{ type: "text", text: response }], isError: false }; } catch (error) { console.error(`Error in search-channels tool:`, error); return { content: [{ type: "text", text: `Error searching channels on ${platform} for '${query}': ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/mcp/tools/contentTools.ts:66-72 (schema)Zod input schema for 'search-channels' tool defining parameters: platform (string), query (string), optional limit (number), cursor (string), includeChannels (boolean).{ platform: z.string().describe("The platform to search on (e.g., 'farcaster')"), query: z.string().describe("The search query"), limit: z.number().optional().describe("Maximum number of results to return"), cursor: z.string().optional().describe("Cursor for pagination"), includeChannels: z.boolean().optional().describe("Whether to include channel information in results") },
- src/mcp/server.ts:25-27 (registration)Top-level registration call to registerContentTools which includes the 'search-channels' tool among others.registerContentResources(server, providerRegistry); registerContentTools(server, providerRegistry); registerContentPrompts(server);