Skip to main content
Glama

QuickBooks Online MCP Server

by heyibad
search-quickbooks-purchases.handler.ts1.61 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 purchases in QuickBooks Online that match given criteria */ export async function searchQuickbooksPurchases(params: 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(params); const sqlQuery = convertCriteriaToSQL("Purchase", 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?.Purchase || [], 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