@backendkit-labs/mcp-connectors 0.2.5 → 0.2.7

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.
package/REFERENCE.md ADDED
@@ -0,0 +1,648 @@
1
+ # @backendkit-labs/mcp-connectors — reference
2
+
3
+ The detailed reference of [@backendkit-labs/mcp-connectors](https://github.com/BackendKit-labs/backendkit-agent-framework/blob/master/packages/mcp-connectors/README.md): every topic beyond the quick start. Start with the README if you are new.
4
+
5
+ ## Contents
6
+
7
+ - [HubSpot CRM connector](#hubspot-crm-connector)
8
+ - [Jira connector](#jira-connector)
9
+ - [Google Calendar connector](#google-calendar-connector)
10
+ - [Using with agent-core MCPClientManager](#using-with-agent-core-mcpclientmanager)
11
+ - [HTTP mode (multi-session)](#http-mode-multi-session)
12
+ - [Wiring all three connectors](#wiring-all-three-connectors)
13
+
14
+ ---
15
+
16
+ ## HubSpot CRM connector
17
+
18
+ ### Authentication
19
+
20
+ Create a **Private App** in your HubSpot account (`Settings → Integrations → Private Apps`), grant it the required CRM scopes, and copy the access token:
21
+
22
+ | Environment variable | Required | Description |
23
+ |---------------------|----------|-------------|
24
+ | `HUBSPOT_TOKEN` | Yes | Private App access token |
25
+
26
+ ### Tools
27
+
28
+ #### `crm_search_contacts`
29
+
30
+ Search contacts by name, email, or company name.
31
+
32
+ ```
33
+ Tool: crm_search_contacts
34
+ Args:
35
+ query string Search term — name, email, or company
36
+ limit number? Max results (default 10)
37
+ ```
38
+
39
+ **Example:**
40
+ ```
41
+ search for alice@acme.com
42
+ → crm_search_contacts({ query: "alice@acme.com" })
43
+ → "ID:12345 Alice Johnson <alice@acme.com> Acme Corp +1-555-0100"
44
+ ```
45
+
46
+ **Complex example — search and enrich:**
47
+ ```
48
+ Find all contacts at Acme Corp and tell me their job titles and when they were created
49
+ → crm_search_contacts({ query: "Acme Corp", limit: 50 })
50
+ → For each contact: crm_get_contact({ id: "..." })
51
+ → LLM synthesizes a table of names, titles, and creation dates
52
+ ```
53
+
54
+ ---
55
+
56
+ #### `crm_get_contact`
57
+
58
+ Get full property details for a contact by HubSpot ID.
59
+
60
+ ```
61
+ Tool: crm_get_contact
62
+ Args:
63
+ id string HubSpot contact ID
64
+ ```
65
+
66
+ **Returns:** `firstname`, `lastname`, `email`, `phone`, `company`, `jobtitle`, `lifecyclestage`, `createdate`, `lastmodifieddate`
67
+
68
+ **Example:**
69
+ ```
70
+ Get the full details for contact 12345
71
+ → crm_get_contact({ id: "12345" })
72
+ → "Contact 12345
73
+ firstname: Alice
74
+ lastname: Johnson
75
+ email: alice@acme.com
76
+ jobtitle: VP Engineering
77
+ lifecyclestage: customer"
78
+ ```
79
+
80
+ ---
81
+
82
+ #### `crm_create_contact`
83
+
84
+ Create a new contact in HubSpot CRM.
85
+
86
+ ```
87
+ Tool: crm_create_contact
88
+ Args:
89
+ email string Email address (required)
90
+ firstname string?
91
+ lastname string?
92
+ phone string?
93
+ company string?
94
+ jobtitle string?
95
+ ```
96
+
97
+ **Example:**
98
+ ```
99
+ Add Bob Smith from Globex as a new CRM contact — bob@globex.com, +1-555-9999, Sr. Engineer
100
+ → crm_create_contact({
101
+ email: "bob@globex.com",
102
+ firstname: "Bob",
103
+ lastname: "Smith",
104
+ company: "Globex",
105
+ phone: "+1-555-9999",
106
+ jobtitle: "Sr. Engineer"
107
+ })
108
+ → "Created contact ID: 67890"
109
+ ```
110
+
111
+ ---
112
+
113
+ #### `crm_search_deals`
114
+
115
+ Search deals by name and/or deal stage.
116
+
117
+ ```
118
+ Tool: crm_search_deals
119
+ Args:
120
+ query string? Deal name search term
121
+ stage string? Deal stage key (e.g. appointmentscheduled, qualifiedtobuy, closedwon, closedlost)
122
+ limit number? Max results (default 10)
123
+ ```
124
+
125
+ **Example — find open deals:**
126
+ ```
127
+ Show me all deals in the "Qualified to Buy" stage worth over $50k
128
+ → crm_search_deals({ stage: "qualifiedtobuy", limit: 50 })
129
+ → LLM filters by amount from results
130
+ → "ID:111 Enterprise License stage:qualifiedtobuy $75,000 close:2026-09-01"
131
+ ```
132
+
133
+ **Example — search by name:**
134
+ ```
135
+ Find the Acme Corp deal
136
+ → crm_search_deals({ query: "Acme Corp" })
137
+ → "ID:222 Acme Corp Enterprise stage:presentationscheduled $120,000 close:2026-07-15"
138
+ ```
139
+
140
+ ---
141
+
142
+ #### `crm_create_note`
143
+
144
+ Log an activity note, optionally linked to a contact and/or deal.
145
+
146
+ ```
147
+ Tool: crm_create_note
148
+ Args:
149
+ body string Note content
150
+ contact_id string? HubSpot contact ID to associate
151
+ deal_id string? HubSpot deal ID to associate
152
+ ```
153
+
154
+ **Example:**
155
+ ```
156
+ Log a call note: "Spoke with Alice, agreed to send proposal by Friday"
157
+ Associate with contact 12345 and deal 222
158
+ → crm_create_note({
159
+ body: "Spoke with Alice, agreed to send proposal by Friday",
160
+ contact_id: "12345",
161
+ deal_id: "222"
162
+ })
163
+ → "Created note ID: 333"
164
+ ```
165
+
166
+ **Complex workflow example:**
167
+
168
+ ```
169
+ After our sales call with Acme Corp today:
170
+ 1. Find the Acme contact and deal
171
+ 2. Log a note about the meeting outcome
172
+ 3. Check if the deal close date needs updating
173
+
174
+ → crm_search_contacts({ query: "Alice Acme Corp" }) → contact 12345
175
+ → crm_search_deals({ query: "Acme Corp" }) → deal 222
176
+ → crm_create_note({ body: "...", contact_id: "12345", deal_id: "222" })
177
+ → LLM: "Note logged. The deal close date is 2026-07-15 — would you like to update it?"
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Jira connector
183
+
184
+ ### Authentication
185
+
186
+ Generate an **API token** at `https://id.atlassian.com/manage-profile/security/api-tokens`.
187
+
188
+ | Environment variable | Required | Description |
189
+ |---------------------|----------|-------------|
190
+ | `JIRA_HOST` | Yes | Your Jira domain (e.g. `mycompany.atlassian.net`) |
191
+ | `JIRA_EMAIL` | Yes | Your Atlassian account email |
192
+ | `JIRA_TOKEN` | Yes | Jira API token (not your password) |
193
+
194
+ ### Tools
195
+
196
+ #### `jira_search`
197
+
198
+ Search Jira issues using JQL (Jira Query Language).
199
+
200
+ ```
201
+ Tool: jira_search
202
+ Args:
203
+ jql string JQL query
204
+ limit number? Max results (default 20)
205
+ ```
206
+
207
+ **JQL examples:**
208
+ ```
209
+ # All open bugs in PROJ, assigned to me
210
+ jql: project = PROJ AND issuetype = Bug AND status != Done AND assignee = currentUser()
211
+
212
+ # Recently updated critical issues
213
+ jql: priority = Critical AND updated >= -7d ORDER BY updated DESC
214
+
215
+ # Issues in the current sprint
216
+ jql: project = PROJ AND sprint in openSprints()
217
+
218
+ # My unresolved tasks due this week
219
+ jql: assignee = currentUser() AND resolution = Unresolved AND due <= endOfWeek()
220
+ ```
221
+
222
+ **Example:**
223
+ ```
224
+ Show me all open bugs in the BACKEND project assigned to Alice
225
+ → jira_search({ jql: 'project = BACKEND AND issuetype = Bug AND status != Done AND assignee = "Alice Johnson"' })
226
+ → "BACK-45 [In Progress] High Auth token expiry bug @Alice Johnson
227
+ BACK-51 [To Do] Medium Rate limit not enforced @Alice Johnson"
228
+ ```
229
+
230
+ ---
231
+
232
+ #### `jira_get_issue`
233
+
234
+ Get full details for a Jira issue including description and recent comments.
235
+
236
+ ```
237
+ Tool: jira_get_issue
238
+ Args:
239
+ key string Issue key (e.g. PROJ-123)
240
+ ```
241
+
242
+ **Returns:** summary, status, assignee, description (converted from ADF to plain text), last 3 comments.
243
+
244
+ **Example:**
245
+ ```
246
+ What's the current status and description of BACK-45?
247
+ → jira_get_issue({ key: "BACK-45" })
248
+ → "BACK-45: Auth token expiry bug
249
+ Status: In Progress Assignee: Alice Johnson
250
+
251
+ Description:
252
+ When a token expires during an active session, the server returns 500
253
+ instead of 401. Reproduction steps: ...
254
+
255
+ Comments (last 2):
256
+ [Alice Johnson · 2026-06-10]: Traced to TokenValidator.validate()
257
+ [Bob Smith · 2026-06-11]: PR opened: https://..."
258
+ ```
259
+
260
+ ---
261
+
262
+ #### `jira_create_issue`
263
+
264
+ Create a new Jira issue.
265
+
266
+ ```
267
+ Tool: jira_create_issue
268
+ Args:
269
+ project string Project key (e.g. PROJ)
270
+ summary string Issue title
271
+ description string? Plain text description
272
+ issue_type string? Issue type (default: Task). E.g. Bug, Story, Epic
273
+ priority string? Priority (Highest, High, Medium, Low, Lowest)
274
+ ```
275
+
276
+ **Example:**
277
+ ```
278
+ Create a high-priority bug in BACK: "Login fails for SAML users with special characters in email"
279
+ → jira_create_issue({
280
+ project: "BACK",
281
+ summary: "Login fails for SAML users with special characters in email",
282
+ description: "Users with + in email address cannot log in via SAML SSO. Affects @company.com+alias emails.",
283
+ issue_type: "Bug",
284
+ priority: "High"
285
+ })
286
+ → "Created BACK-52 (ID: 100023)"
287
+ ```
288
+
289
+ ---
290
+
291
+ #### `jira_add_comment`
292
+
293
+ Add a comment to a Jira issue.
294
+
295
+ ```
296
+ Tool: jira_add_comment
297
+ Args:
298
+ key string Issue key
299
+ body string Comment text
300
+ ```
301
+
302
+ **Example:**
303
+ ```
304
+ Add a comment to BACK-45: "Fixed in PR #127, ready for review"
305
+ → jira_add_comment({ key: "BACK-45", body: "Fixed in PR #127, ready for review" })
306
+ → "Comment added to BACK-45."
307
+ ```
308
+
309
+ ---
310
+
311
+ #### `jira_transition`
312
+
313
+ Move an issue to a new status (e.g. move from "To Do" to "In Progress").
314
+
315
+ ```
316
+ Tool: jira_transition
317
+ Args:
318
+ key string Issue key
319
+ status string Target status name (e.g. Done, In Progress, To Do, In Review)
320
+ ```
321
+
322
+ The tool fetches available transitions first and matches by name (case-insensitive). If the target status isn't available, it reports valid options.
323
+
324
+ **Example:**
325
+ ```
326
+ Mark BACK-52 as "In Progress"
327
+ → jira_transition({ key: "BACK-52", status: "In Progress" })
328
+ → "BACK-52 → "In Progress""
329
+
330
+ Mark BACK-45 as done
331
+ → jira_transition({ key: "BACK-45", status: "Done" })
332
+ → "BACK-45 → "Done""
333
+ ```
334
+
335
+ **Complex workflow — sprint management:**
336
+
337
+ ```
338
+ Close out the sprint: mark all Done issues as closed, move remaining In Progress issues to next sprint
339
+
340
+ → jira_search({ jql: "sprint in openSprints() AND status = Done" })
341
+ For each: jira_transition({ key: "...", status: "Closed" })
342
+
343
+ → jira_search({ jql: "sprint in openSprints() AND status = 'In Progress'" })
344
+ LLM: "Found 3 in-progress issues: BACK-48, BACK-50, BACK-53. Move them to next sprint? (I need the sprint ID)"
345
+ ```
346
+
347
+ ---
348
+
349
+ ## Google Calendar connector
350
+
351
+ ### Authentication
352
+
353
+ Two auth modes are supported, checked in order:
354
+
355
+ #### Mode 1: Service Account (recommended for production)
356
+
357
+ Create a service account in Google Cloud Console, download the JSON key, and share the target calendar with the service account email. Supports automatic token refresh — no manual intervention needed.
358
+
359
+ ```bash
360
+ # Paste the full JSON content of the service account key file
361
+ GCAL_SERVICE_ACCOUNT_KEY='{"type":"service_account","client_email":"bk-agent@my-project.iam.gserviceaccount.com","private_key":"-----BEGIN RSA PRIVATE KEY-----\n...","token_uri":"https://oauth2.googleapis.com/token"}'
362
+ ```
363
+
364
+ The private key can also contain literal `\n` (as stored in environment variables) — the server handles unescaping automatically.
365
+
366
+ #### Mode 2: Access Token (quick testing)
367
+
368
+ ```bash
369
+ GCAL_ACCESS_TOKEN=ya29.a0AfH... # Google OAuth2 access token (expires in ~1h)
370
+ ```
371
+
372
+ | Environment variable | Required | Description |
373
+ |---------------------|----------|-------------|
374
+ | `GCAL_SERVICE_ACCOUNT_KEY` | Recommended | Full JSON content of a service account key |
375
+ | `GCAL_ACCESS_TOKEN` | Alternative | Short-lived OAuth2 token |
376
+
377
+ ### Tools
378
+
379
+ #### `calendar_list_calendars`
380
+
381
+ List all Google Calendars accessible to the authenticated account.
382
+
383
+ ```
384
+ Tool: calendar_list_calendars
385
+ Args: (none)
386
+ ```
387
+
388
+ **Example:**
389
+ ```
390
+ What calendars do I have access to?
391
+ → calendar_list_calendars()
392
+ → "primary@company.com "Alice Johnson" (primary) [owner]
393
+ team-eng@group.calendar.google.com "Engineering Team" [writer]
394
+ company-holidays@group.calendar.google.com "Company Holidays" [reader]"
395
+ ```
396
+
397
+ ---
398
+
399
+ #### `calendar_list_events`
400
+
401
+ List upcoming events within a time range.
402
+
403
+ ```
404
+ Tool: calendar_list_events
405
+ Args:
406
+ calendar_id string? Calendar ID (default: "primary")
407
+ time_min string? Start of range, ISO 8601 (default: now)
408
+ time_max string? End of range, ISO 8601 (default: 7 days from now)
409
+ limit number? Max events (default 10)
410
+ ```
411
+
412
+ **Example — this week:**
413
+ ```
414
+ What's on my calendar this week?
415
+ → calendar_list_events({ limit: 20 })
416
+ → "[2026-06-11 09:00 – 09:30] Daily Standup
417
+ [2026-06-11 14:00 – 15:00] Architecture Review (4 attendees)
418
+ [2026-06-12 10:00 – 11:00] 1:1 with Bob
419
+ [2026-06-13 All Day] Company Holiday"
420
+ ```
421
+
422
+ **Example — specific calendar and range:**
423
+ ```
424
+ Show me all Engineering Team events for next month
425
+ → calendar_list_events({
426
+ calendar_id: "team-eng@group.calendar.google.com",
427
+ time_min: "2026-07-01T00:00:00Z",
428
+ time_max: "2026-07-31T23:59:59Z",
429
+ limit: 50
430
+ })
431
+ ```
432
+
433
+ ---
434
+
435
+ #### `calendar_create_event`
436
+
437
+ Create a new event in Google Calendar.
438
+
439
+ ```
440
+ Tool: calendar_create_event
441
+ Args:
442
+ summary string Event title (required)
443
+ start string Start time ISO 8601 (required)
444
+ end string End time ISO 8601 (required)
445
+ description string? Event description
446
+ attendees string[]? List of attendee email addresses
447
+ timezone string? IANA timezone (default: UTC)
448
+ calendar_id string? Calendar ID (default: "primary")
449
+ ```
450
+
451
+ **Example — simple meeting:**
452
+ ```
453
+ Schedule a 1-hour team sync tomorrow at 2pm Pacific
454
+ → calendar_create_event({
455
+ summary: "Team Sync",
456
+ start: "2026-06-12T14:00:00",
457
+ end: "2026-06-12T15:00:00",
458
+ timezone: "America/Los_Angeles"
459
+ })
460
+ → "Event created: abc123def
461
+ https://calendar.google.com/calendar/event?eid=..."
462
+ ```
463
+
464
+ **Example — meeting with attendees:**
465
+ ```
466
+ Book a sprint planning meeting for next Monday 10am-12pm UTC
467
+ Invite: alice@co.com, bob@co.com, carol@co.com
468
+ Add agenda to description
469
+ → calendar_create_event({
470
+ summary: "Sprint Planning — Q3 Sprint 2",
471
+ start: "2026-06-15T10:00:00",
472
+ end: "2026-06-15T12:00:00",
473
+ timezone: "UTC",
474
+ description: "Agenda:\n1. Review previous sprint\n2. Story point estimation\n3. Sprint commitment",
475
+ attendees: ["alice@co.com", "bob@co.com", "carol@co.com"]
476
+ })
477
+ → "Event created: xyz789
478
+ https://calendar.google.com/..."
479
+ ```
480
+
481
+ ---
482
+
483
+ #### `calendar_get_freebusy`
484
+
485
+ Check free/busy availability for one or more users in a time range.
486
+
487
+ ```
488
+ Tool: calendar_get_freebusy
489
+ Args:
490
+ emails string[] List of email addresses to check (required)
491
+ time_min string Start of range, ISO 8601 (required)
492
+ time_max string End of range, ISO 8601 (required)
493
+ ```
494
+
495
+ **Example — find a meeting slot:**
496
+ ```
497
+ Find a 1-hour slot when alice@co.com, bob@co.com, and carol@co.com are all free next Tuesday
498
+ → calendar_get_freebusy({
499
+ emails: ["alice@co.com", "bob@co.com", "carol@co.com"],
500
+ time_min: "2026-06-16T08:00:00Z",
501
+ time_max: "2026-06-16T18:00:00Z"
502
+ })
503
+ → "alice@co.com:
504
+ BUSY 09:00 – 09:30
505
+ BUSY 11:00 – 12:00
506
+ bob@co.com: FREE all day
507
+ carol@co.com:
508
+ BUSY 10:00 – 11:30
509
+ BUSY 14:00 – 15:00"
510
+ → LLM: "Everyone is free from 12:00 to 14:00 and from 15:00 to 18:00. Should I book 12:00–13:00?"
511
+ ```
512
+
513
+ ---
514
+
515
+ ## Using with agent-core MCPClientManager
516
+
517
+ ### Standalone client
518
+
519
+ ```typescript
520
+ import { MCPClientManager } from '@backendkit-labs/agent-core';
521
+
522
+ const mcp = new MCPClientManager([
523
+ { name: 'hubspot', command: 'bk-mcp-hubspot', env: { HUBSPOT_TOKEN: process.env.HUBSPOT_TOKEN! } },
524
+ { name: 'jira', command: 'bk-mcp-jira', env: {
525
+ JIRA_HOST: process.env.JIRA_HOST!, JIRA_EMAIL: process.env.JIRA_EMAIL!, JIRA_TOKEN: process.env.JIRA_TOKEN!,
526
+ } },
527
+ { name: 'gcal', command: 'bk-mcp-gcal', env: { GCAL_SERVICE_ACCOUNT_KEY: process.env.GCAL_SERVICE_ACCOUNT_KEY! } },
528
+ ]);
529
+
530
+ await mcp.initialize(); // spawns each connector over stdio
531
+ const tools = mcp.getTools(); // mcp__hubspot__*, mcp__jira__*, mcp__gcal__*
532
+ ```
533
+
534
+ ### Via engine options (recommended approach)
535
+
536
+ Pass `mcpServers` to `createBaseEngine` or `createCodingEngine` — the engine manages lifecycle, retries, and disconnect detection:
537
+
538
+ ```typescript
539
+ import { createBaseEngine, selfAssertedIdentities } from '@backendkit-labs/agent-core';
540
+
541
+ const engine = createBaseEngine({
542
+ agentIdentity: selfAssertedIdentities(), // who the agent is (SPEC-0044)
543
+ identity: { userId: 'me' }, // on whose behalf it acts
544
+ ...baseConfig,
545
+ mcpServers: [
546
+ {
547
+ name: 'hubspot',
548
+ command: 'npx',
549
+ args: ['-y', '@backendkit-labs/mcp-connectors/hubspot'],
550
+ env: { HUBSPOT_TOKEN: process.env.HUBSPOT_TOKEN! },
551
+ },
552
+ {
553
+ name: 'jira',
554
+ command: 'npx',
555
+ args: ['-y', '@backendkit-labs/mcp-connectors/jira'],
556
+ env: {
557
+ JIRA_HOST: process.env.JIRA_HOST!,
558
+ JIRA_EMAIL: process.env.JIRA_EMAIL!,
559
+ JIRA_TOKEN: process.env.JIRA_TOKEN!,
560
+ },
561
+ },
562
+ {
563
+ name: 'gcal',
564
+ command: 'npx',
565
+ args: ['-y', '@backendkit-labs/mcp-connectors/gcal'],
566
+ env: { GCAL_SERVICE_ACCOUNT_KEY: process.env.GCAL_SERVICE_ACCOUNT_KEY! },
567
+ },
568
+ ],
569
+ });
570
+ ```
571
+
572
+ ---
573
+
574
+ ## HTTP mode (multi-session)
575
+
576
+ Start the servers in HTTP mode to share one connector process between several agent sessions on the same host:
577
+
578
+ ```bash
579
+ # Start connectors as HTTP servers
580
+ HUBSPOT_TOKEN=xxx bk-mcp-hubspot --http --port 4001
581
+ JIRA_HOST=co.atlassian.net JIRA_EMAIL=me@co.com JIRA_TOKEN=xxx bk-mcp-jira --http --port 4002
582
+ GCAL_SERVICE_ACCOUNT_KEY='...' bk-mcp-gcal --http --port 4003
583
+ ```
584
+
585
+ The HTTP server listens on `127.0.0.1` only and rejects requests whose `Host` or `Origin` is not loopback (protection against DNS rebinding). Set `BK_MCP_AUTH_TOKEN` to also require `Authorization: Bearer <token>`. Connect from the same host (or a sidecar that shares the network namespace) with a `url` config:
586
+
587
+ ```typescript
588
+ const mcp = new MCPClientManager([
589
+ { name: 'hubspot', url: 'http://127.0.0.1:4001/mcp', headers: { Authorization: `Bearer ${process.env.BK_MCP_AUTH_TOKEN}` } },
590
+ { name: 'jira', url: 'http://127.0.0.1:4002/mcp' },
591
+ { name: 'gcal', url: 'http://127.0.0.1:4003/mcp' },
592
+ ]);
593
+ await mcp.initialize();
594
+ ```
595
+
596
+ Because of the loopback-only binding, running each connector in its own container and calling it by service name (`http://mcp-hubspot:4001`) does not work. Run the connectors in the same container as the agent, as sidecars sharing `localhost`, or over stdio.
597
+
598
+ ---
599
+
600
+ ## Wiring all three connectors
601
+
602
+ Full example — an agent that can manage CRM contacts, Jira issues, and calendar events together:
603
+
604
+ ```typescript
605
+ import { createCodingEngine } from '@backendkit-labs/agent-coding';
606
+ import { selfAssertedIdentities } from '@backendkit-labs/agent-core';
607
+
608
+ const engine = createCodingEngine({
609
+ agentIdentity: selfAssertedIdentities(), // who the agent is (SPEC-0044)
610
+ identity: { userId: 'me' }, // on whose behalf it acts
611
+ providers: {
612
+ deepseek: { apiKey: process.env.DEEPSEEK_API_KEY! },
613
+ },
614
+ defaultProvider: 'deepseek',
615
+ mcpServers: [
616
+ {
617
+ name: 'hubspot',
618
+ command: 'bk-mcp-hubspot',
619
+ args: [],
620
+ env: { HUBSPOT_TOKEN: process.env.HUBSPOT_TOKEN! },
621
+ },
622
+ {
623
+ name: 'jira',
624
+ command: 'bk-mcp-jira',
625
+ args: [],
626
+ env: {
627
+ JIRA_HOST: process.env.JIRA_HOST!,
628
+ JIRA_EMAIL: process.env.JIRA_EMAIL!,
629
+ JIRA_TOKEN: process.env.JIRA_TOKEN!,
630
+ },
631
+ },
632
+ {
633
+ name: 'gcal',
634
+ command: 'bk-mcp-gcal',
635
+ args: [],
636
+ env: { GCAL_SERVICE_ACCOUNT_KEY: process.env.GCAL_SERVICE_ACCOUNT_KEY! },
637
+ },
638
+ ],
639
+ });
640
+
641
+ // Multi-tool agent workflow
642
+ await engine.run(`
643
+ I just closed the Acme Corp deal. Please:
644
+ 1. Find the Acme Corp deal in HubSpot and log a note: "Deal closed — contract signed"
645
+ 2. Create a Jira task in the ONBOARD project: "Onboard Acme Corp — enterprise tier"
646
+ 3. Schedule a kickoff meeting for next Wednesday at 2pm ET with alice@acme.com
647
+ `);
648
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/shared/http-client.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAID;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC7B,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,EACjB,IAAI,GAAE,gBAAqB,GAC5B,OAAO,CAAC,CAAC,CAAC,CAsDZ"}
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/shared/http-client.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAOD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC7B,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,EACjB,IAAI,GAAE,gBAAqB,GAC5B,OAAO,CAAC,CAAC,CAAC,CA0DZ"}
@@ -4,6 +4,8 @@ exports.fetchJson = fetchJson;
4
4
  const retry_1 = require("@backendkit-labs/retry");
5
5
  const DEFAULT_TIMEOUT_MS = 15_000;
6
6
  const DEFAULT_MAX_ATTEMPTS = 3;
7
+ /** What an error response may put in the message the model reads: the start of the body, not all of it. */
8
+ const MAX_ERROR_BODY_CHARS = 500;
7
9
  const IDEMPOTENT_METHODS = new Set(['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE']);
8
10
  /**
9
11
  * fetch() wrapper shared by connectors: hard timeout via AbortController, retry with
@@ -25,6 +27,7 @@ async function fetchJson(serviceName, url, init, opts = {}) {
25
27
  res = await fetch(url, { ...init, signal: controller.signal });
26
28
  }
27
29
  catch (err) {
30
+ clearTimeout(timer);
28
31
  // Duck-typed: the DOMException from an aborted fetch can come from another realm.
29
32
  const aborted = err?.name === 'AbortError';
30
33
  // eslint-disable-next-line @typescript-eslint/no-throw-literal
@@ -35,21 +38,24 @@ async function fetchJson(serviceName, url, init, opts = {}) {
35
38
  : `${serviceName} ${method} ${url.split('?')[0]} → network error: ${err.message}`,
36
39
  };
37
40
  }
41
+ // The timer keeps running while the body is read: a server that sends headers and then stalls must not hang the call.
42
+ try {
43
+ if (res.status === 204)
44
+ return undefined;
45
+ if (!res.ok) {
46
+ const text = (await res.text().catch(() => '')).slice(0, MAX_ERROR_BODY_CHARS);
47
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
48
+ throw {
49
+ type: 'http',
50
+ status: res.status,
51
+ message: `${serviceName} ${method} ${url.split('?')[0]} → ${res.status}: ${text}`,
52
+ };
53
+ }
54
+ return await res.json();
55
+ }
38
56
  finally {
39
57
  clearTimeout(timer);
40
58
  }
41
- if (res.status === 204)
42
- return undefined;
43
- if (!res.ok) {
44
- const text = await res.text().catch(() => '');
45
- // eslint-disable-next-line @typescript-eslint/no-throw-literal
46
- throw {
47
- type: 'http',
48
- status: res.status,
49
- message: `${serviceName} ${method} ${url.split('?')[0]} → ${res.status}: ${text}`,
50
- };
51
- }
52
- return res.json();
53
59
  };
54
60
  const result = await (0, retry_1.retry)(attempt, {
55
61
  maxAttempts: opts.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,