Skip to main content
Glama
alveyautomation

qbo-mcp

qbo_search_customers

Search QuickBooks Online customers by display name using a substring, case-insensitive query. Returns matching customers and total count, with optional limit on results.

Instructions

Search customers by display name (substring, case-insensitive).

Args: query: Free-text fragment matched against Customer.DisplayName via QBO's LIKE '%query%' operator. limit: Cap on returned customers (1-1000, default 50).

Returns: JSON envelope: {"ok": true, "data": {"customers": [...], "count": N}}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'qbo_search_customers' – registered via @mcp.tool() decorator. Validates input, caps limit to 1-1000, delegates to QBOClient.search_customers(), and returns a JSON envelope.
    @mcp.tool()
    def qbo_search_customers(query: str, limit: int = 50) -> str:
        """Search customers by display name (substring, case-insensitive).
    
        Args:
            query: Free-text fragment matched against Customer.DisplayName
                via QBO's `LIKE '%query%'` operator.
            limit: Cap on returned customers (1-1000, default 50).
    
        Returns:
            JSON envelope: {"ok": true, "data": {"customers": [...], "count": N}}.
        """
        if not query or not query.strip():
            return _err("query is required and must be non-empty")
        try:
            capped = max(1, min(limit, 1000))
            customers = _get_client().search_customers(query=query.strip(), limit=capped)
            return _ok(
                {
                    "customers": customers,
                    "count": len(customers),
                    "query": query.strip(),
                    "limit": capped,
                }
            )
        except (ValueError, QBOError, RuntimeError) as exc:
            return _err(str(exc))
  • The @mcp.tool() decorator registers 'qbo_search_customers' as a FastMCP tool on the 'qbo-mcp' server.
    @mcp.tool()
    def qbo_search_customers(query: str, limit: int = 50) -> str:
  • QBOClient.search_customers() – builds a QBO query with DisplayName LIKE '%<escaped>%', delegates to _paginate_query, and returns a list of customer dicts.
    def search_customers(
        self, query: str, *, limit: int = 50
    ) -> list[dict]:
        """Search active customers by display name (substring, case-insensitive)."""
        if not query or not query.strip():
            raise ValueError("query must be non-empty")
        safe = _escape_qbo_string(query.strip())
        where = f"DisplayName LIKE '%{safe}%'"
        return list(
            self._paginate_query(
                select_clause="SELECT * FROM Customer",
                entity="Customer",
                where=where,
                order_by="DisplayName",
                limit=limit,
            )
        )
  • QBOClient._paginate_query() – handles STARTPOSITION/MAXRESULTS pagination for QBO queries, yielding records up to the requested limit.
    def _paginate_query(
        self,
        *,
        select_clause: str,
        entity: str,
        where: str | None = None,
        order_by: str | None = None,
        limit: int,
        page_size: int = QUERY_PAGE_SIZE,
    ) -> Iterator[dict]:
        """Yield records from a QBO query, handling STARTPOSITION pagination.
    
        QBO's query endpoint requires explicit `STARTPOSITION` and `MAXRESULTS`
        clauses for paging (it never returns a cursor). Stops yielding once
        `limit` records have been emitted, or when a page returns fewer
        rows than `page_size` (signaling the natural end of results).
        """
        if limit <= 0:
            return
        emitted = 0
        start_position = 1
        while True:
            page = max(1, min(page_size, limit - emitted))
            stmt_parts = [select_clause]
            if where:
                stmt_parts.append(f"WHERE {where}")
            if order_by:
                stmt_parts.append(f"ORDER BY {order_by}")
            stmt_parts.append(f"STARTPOSITION {start_position}")
            stmt_parts.append(f"MAXRESULTS {page}")
            stmt = " ".join(stmt_parts)
    
            data = self._query_page(stmt)
            qr = data.get("QueryResponse") or {}
            items = qr.get(entity) or []
    
            for record in items:
                yield record
                emitted += 1
                if emitted >= limit:
                    return
    
            if len(items) < page:
                return
            start_position += len(items)
  • _escape_qbo_string() – escapes backslashes, single quotes, and underscores for safe QBO string literals in LIKE expressions.
    def _escape_qbo_string(value: str) -> str:
        """Escape characters that would break a QBO string literal.
    
        QBO's query language uses single quotes for strings and a backslash as
        the escape character for both `'` and `\\`. `%` and `_` are also
        metacharacters inside `LIKE` expressions; we leave `%` alone so that
        callers don't lose substring semantics, but escape `_` so a literal
        underscore in a customer name doesn't silently match anything.
        """
        return (
            value.replace("\\", "\\\\")
            .replace("'", "\\'")
            .replace("_", "\\_")
        )
Behavior4/5

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

No annotations are provided, so the description carries the burden. It discloses the underlying LIKE operator and return envelope. No mention of authentication or rate limits, but these are less critical for a search tool.

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 concise with two sentences plus structured Args/Returns. It is front-loaded with the purpose and every sentence adds value without redundancy.

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

Completeness5/5

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

Given the output schema exists, the description still provides the return structure (JSON envelope) which is helpful. All aspects of the tool are addressed: purpose, parameters, and return format.

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

Parameters5/5

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

Schema coverage is 0%, but the description adds full context: query is matched via LIKE operator, limit has range 1-1000 and default 50. This adds significant meaning beyond the schema's type declarations.

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

Purpose5/5

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

The description clearly states 'Search customers by display name (substring, case-insensitive)', specifying the verb, resource, and matching method. This distinguishes it from siblings like qbo_search_bills which search different entities.

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

Usage Guidelines4/5

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

The description explains the parameters and their behavior, but does not explicitly state when to use this tool over alternatives. However, sibling tools operate on different entities, so usage context is clear.

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/alveyautomation/qbo-mcp'

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