hs_get_form
Retrieve a complete HubSpot form definition by providing the form GUID. Returns all fields, required properties, and redirect settings for use in form analysis or integration.
Instructions
Get full form definition including fields, required properties, and redirect settings.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| formGuid | Yes | HubSpot form GUID |
Implementation Reference
- src/tools/forms.ts:16-18 (schema)Zod schema for hs_get_form input: requires formGuid (string) describing the HubSpot form GUID.
export const GetFormSchema = z.object({ formGuid: z.string().describe("HubSpot form GUID"), }); - src/tools/forms.ts:20-22 (handler)getForm handler function: takes formGuid and calls HubSpot GET /forms/v2/forms/{formGuid} to retrieve the full form definition.
export async function getForm(args: z.infer<typeof GetFormSchema>) { return hubspot(`/forms/v2/forms/${args.formGuid}`); } - src/index.ts:51-56 (registration)Imports GetFormSchema and getForm from ./tools/forms.js.
// Forms import { ListFormsSchema, listForms, GetFormSchema, getForm, FormSubmissionsSchema, formSubmissions, } from "./tools/forms.js"; - src/index.ts:248-253 (registration)Registers the 'hs_get_form' tool on the MCP server with description, schema, and handler binding.
server.tool( "hs_get_form", "Get full form definition including fields, required properties, and redirect settings.", GetFormSchema.shape, async (args) => { try { return ok(await getForm(args)); } catch (e) { return err(e); } }, ); - src/client.ts:16-48 (helper)hubspot() helper: generic HTTP client that constructs the API URL, adds auth token, and returns JSON response.
export async function hubspot<T = unknown>( path: string, method: "GET" | "POST" | "PATCH" | "DELETE" = "GET", body?: unknown, params?: Record<string, string | number | boolean>, ): Promise<T> { const token = getToken(); let url = `${BASE_URL}${path}`; if (params && method === "GET") { const qs = new URLSearchParams( Object.entries(params).map(([k, v]) => [k, String(v)]), ).toString(); if (qs) url += `?${qs}`; } const res = await fetch(url, { method, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, ...(body && method !== "GET" ? { body: JSON.stringify(body) } : {}), }); if (!res.ok) { const text = await res.text().catch(() => res.statusText); throw new HubSpotError(`HubSpot API error (${res.status}): ${text}`, res.status); } if (res.status === 204) return undefined as T; return (await res.json()) as T; }