Skip to main content
Glama
billyfranklim1

mcp-evolution

Find Chats

find_chats

Retrieve chats from your WhatsApp instance with optional text search, result limit, and offset to control payload size.

Instructions

Find chats for the pinned instance. Supports search, limit, and offset to prevent large payloads.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
whereNoOptional Prisma-style filter object (power-user). If supplied, search is ignored.
searchNoConvenience substring filter against pushName or remoteJid (case-insensitive). Ignored when where is provided.
limitNoMax results to return (default 50, max 500).
offsetNoSkip first N results (default 0).

Implementation Reference

  • The registerFindChats function registers the 'find_chats' tool with the MCP server. The handler (async callback from line 50-95) executes the core logic: builds a payload with limit/offset, calls Evolution API POST /chat/findChats/{instanceName}, optionally filters client-side by search (pushName/remoteJid), applies slice for safety, and normalizes the response to compact shape.
    export function registerFindChats(server: McpServer, client: EvolutionClient): void {
      server.registerTool(
        "find_chats",
        {
          title: "Find Chats",
          description:
            "Find chats for the pinned instance. Supports search, limit, and offset to prevent large payloads.",
          inputSchema: schema,
        },
        async (args) => {
          try {
            const limit = args.limit ?? 50;
            const offset = args.offset ?? 0;
    
            // Build Evolution request body — pass limit/offset as top-level keys (Evolution v2)
            const payload: Record<string, unknown> = args.where
              ? { where: args.where, limit, offset }
              : { limit, offset };
    
            const raw = await client.post(`/chat/findChats/${client.instanceName}`, payload);
    
            let chats: ChatItem[] = Array.isArray(raw) ? raw : [];
    
            // Client-side search only when no custom where was supplied
            if (!args.where && args.search) {
              const needle = args.search.toLowerCase();
              chats = chats.filter(
                (c) =>
                  c.pushName?.toLowerCase().includes(needle) ||
                  c.remoteJid?.toLowerCase().includes(needle)
              );
            }
    
            // Client-side safety net for limit/offset (in case Evolution ignores them)
            chats = chats.slice(offset, offset + limit);
    
            // Normalize to compact shape — drop all extra fields to shrink payload
            const normalized = chats.map(({ remoteJid, pushName, name, unreadCount, updatedAt }) => ({
              remoteJid,
              pushName,
              name,
              unreadCount,
              updatedAt,
            }));
    
            return {
              content: [{ type: "text" as const, text: JSON.stringify(normalized, null, 2) }],
            };
          } catch (e) {
            if (e instanceof McpError) {
              return { isError: true, content: [{ type: "text" as const, text: e.message }] };
            }
            throw e;
          }
        }
      );
    }
  • Input schema defined with Zod: 'where' (optional Prisma-style filter record), 'search' (optional substring filter), 'limit' (int 1-500, default 50), 'offset' (int min 0, default 0).
    const schema = {
      where: z
        .record(z.unknown())
        .optional()
        .describe("Optional Prisma-style filter object (power-user). If supplied, search is ignored."),
      search: z
        .string()
        .optional()
        .describe("Convenience substring filter against pushName or remoteJid (case-insensitive). Ignored when where is provided."),
      limit: z
        .number()
        .int()
        .min(1)
        .max(500)
        .default(50)
        .optional()
        .describe("Max results to return (default 50, max 500)."),
      offset: z
        .number()
        .int()
        .min(0)
        .default(0)
        .optional()
        .describe("Skip first N results (default 0)."),
    };
  • Tool is registered by calling registerFindChats(server, client) inside registerAllTools().
    registerFindChats(server, client);
  • src/tools/index.ts:6-6 (registration)
    Import statement: import { registerFindChats } from './find-chats.js'.
    import { registerFindChats } from "./find-chats.js";
Behavior3/5

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

No annotations exist, so the description carries the full burden. It discloses that limit/offset prevent large payloads and mentions Prisma-style filtering. However, it does not state read-only semantics, authentication needs, or error handling.

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 two sentences, concise and front-loaded with the core purpose. No extraneous text.

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?

For a tool with nested objects, 4 parameters, and no output schema, the description is too brief. It lacks details on return format, pagination behavior, and error states. Given the complexity, more completeness is needed.

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?

Input schema has 100% description coverage for all 4 parameters. The description adds context that limit/offset exist to prevent large payloads, which reinforces but does not significantly extend schema information.

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 'Find chats for the pinned instance' (verb+resource) and mentions key features (search, limit, offset). It distinguishes from similar sibling tools by specifying context 'for the pinned instance', though it does not explicitly differentiate from other find tools.

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?

No guidance is provided on when to use this tool versus alternatives. There is no mention of when not to use it or what context would be better for a different tool.

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/billyfranklim1/mcp-evolution'

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