Skip to main content
Glama
DLHellMe
by DLHellMe

api_search_channel

Search for messages within a Telegram channel using specific queries to find relevant content quickly.

Instructions

Search for messages within a Telegram channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe Telegram channel URL
queryYesSearch query
limitNoMaximum number of results

Implementation Reference

  • The main handler function that checks API connection, extracts parameters (channel URL, query, limit), calls the scraper's search method, formats results with MarkdownFormatter, and returns the search results or error messages.
    async handleApiSearchChannel(this: any, args: any): Promise<any> {
      if (!this._apiScraper || !this._apiScraper.isConnected()) {
        return {
          content: [{
            type: 'text',
            text: '❌ Not connected to Telegram API. Please use telegram_api_login first.'
          }]
        };
      }
      
      try {
        const channelUrl = args.url || args.channel;
        const query = args.query || args.search || '';
        const limit = args.limit || 1000;
        
        if (!query) {
          return {
            content: [{
              type: 'text',
              text: '❌ Please provide a search query'
            }]
          };
        }
        
        const result = await this._apiScraper.search(channelUrl, query, limit);
        
        const formatter = new (await import('./formatters/markdown-formatter.js')).MarkdownFormatter();
        const markdown = formatter.format(result);
        
        return {
          content: [{
            type: 'text',
            text: `# Search Results for "${query}"\n\n${markdown}\n\n✅ Searched using Telegram API`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `❌ Search failed: ${error instanceof Error ? error.message : 'Unknown error'}`
          }]
        };
      }
    },
  • src/server.ts:337-358 (registration)
    Registers the 'api_search_channel' tool in the MCP server's tool list, including its description and input schema for validation.
      name: 'api_search_channel',
      description: 'Search for messages within a Telegram channel',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'The Telegram channel URL'
          },
          query: {
            type: 'string',
            description: 'Search query'
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results',
            default: 50
          }
        },
        required: ['url', 'query']
      }
    },
  • src/server.ts:101-102 (registration)
    Dispatches tool calls to the appropriate handler in the main request handler switch statement.
    case 'api_search_channel':
      return await this.handleApiSearchChannel(args);
  • src/server.ts:765-765 (registration)
    Binds the handler from apiHandlers to the server instance for use in tool dispatching.
    private handleApiSearchChannel = apiHandlers.handleApiSearchChannel.bind(this);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it indicates a search operation, it doesn't describe important behavioral aspects such as authentication requirements, rate limits, error handling, pagination, or what the search results look like. For a tool with no annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a straightforward search tool and front-loads the key information, making it easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is insufficiently complete. It doesn't address authentication needs, result format, error conditions, or how it differs from similar sibling tools. For a search operation in a context with multiple channel-related tools, more contextual information would be needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear documentation for all three parameters (url, query, limit). The description doesn't add any meaningful semantic context beyond what's already in the schema, such as URL format examples, query syntax, or practical usage tips. With high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Search for messages within a Telegram channel', which includes a specific verb ('Search') and resource ('messages within a Telegram channel'). However, it doesn't explicitly differentiate from sibling tools like 'scrape_channel' or 'scrape_date_range', which might have overlapping functionality for retrieving channel content.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools like 'scrape_channel', 'scrape_channel_full', and 'scrape_date_range' that might retrieve channel content, there's no indication of when this search-specific tool is preferred or what its limitations are compared to others.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DLHellMe/telegram-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server