qbo_get_vendor
Retrieve the complete record of a specific vendor from QuickBooks Online by providing the vendor ID. Returns vendor data or null if not found.
Instructions
Fetch the full record for a single vendor.
Args: vendor_id: QBO Vendor.Id.
Returns:
JSON envelope. data is the vendor record, or null on 404.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vendor_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- qbo_mcp/server.py:152-168 (handler)The MCP tool handler function for qbo_get_vendor. Validates vendor_id, calls the client's get_vendor method, and returns JSON envelope.
@mcp.tool() def qbo_get_vendor(vendor_id: str) -> str: """Fetch the full record for a single vendor. Args: vendor_id: QBO Vendor.Id. Returns: JSON envelope. `data` is the vendor record, or null on 404. """ if not vendor_id or not str(vendor_id).strip(): return _err("vendor_id is required and must be non-empty") try: vendor = _get_client().get_vendor(str(vendor_id).strip()) return _ok(vendor) except (ValueError, QBOError, RuntimeError) as exc: return _err(str(exc)) - qbo_mcp/server.py:152-152 (registration)The @mcp.tool() decorator registers qbo_get_vendor as an MCP tool on the FastMCP instance.
@mcp.tool() - qbo_mcp/server.py:152-152 (schema)The function signature `(vendor_id: str) -> str` defines the input schema (one required string parameter) and output type.
@mcp.tool() - qbo_mcp/client.py:356-366 (helper)The QBOClient.get_vendor method that performs the actual QBO API request. Returns the vendor dict or None on 404.
def get_vendor(self, vendor_id: str) -> dict | None: """Fetch one vendor by Id, or None on 404.""" if not vendor_id or not str(vendor_id).strip(): raise ValueError("vendor_id must be non-empty") try: data = self._request("GET", f"vendor/{vendor_id}") except QBOError as exc: if exc.status_code == 404: return None raise return data.get("Vendor") - qbo_mcp/server.py:32-61 (helper)Helper functions used by the tool: _get_client() creates/lazy-loads the QBO client; _ok() and _err() format the JSON response envelope.
def _get_client() -> QBOClient: global _settings, _client if _client is None: _settings = Settings.from_env() _client = QBOClient( client_id=_settings.client_id, client_secret=_settings.client_secret, refresh_token=_settings.refresh_token, realm_id=_settings.realm_id, api_host=_settings.api_host, token_url=QBO_TOKEN_URL, minor_version=_settings.minor_version, timeout=_settings.http_timeout, max_retries=_settings.max_retries, ) return _client def _ok(data: Any) -> str: return json.dumps({"ok": True, "data": data}, default=_json_default, indent=2) def _err(message: str) -> str: return json.dumps({"ok": False, "error": message}, indent=2) def _json_default(value: Any) -> Any: if isinstance(value, (date, datetime)): return value.isoformat() raise TypeError(f"Object of type {type(value).__name__} is not JSON serializable")