@firedrill-tools/hubspot 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +263 -0
  3. package/firedrill/agent.target.json +17 -0
  4. package/firedrill/baseline.scenario.json +5 -0
  5. package/firedrill/conformance.suite.json +20 -0
  6. package/firedrill/hubspot-deactivated-user.drill.json +53 -0
  7. package/firedrill/hubspot-denied.drill.json +74 -0
  8. package/firedrill/hubspot-fresh-actor.drill.json +128 -0
  9. package/firedrill/hubspot-invalid-auth.drill.json +433 -0
  10. package/firedrill/hubspot-mcp-aliases.drill.json +265 -0
  11. package/firedrill/hubspot-no-scopes.drill.json +433 -0
  12. package/firedrill/hubspot-owned-visibility.drill.json +113 -0
  13. package/firedrill/hubspot-rate-limited.drill.json +446 -0
  14. package/firedrill/hubspot-rest-flow.drill.json +963 -0
  15. package/firedrill/hubspot-scopes.drill.json +166 -0
  16. package/firedrill/hubspot-size-bounds.drill.json +156 -0
  17. package/firedrill/hubspot-write-committed-lost.drill.json +166 -0
  18. package/firedrill/hubspot-write-unavailable.drill.json +292 -0
  19. package/firedrill/rate-limited.scenario.json +11 -0
  20. package/firedrill/tools/hubspot/behavior.mjs +1318 -0
  21. package/firedrill/tools/hubspot/hubspot.tool.json +5524 -0
  22. package/firedrill/tools/hubspot/lib/bytes.mjs +32 -0
  23. package/firedrill/tools/hubspot/lib/json-depth.mjs +17 -0
  24. package/firedrill/tools/hubspot/lib/object-types.mjs +47 -0
  25. package/firedrill/tools/hubspot/lib/properties.mjs +275 -0
  26. package/firedrill/tools/hubspot/lib/search-matchers.mjs +85 -0
  27. package/firedrill/tools/hubspot/lib/search.mjs +301 -0
  28. package/firedrill/tools/hubspot/lib/state.mjs +248 -0
  29. package/firedrill/tools/hubspot/lib/wire.mjs +125 -0
  30. package/firedrill/world.json +3128 -0
  31. package/firedrill/write-committed-lost.scenario.json +11 -0
  32. package/firedrill/write-unavailable.scenario.json +11 -0
  33. package/firedrill.json +5 -0
  34. package/package.json +64 -0
  35. package/starter.json +2540 -0
  36. package/test/conformance.mjs +1007 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Reload Tech Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ # @firedrill-tools/hubspot
