Skip to main content
Glama

QuickBooks Online MCP Server

by heyibad
search-quickbooks-vendors.handler.ts2.3 kB
import { makeQuickBooksRequest, queryQuickBooks, extractAccessToken, } from "../helpers/quickbooks-api.js"; import { getRequestHeaders } from "../helpers/request-context.js"; import { ToolResponse } from "../types/tool-response.js"; import { formatError } from "../helpers/format-error.js"; import { buildQuickbooksSearchCriteria } from "../helpers/build-quickbooks-search-criteria.js"; import { convertCriteriaToSQL } from "../helpers/criteria-to-sql.js"; /** * Search vendors from QuickBooks Online. * * Accepts either: * • A plain criteria object (key/value pairs) – passed directly to findVendors * • An **array** of objects in the `{ field, value, operator? }` shape – this * allows use of operators such as `IN`, `LIKE`, `>`, `<`, `>=`, `<=` etc. * * Pagination / sorting options such as `limit`, `offset`, `asc`, `desc`, * `fetchAll`, `count` can be supplied via the top‑level criteria object or as * dedicated entries in the array form. */ export async function searchQuickbooksVendors( criteria: object | Array<Record<string, any>> = {} ): Promise<ToolResponse<any[]>> { try { // Get access token from request headers const headers = getRequestHeaders(); const accessToken = extractAccessToken(headers); if (!accessToken) { return { result: null, isError: true, error: "Missing Authorization header. Please provide: Authorization: Bearer <access_token>", }; } const normalizedCriteria = buildQuickbooksSearchCriteria(criteria); const sqlQuery = convertCriteriaToSQL("Vendor", normalizedCriteria); const response = await queryQuickBooks({ query: sqlQuery, accessToken, }); if (response.isError) { return { result: null, isError: true, error: response.error || "Search failed", }; } return { result: response.result?.QueryResponse?.Vendor || [], isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }

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/heyibad/quickbook-mcp-'

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