2
+
3
+ A synthetic **HubSpot CRM portal** for [Firedrill](https://firedrill.run): one fictional account holding contacts,
4
+ companies, deals, notes and tasks, exposed through a bounded subset of the HubSpot CRM v3 Objects, Search, Owners,
5
+ Pipelines and Properties APIs, the CRM v4 Associations API, the Account Info API, and through the tool names of
6
+ HubSpot's published MCP server. Agents that talk to HubSpot through `@hubspot/api-client`-style REST calls or over
7
+ MCP can be exercised against it without a portal, a private-app token or network access.
8
+
9
+ Everything is computed from the world's state: record ids come from a counter row, timestamps from Firedrill's
10
+ virtual clock, visibility from the calling actor's owner row. Nothing here contacts HubSpot; no e-mail, sequence or
11
+ workflow is ever triggered.
12
+
13
+ Package id `hubspot`, version `0.1.0`, engine `>=0.1.0 <0.2.0`, license Apache-2.0. **Backend only** — there is no
14
+ browser app; browse state through the REST routes, the MCP aliases or the Firedrill inspector.
15
+
16
+ ## Install
17
+
18
+ ```sh
19
+ firedrill tool add @firedrill-tools/hubspot --install
20
+ firedrill serve --scenario baseline --no-open
21
+ ```
22
+
23
+ `firedrill serve` prints the HTTP and MCP endpoints and their tokens. A new world receives the starter data and
24
+ the grants below. Existing worlds do not change silently: add the grants and (optionally) the `starter.json` rows
25
+ to your own world or scenario.
26
+
27
+ ### Grants and identity
28
+
29
+ Every actor that should use the Tool needs the grants for the operations it may call (`packageId: "hubspot"`):
30
+
31
+ ```
32
+ account.get-details objects.list objects.get objects.create objects.update objects.archive
33
+ objects.batch-read objects.batch-create objects.batch-update objects.search
34
+ associations.list associations.create-default associations.create associations.batch-create
35
+ associations.archive associations.batch-read associations.list-labels
36
+ owners.list owners.get pipelines.list pipelines.get pipelines.list-stages properties.list properties.get
37
+ ```
38
+
39
+ and these actor **attributes**, which model a HubSpot private app acting for one portal user:
40
+
41
+ | attribute | meaning |
42
+ |---|---|
43
+ | `email` (optional) | Selects the caller: the non-archived `owners` row with that e-mail (case-insensitive) is the caller's user and owner. A claimed e-mail with no match (or a deactivated owner) fails every operation with `UNAUTHORIZED` (HTTP 401, category `INVALID_AUTHENTICATION`), like an invalid token. **Absent** (e.g. the actor `firedrill tool add` creates): the caller is the portal's default user, the first non-archived owner in row-id order — Maya Lindqvist (`41001`) in the starter data; a portal without any active owner answers `UNAUTHORIZED`. |
44
+ | `scopes` (optional, string array) | Granted private-app scopes. Absent = every scope the Tool knows. Present = each operation needs its scope (`crm.objects.<type>.read/write`, `crm.objects.owners.read`, `crm.schemas.<type>.read`, `oauth`); a missing one fails `MISSING_SCOPES` (HTTP 403 with `errors[0].context.requiredGranularScopes`). Notes and tasks are gated by the contacts scopes. |
45
+ | `recordAccess` (optional, `all` \| `owned`) | HubSpot's "owned records only" user permission. With `owned`, records owned by someone else are absent from lists, searches and association listings, and get/update/archive/associate on them fail `NOT_FOUND` exactly like a non-existent id. Unassigned records stay visible. |
46
+
47
+ ### Connections
48
+
49
+ Two connection recipes are declared: `hubspot-api-client` (`HUBSPOT_API_BASE_PATH` = the HTTP binding,
50
+ `HUBSPOT_ACCESS_TOKEN` = its token, sent as `Authorization: Bearer …`) and `hubspot-mcp` (`HUBSPOT_MCP_URL` /
51
+ `PRIVATE_APP_ACCESS_TOKEN` for the MCP binding). The values are isolated world tokens for test processes only; the
52
+ official `@hubspot/mcp-server` is a stdio process bound to `api.hubapi.com` and is not the client being run — its
53
+ tool names are exposed by this package's MCP binding directly.
54
+
55
+ ## Starting data
56
+
57
+ `starter.json` (and the conformance `firedrill/world.json`) contain 118 fictional rows, virtual time
58
+ 2026-09-14T09:00:00Z (`virtualTimeUs 1789376400000000`, copied into the world by `firedrill tool add`, so records created
59
+ in a fresh install are stamped 2026-09-14, after every seeded record): portal `24871365` (EU data hosting, `Europe/Stockholm`, `EUR`) of **Brightline Analytics**, a
60
+ small B2B data-tooling company (`@brightline.example.com`), with four owners (Maya Lindqvist and Tom Achebe in
61
+ Sales, Priya Raman in Customer Success, Jonas Weber deactivated), 14 contacts (one archived, one without e-mail,
62
+ one with a mixed-case e-mail, two still owned by the deactivated owner, three unassigned, non-ASCII names), 6
63
+ companies (one archived, a parent and a subsidiary sharing a domain, one without contacts or deals), 8 deals across
64
+ the `default` Sales Pipeline (HubSpot's seven default stages) and a custom `5f2a9c1e` Renewals pipeline (one closed
65
+ won, one closed lost, one without an amount), 4 notes and 4 tasks (one overdue, one completed), 24 links stored as 48
66
+ directed association rows (a primary company, a user-defined `Champion` label, a link to the archived company), the
67
+ HubSpot-defined association type ids for the ten type pairs in scope, and three custom properties
68
+ (`contacts/plan_tier`, `deals/arr`, hidden `companies/csm_health`). Object ids are below 1001; created records start
69
+ at 1001.
70
+
71
+ ## Operations
72
+
73
+ | operation | MCP alias | HTTP route |
74
+ |---|---|---|
75
+ | `account.get-details` | `hubspot-get-user-details` | `GET /account-info/v3/details` |
76
+ | `objects.list` | `hubspot-list-objects` | `GET /crm/v3/objects/{objectType}` |
77
+ | `objects.get` | — | `GET /crm/v3/objects/{objectType}/{objectId}` |
78
+ | `objects.create` | — | `POST /crm/v3/objects/{objectType}` |
79
+ | `objects.update` | — | `PATCH /crm/v3/objects/{objectType}/{objectId}` |
80
+ | `objects.archive` | — | `DELETE /crm/v3/objects/{objectType}/{objectId}` |
81
+ | `objects.batch-read` | `hubspot-batch-read-objects` | `POST /crm/v3/objects/{objectType}/batch/read` |
82
+ | `objects.batch-create` | `hubspot-batch-create-objects` | `POST /crm/v3/objects/{objectType}/batch/create` |
83
+ | `objects.batch-update` | `hubspot-batch-update-objects` | `POST /crm/v3/objects/{objectType}/batch/update` |
84
+ | `objects.search` | `hubspot-search-objects` | `POST /crm/v3/objects/{objectType}/search` |
85
+ | `associations.list` | `hubspot-list-associations` | `GET /crm/v4/objects/{objectType}/{objectId}/associations/{toObjectType}` |
86
+ | `associations.create-default` | — | `PUT /crm/v4/objects/{fromObjectType}/{fromObjectId}/associations/default/{toObjectType}/{toObjectId}` |
87
+ | `associations.create` | — | `PUT /crm/v4/objects/{fromObjectType}/{fromObjectId}/associations/{toObjectType}/{toObjectId}` |
88
+ | `associations.batch-create` | `hubspot-batch-create-associations` | `POST /crm/v4/associations/{fromObjectType}/{toObjectType}/batch/create` |
89
+ | `associations.archive` | — | `DELETE /crm/v4/objects/{fromObjectType}/{fromObjectId}/associations/{toObjectType}/{toObjectId}` |
90
+ | `associations.batch-read` | — | `POST /crm/v4/associations/{fromObjectType}/{toObjectType}/batch/read` |
91
+ | `associations.list-labels` | `hubspot-get-association-definitions` | `GET /crm/v4/associations/{fromObjectType}/{toObjectType}/labels` |
92
+ | `owners.list` | — | `GET /crm/v3/owners` |
93
+ | `owners.get` | — | `GET /crm/v3/owners/{ownerId}` |
94
+ | `pipelines.list` | — | `GET /crm/v3/pipelines/{objectType}` |
95
+ | `pipelines.get` | — | `GET /crm/v3/pipelines/{objectType}/{pipelineId}` |
96
+ | `pipelines.list-stages` | — | `GET /crm/v3/pipelines/{objectType}/{pipelineId}/stages` |
97
+ | `properties.list` | `hubspot-list-properties` | `GET /crm/v3/properties/{objectType}` |
98
+ | `properties.get` | `hubspot-get-property` | `GET /crm/v3/properties/{objectType}/{propertyName}` |
99
+
100
+ `{objectType}` accepts `contacts`, `companies`, `deals`, `notes`, `tasks`, their singular spellings and the numeric
101
+ ids `0-1`, `0-2`, `0-3`, `0-46`, `0-27`; anything else is `404 OBJECT_NOT_FOUND` ("Unable to infer object type").
102
+ Canonical names are also reachable as `POST /v1/operations/hubspot/<operation>` and as MCP tools `hubspot.<operation>`.
103
+
104
+ Behaviour highlights, all computed from state:
105
+
106
+ - Records are `{ id, properties, createdAt, updatedAt, archived, archivedAt?, associations? }`; property values are
107
+ strings or `null`. Reads return the requested properties (unknown names are dropped) or the type's default set,
108
+ always with `hs_object_id` and the create/modified timestamps. Writes validate every value against the property
109
+ definition (unknown → `Property "x" does not exist`, read-only, wrong number/date/boolean/enumeration, invalid or
110
+ deactivated `hubspot_owner_id`), reject empty property maps, and answer `400 VALIDATION_ERROR` with one
111
+ `errors[]` entry per bad property.
112
+ - Contact `email` is unique (case-insensitive): a duplicate fails `409 CONFLICT` with `Contact already exists.
113
+ Existing ID: …`. Company `domain` is not unique. Deals need `dealstage` (pipeline defaults to `default`) and the
114
+ stage must belong to the pipeline; `hs_deal_stage_probability`, `hs_is_closed` and `hs_is_closed_won` are derived
115
+ from the stage. Notes and tasks need `hs_timestamp`; task status/priority/type are enumerations.
116
+ - `datetime`/`date` values (and datetime search filter values) are parsed without the host clock or time zone: an
117
+ epoch-millisecond digit string, or ISO 8601 `YYYY-MM-DD[THH:MM[:SS[.fraction]]][Z|±HH:MM|±HHMM|±HH]`. A value
118
+ without a zone designator is **UTC** and a date-only value is midnight UTC, so the same input stores the same
119
+ instant on every machine; values are stored as `YYYY-MM-DDTHH:MM:SS.sssZ` and must fall within years 0000–9999
120
+ (`253402300800000` or `9999-12-31T23:00:00-05:00` is `INVALID_DATE`). Anything else (e.g. `September 20,
121
+ 2026`, `2026-02-30`, `24:00:00`) fails `400 VALIDATION_ERROR` (`INVALID_DATE`); an invalid date filter value fails
122
+ the search with `400`.
123
+ - On create a `null` value sets nothing (the property stays unset); PATCH merges and `null` clears. A required
124
+ datetime that is present but invalid reports only `INVALID_DATE`, not also `REQUIRED_FIELD_NOT_SET`. `objects.update` emits one `object.property-changed` event per property whose stored
125
+ value actually changed. Archiving is a soft delete: archived records vanish from lists, searches, lookups and
126
+ association listings unless `archived=true` is requested; they are never restored.
127
+ - Malformed query flags (`?limit=abc`, `?archived=maybe`) on list/get routes answer `400 VALIDATION_ERROR` in
128
+ HubSpot's envelope (`limit must be between 1 and 100`, `archived must be true or false`).
129
+ - JSON request bodies may nest at most 512 levels. A deeper body is refused with `400` before argument validation
130
+ (the codec measures depth iteratively); ordinary bodies a few levels deep are unaffected.
131
+ - Listing pages by ascending id with `limit`/`after` (`paging.next.after` + a relative `link`); search takes
132
+ `filterGroups` (OR of ANDs, ≤ 5 groups, ≤ 6 filters each, ≤ 18 total; operators `EQ NEQ LT LTE GT GTE BETWEEN IN
133
+ NOT_IN HAS_PROPERTY NOT_HAS_PROPERTY CONTAINS_TOKEN NOT_CONTAINS_TOKEN`, typed comparison for numbers and dates),
134
+ a free-text `query` (every token a prefix of a token in the type's searchable properties), one sort (object or
135
+ `"-createdate"` shorthand), `limit` ≤ 200 and a decimal offset `after` below 10 000; `total` is exact.
136
+ - Property values are limited to 65,536 characters (HubSpot's limit); a longer value fails `400 VALIDATION_ERROR` with
137
+ `INVALID_LENGTH` and nothing is written.
138
+ - List and search pages are filled by the UTF-8 size of the encoded body as well as by count: a page stops before it
139
+ would pass 900,000 bytes and `paging.next.after` points at the first record not returned, so every record appears
140
+ exactly once while paging. A single record, a get, a create/update response, a batch read/create/update or an
141
+ association batch read that would be larger answers `400 VALIDATION_ERROR` ("above this Tool's 900000-byte response
142
+ limit"), and a rejected write commits nothing.
143
+ - Batch reads/updates report unknown ids in `errors` (`numErrors`) and process the rest; batch creates are
144
+ all-or-nothing on validation errors or duplicate e-mails; batch bodies take 1–100 inputs.
145
+ - Associations are stored as two directed rows per link with HubSpot's real type ids (contact→company `279`/`280`,
146
+ primary `1`/`2`, contact→deal `4`/`3`, company→deal `342`/`341`, primary `6`/`5`, note and task pairs, plus the
147
+ user-defined `Champion` `57`/`58`). A HubSpot-defined `Primary` label is exclusive per record and type pair;
148
+ `create-default` is idempotent; inline `associations` on create resolve the target type from the type id;
149
+ archiving removes both directions and answers 204 even when nothing was linked.
150
+ - Owners list/get (`idProperty=userId`, `archived`), deal pipelines and stages (`metadata.probability`/`isClosed`
151
+ as strings), property definitions (HubSpot-defined constants merged with custom `properties` rows; the REST
152
+ route lists hidden ones, the MCP alias filters them unless `includeHidden`).
153
+
154
+ Every response carries `X-HubSpot-Correlation-Id` and constant `X-HubSpot-RateLimit-*` headers. Errors use HubSpot's
155
+ envelope `{ status: "error", message, correlationId, category, errors?, context?, links? }` with categories
156
+ `INVALID_AUTHENTICATION` (401), `MISSING_SCOPES` (403, also for a framework-denied actor), `OBJECT_NOT_FOUND` (404),
157
+ `VALIDATION_ERROR` (400, also for schema-invalid input), `CONFLICT` (409), `RATE_LIMITS` (429) and `INTERNAL_ERROR`
158
+ (503). Requests with a form or text body get the framework's 415; paths outside the table above get 404 (or 405
159
+ when only other methods exist on that path).
160
+
161
+ ## Events and faults
162
+
163
+ Events: `object.created` (one per record created, batch included), `object.property-changed` (one per changed
164
+ property on update, derived deal properties included) and `association.changed` (one per directed row added or
165
+ removed, with `associationTypeIds` and `removed`). Consumers can attach callbacks to them in their own world.
166
+
167
+ Faults (select them in a scenario with `faults: [{ packageId: "hubspot", faultId }]`):
168
+
169
+ | fault | timing | effect |
170
+ |---|---|---|
171
+ | `rate-limited` | before, every operation | `429 RATE_LIMITS` "You have reached your secondly limit." with `X-HubSpot-RateLimit-Secondly-Remaining: 0` and `Retry-After: 1`; nothing runs. |
172
+ | `write-unavailable` | before, every write | `503 INTERNAL_ERROR`; nothing is written, reads keep working. |
173
+ | `write-committed-lost` | after commit, `objects.create` / `objects.batch-create` | The record **is** created and `object.created` emitted, yet the caller sees 503. A naive retry of a contact create then hits `409 CONFLICT`; a retry of a company create silently duplicates — the behaviour an agent must handle. |
174
+
175
+ ## Conformance
176
+
177
+ `firedrill tool test hubspot` runs thirteen drills twice over the HTTP and MCP bindings (a scripted target,
178
+ `test/conformance.mjs`, Node built-ins only): the full REST flow (every route, error path and edge case, including
179
+ datetime coercion), the MCP aliases, owned-record visibility, read-only scopes, no scopes, a framework-denied actor,
180
+ an unknown e-mail, a deactivated owner, an actor without identity attributes, size bounds (65,536-character values,
181
+ pathological wildcard searches, byte-bounded list/search pages over large CJK records, oversized batches), and one
182
+ drill per fault. Together they observe every operation, every declared error of every
183
+ operation, all three events and all three faults, and the repeat pass proves determinism.
184
+
185
+ ## Protocol compatibility
186
+
187
+ The HTTP surface follows the HubSpot API reference field-by-field for the routes above (paths, query parameters,
188
+ JSON bodies, `paging`, batch envelopes, error envelope, rate-limit headers), so `@hubspot/api-client` with its
189
+ `basePath` pointed at the HTTP binding is the intended client — but **no official client has been run against this
190
+ Tool**: compatibility is by reference, not verified against a real client, and the manifest `compatibility` array is
191
+ empty. The eleven MCP aliases reproduce the tool names of `@hubspot/mcp-server` 0.4.0 and take the REST body field
192
+ names those tools forward; their exact argument schemas were not verified against the running server.
193
+
194
+ ## Limitations
195
+
196
+ - A bounded synthetic subset: 24 operations, 24 routes, five object types. No tickets, custom objects/schemas, calls,
197
+ e-mails, meetings, communications, the legacy engagements API, `batch/upsert`, `batch/archive`, merge, GDPR delete,
198
+ property history (`propertiesWithHistory` is rejected with 400), property/pipeline/association-label management,
199
+ lists, forms, files, workflows, webhooks, timeline events, OAuth token endpoints, API-usage endpoints or CSV
200
+ import/export. Ten of the official MCP server's 21 tools (engagements, workflows, schemas, links, feedback) are absent.
201
+ - Authentication is the world token plus the actor's `email`; scopes are enforced only when the actor declares
202
+ `scopes`, from the small scope list above (no highly-sensitive-data scopes, no team-based access; `recordAccess`
203
+ knows only `all` and `owned`, and unassigned records are visible to `owned` users).
204
+ - The HubSpot-defined property set is the small subset agents use, not HubSpot's several hundred; no calculated or
205
+ analytics properties, no `hs_all_owner_ids`; custom properties come from starter rows; `hasUniqueValue` only on
206
+ contact `email`; `hubspot_owner_assigneddate` is stamped on contacts only.
207
+ - Deals derive only probability and closed flags from the stage; no `hs_closed_amount`, forecast categories, line
208
+ items, quotes or currency conversion.
209
+ - Search is synchronous (a write is searchable immediately; HubSpot's index lags), offset-paged, one sort, no
210
+ relevance ranking or fuzzy matching; `CONTAINS_TOKEN` is whole-word with `*` wildcards, matched in time linear in
211
+ the value (KMP substring search, no regular expression). One search may spend at most 40,000,000 character units of
212
+ matching work (folding, tokenising and scanning property values); a search that would need more answers
213
+ `400 VALIDATION_ERROR` ("characters of matching work") instead of blocking the server. HubSpot has no such error. `query` and every filter `value`/`values` item/`highValue` are limited to 3,000 characters (HubSpot's
214
+ query limit, applied to filter values too); a longer one answers `400 VALIDATION_ERROR`.
215
+ - Batch routes always answer 200/201 with `numErrors`/`errors`; HubSpot answers 207 on partial failures.
216
+ - Responses are capped at 900,000 UTF-8 bytes because the framework refuses HTTP responses over 1 MiB. HubSpot itself
217
+ would return a 100-input batch of large records; here it answers `400 VALIDATION_ERROR` and the caller must send
218
+ fewer inputs or request fewer properties. List and search pages may hold fewer than `limit` records.
219
+ - Only the ten type pairs above have association definitions; `paging.next.link` is a relative path; archived
220
+ records keep their association rows (hidden from listings) and are never restored.
221
+ - Rate-limit headers are constant decorations; `Remaining` only drops under the `rate-limited` fault. Batch
222
+ `startedAt`/`completedAt` and all timestamps come from virtual time, which does not advance within a drill.
223
+ - `correlationId` is the Firedrill invocation correlation id, not a HubSpot-format UUID.
224
+ - Object, owner and association ids are bounded to 512 characters by the operation input schemas (the framework's
225
+ own state row-id bound). Within that bound an unknown id — including an `idProperty=email` lookup of an address
226
+ longer than 64 characters — answers HubSpot's 404; only a longer id (in a path or a batch input) answers
227
+ `400 VALIDATION_ERROR` with the generic message `Invalid input JSON: arguments do not match hubspot.<operation>`,
228
+ where HubSpot would answer 404. Pipeline ids and property names of any length answer HubSpot's 404. Error messages
229
+ shorten echoed caller values to 100 **code points** (`aaaa…`), so an astral character is never split and a quoted
230
+ value keeps its closing quote. The whole `message` is then bounded to the framework's cap of 1000 UTF-16 units,
231
+ again cut on a code point boundary and ending in `…` (an aggregated `Property values were not valid: […]` summary
232
+ over several long property names is the one message that can reach it); `errors[]` always lists every field in full.
233
+ - **Malformed percent-encoding**: `firedrill serve` decodes query strings and bodies leniently, so a broken escape
234
+ such as `%E0%A4%A` reaches the Tool as U+FFFD (while `%ZZ` stays literal and a bad path segment 404s). U+FFFD in a
235
+ search expression or free-text filter is treated as a mangled request, never as search text: `objects.search`
236
+ `query`, every filter `value`/`values` item/`highValue`, and the `owners.list` `email` filter answer
237
+ `400 VALIDATION_ERROR` ("contains an invalid character (U+FFFD)") instead of silently matching nothing. A correctly
238
+ encoded U+FFFD (`%EF%BF%BD`) is rejected the same way; legitimate non-ASCII searches (`café`, `Müller`, CJK)
239
+ work normally. A mangled *property name* answers the existing `Property "…" does not exist` error, and a mangled
240
+ read projection (`?properties=`) is dropped like any unknown property name, as HubSpot does. Free-text `query`
241
+ tokens are letters, digits and `@._+-`; a query made only of other characters (an emoji, punctuation) yields no
242
+ tokens and behaves exactly like an empty `query` — no text filter, so the `filterGroups` decide the result.
243
+ - `GET /crm/v3/properties/{objectType}` keeps hidden definitions by default over HTTP (`?includeHidden=false` drops
244
+ them); the canonical `properties.list` operation defaults to `includeHidden: false`. A non-boolean value answers
245
+ `400 VALIDATION_ERROR`. **Deviation:** real HubSpot's REST route has no hidden filter and ignores unknown query
246
+ parameters, so it would answer **200** for `?includeHidden=maybe`; this Tool validates the flag for consistency
247
+ with `limit` / `archived`. Unknown parameters other than `includeHidden` are still ignored (`?foo=bar` → 200).
248
+ - **Framework limitation (`__proto__`)**: the framework's JSON decoding removes a `__proto__` key before the handler
249
+ runs, so `{"properties":{"__proto__":"x","firstname":"P"}}` creates the contact from `firstname` alone instead of
250
+ reporting HubSpot's `PROPERTY_DOESNT_EXIST`, and a body with only `__proto__` reads as `properties must be a
251
+ non-empty object`. `constructor` and `prototype` do reach the handler and answer `PROPERTY_DOESNT_EXIST`. No caller
252
+ key ever reaches a plain object: property names are resolved through a `Map` of definitions, so the shared realm
253
+ cannot be poisoned.
254
+
255
+ ## Trademarks
256
+
257
+ HubSpot is a trademark of HubSpot, Inc. The name is used only to identify the service this package simulates in a
258
+ test environment; there is no affiliation with or endorsement by HubSpot.
259
+
260
+ ## Safety
261
+
262
+ Tools and conformance targets are trusted local executable code, not a sandbox. Review before running. Keep
263
+ credentials and generated worlds/reports out of the package and repository; the file list excludes `.firedrill/`.
@@ -0,0 +1,17 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "target": {
4
+ "id": "conformance-agent",
5
+ "kind": "command",
6
+ "bindings": [
7
+ "http",
8
+ "mcp"
9
+ ],
10
+ "executable": "node",
11
+ "arguments": [
12
+ "test/conformance.mjs"
13
+ ],
14
+ "workingDirectory": ".",
15
+ "timeoutMs": 90000
16
+ }
17
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "baseline",
4
+ "title": "Baseline: the fictional Brightline Analytics portal exactly as authored in world.json (no faults)"
5
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "conformance",
4
+ "title": "HubSpot Tool conformance",
5
+ "drills": [
6
+ "hubspot-rest-flow",
7
+ "hubspot-mcp-aliases",
8
+ "hubspot-owned-visibility",
9
+ "hubspot-scopes",
10
+ "hubspot-no-scopes",
11
+ "hubspot-denied",
12
+ "hubspot-invalid-auth",
13
+ "hubspot-deactivated-user",
14
+ "hubspot-rate-limited",
15
+ "hubspot-write-unavailable",
16
+ "hubspot-write-committed-lost",
17
+ "hubspot-fresh-actor",
18
+ "hubspot-size-bounds"
19
+ ]
20
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "hubspot-deactivated-user",
4
+ "title": "A deactivated (archived) owner fails 401 on every operation",
5
+ "targetId": "conformance-agent",
6
+ "scenarioId": "baseline",
7
+ "actorId": "former",
8
+ "task": {
9
+ "instruction": "Run the deactivated-user conformance flow against the synthetic HubSpot Tool and fail loudly on any unexpected status, header or body."
10
+ },
11
+ "assertions": [
12
+ {
13
+ "id": "account-get-details-error",
14
+ "kind": "operation.count",
15
+ "operation": {
16
+ "packageId": "hubspot",
17
+ "operationId": "account.get-details"
18
+ },
19
+ "outcomes": [
20
+ "tool_error"
21
+ ],
22
+ "comparison": {
23
+ "operator": "equals",
24
+ "value": 1
25
+ }
26
+ },
27
+ {
28
+ "id": "objects-list-error",
29
+ "kind": "operation.count",
30
+ "operation": {
31
+ "packageId": "hubspot",
32
+ "operationId": "objects.list"
33
+ },
34
+ "outcomes": [
35
+ "tool_error"
36
+ ],
37
+ "comparison": {
38
+ "operator": "equals",
39
+ "value": 1
40
+ }
41
+ },
42
+ {
43
+ "id": "contacts-count",
44
+ "kind": "state.count",
45
+ "packageId": "hubspot",
46
+ "namespace": "contacts",
47
+ "comparison": {
48
+ "operator": "equals",
49
+ "value": 14
50
+ }
51
+ }
52
+ ]
53
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "hubspot-denied",
4
+ "title": "An actor without grants is denied by the framework over HTTP and MCP (HubSpot-shaped 403)",
5
+ "targetId": "conformance-agent",
6
+ "scenarioId": "baseline",
7
+ "actorId": "auditor",
8
+ "task": {
9
+ "instruction": "Run the denied conformance flow against the synthetic HubSpot Tool and fail loudly on any unexpected status, header or body."
10
+ },
11
+ "assertions": [
12
+ {
13
+ "id": "account-get-details-denied",
14
+ "kind": "operation.denied",
15
+ "operation": {
16
+ "packageId": "hubspot",
17
+ "operationId": "account.get-details"
18
+ },
19
+ "outcomes": [
20
+ "denied"
21
+ ],
22
+ "attemptRequired": true
23
+ },
24
+ {
25
+ "id": "objects-list-denied",
26
+ "kind": "operation.denied",
27
+ "operation": {
28
+ "packageId": "hubspot",
29
+ "operationId": "objects.list"
30
+ },
31
+ "outcomes": [
32
+ "denied"
33
+ ],
34
+ "attemptRequired": true
35
+ },
36
+ {
37
+ "id": "objects-create-denied",
38
+ "kind": "operation.denied",
39
+ "operation": {
40
+ "packageId": "hubspot",
41
+ "operationId": "objects.create"
42
+ },
43
+ "outcomes": [
44
+ "denied"
45
+ ],
46
+ "attemptRequired": true
47
+ },
48
+ {
49
+ "id": "objects-create-ok",
50
+ "kind": "operation.count",
51
+ "operation": {
52
+ "packageId": "hubspot",
53
+ "operationId": "objects.create"
54
+ },
55
+ "outcomes": [
56
+ "ok"
57
+ ],
58
+ "comparison": {
59
+ "operator": "equals",
60
+ "value": 0
61
+ }
62
+ },
63
+ {
64
+ "id": "contacts-count",
65
+ "kind": "state.count",
66
+ "packageId": "hubspot",
67
+ "namespace": "contacts",
68
+ "comparison": {
69
+ "operator": "equals",
70
+ "value": 14
71
+ }
72
+ }
73
+ ]
74
+ }