@zapier/google-contacts-connector 0.0.0 → 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.
- package/LICENSE +93 -0
- package/NOTICE +8 -0
- package/README.md +106 -2
- package/SKILL.md +135 -0
- package/cli.js +71 -0
- package/cli.ts +5 -0
- package/connections.ts +8 -0
- package/dist/cli.js +4 -0
- package/dist/index.js +1134 -0
- package/index.ts +64 -0
- package/package.json +59 -4
- package/preflight.sh +157 -0
- package/references/google-contacts-api-gotchas.md +181 -0
- package/scripts/.gitkeep +0 -0
- package/scripts/copyOtherContact.ts +57 -0
- package/scripts/createContact.ts +140 -0
- package/scripts/createContactGroup.ts +51 -0
- package/scripts/deleteContact.ts +52 -0
- package/scripts/deleteContactGroup.ts +61 -0
- package/scripts/deleteContactPhoto.ts +56 -0
- package/scripts/getContact.ts +57 -0
- package/scripts/getContactGroup.ts +71 -0
- package/scripts/listContactGroups.ts +81 -0
- package/scripts/listContacts.ts +110 -0
- package/scripts/listOtherContacts.ts +80 -0
- package/scripts/modifyContactGroupMembers.ts +82 -0
- package/scripts/searchContacts.ts +72 -0
- package/scripts/searchOtherContacts.ts +71 -0
- package/scripts/updateContact.ts +166 -0
- package/scripts/updateContactGroup.ts +67 -0
- package/scripts/updateContactPhoto.ts +64 -0
- package/tsup.config.ts +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor's trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
+
company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
+
also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
+
to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
+
software the licensor makes available under these terms, including any portion
|
|
77
|
+
of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that
|
|
84
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
+
otherwise. Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Independent, unofficial connector for Google Contacts.
|
|
2
|
+
|
|
3
|
+
Zapier licenses only the connector code in this package, under the Elastic
|
|
4
|
+
License 2.0. Zapier grants no rights in Google Contacts's API, services, data,
|
|
5
|
+
schemas, documentation, or other materials, which remain the property of
|
|
6
|
+
Google Contacts. Google Contacts and its logos are trademarks of their owner, used only to
|
|
7
|
+
identify the service this connector works with. Not affiliated with, endorsed
|
|
8
|
+
by, or sponsored by Google Contacts.
|
package/README.md
CHANGED
|
@@ -1,4 +1,108 @@
|
|
|
1
1
|
# @zapier/google-contacts-connector
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
_Independent, unofficial connector for Google Contacts. Not affiliated with, endorsed by, or sponsored by Google Contacts. "Google Contacts" is a trademark of its owner, used only to identify the service this connector works with._
|
|
4
|
+
|
|
5
|
+
Agent-callable tools for Google Contacts, wrapping the [Google People API](https://developers.google.com/people/api/rest). It lets an agent create, read, update, and delete a person's contacts; search contacts by name, email, or phone; set or remove contact photos; create and manage contact groups (labels) and their membership; and browse the auto-saved "other contacts" surface. Authentication is OAuth 2.0 — either a Zapier-managed connection (recommended) or a direct Google access token.
|
|
6
|
+
|
|
7
|
+
This connector is the same artifact across four shapes: MCP server, CLI bin, importable Node module, and an [Agent Skill](https://agentskills.io/) anchored by [`SKILL.md`](SKILL.md). Pick the shape that matches how your agent runs.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Run a tool with zero install — npx fetches the package on first use
|
|
13
|
+
GOOGLE_CONTACTS_ACCESS_TOKEN=xxx npx @zapier/google-contacts-connector run <toolName> '{ ... }' --connection env:GOOGLE_CONTACTS_ACCESS_TOKEN
|
|
14
|
+
|
|
15
|
+
# Install as a dependency to import the tools in your own code
|
|
16
|
+
npm install @zapier/google-contacts-connector
|
|
17
|
+
|
|
18
|
+
# Or install as an Agent Skill (https://agentskills.io)
|
|
19
|
+
npx skills zapier/connectors --skill google-contacts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Auth is one `[<resolver>:]<value>` connection string passed with `--connection`. The value is a _selector_, not the secret: `--connection zapier:<connection-id>` routes through Zapier-managed auth (recommended; no third-party secret enters the agent's environment — store the id in `GOOGLE_CONTACTS_ZAPIER_CONNECTION_ID` and pass `--connection "zapier:$GOOGLE_CONTACTS_ZAPIER_CONNECTION_ID"` if you like), and `--connection env:GOOGLE_CONTACTS_ACCESS_TOKEN` reads a direct token from `$GOOGLE_CONTACTS_ACCESS_TOKEN` (the token stays in `env`, never on argv). The `<resolver>:` prefix is optional — a bare value is claimed by the first matching resolver. See [`SKILL.md`](SKILL.md#auth) for tradeoffs and how to find a connection ID.
|
|
23
|
+
|
|
24
|
+
## Tools
|
|
25
|
+
|
|
26
|
+
| Tool | Description |
|
|
27
|
+
| --------------------------- | ------------------------------------------------------------------------------------------ |
|
|
28
|
+
| `createContact` | Create a contact from structured name, email, phone, address, and organization fields. |
|
|
29
|
+
| `getContact` | Retrieve a single contact by resource name, with full field detail. |
|
|
30
|
+
| `updateContact` | Update a contact; each array sent replaces that whole field, omitted fields are untouched. |
|
|
31
|
+
| `deleteContact` | Delete a contact from the account. |
|
|
32
|
+
| `listContacts` | List the account's contacts, paginated — the primary resourceName resolver. |
|
|
33
|
+
| `searchContacts` | Search contacts by name, nickname, email, phone, or organization (prefix match). |
|
|
34
|
+
| `updateContactPhoto` | Set or replace a contact's photo from a base64-encoded image. |
|
|
35
|
+
| `deleteContactPhoto` | Remove a contact's photo, reverting to the default avatar. |
|
|
36
|
+
| `listContactGroups` | List contact groups (labels), user and system — the contactGroupResourceName resolver. |
|
|
37
|
+
| `getContactGroup` | Get a single contact group, optionally with its member contact resource names. |
|
|
38
|
+
| `createContactGroup` | Create a new user contact group (label). |
|
|
39
|
+
| `updateContactGroup` | Rename a user contact group (system groups cannot be renamed). |
|
|
40
|
+
| `deleteContactGroup` | Delete a user contact group (label), optionally with its member contacts. |
|
|
41
|
+
| `modifyContactGroupMembers` | Add and/or remove contacts in a group without disturbing other memberships. |
|
|
42
|
+
| `listOtherContacts` | List auto-saved "other contacts" (people interacted with but never saved). |
|
|
43
|
+
| `searchOtherContacts` | Search "other contacts" by name, email, or phone (prefix match). |
|
|
44
|
+
| `copyOtherContact` | Promote an "other contact" into saved contacts, returning an editable contact. |
|
|
45
|
+
|
|
46
|
+
Run `npx @zapier/google-contacts-connector run <toolName> --help` to see any tool's exact input contract + the available resolvers.
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { searchContacts } from "@zapier/google-contacts-connector";
|
|
52
|
+
|
|
53
|
+
// Each named export is the consumer-facing (input, opts) => Promise<{ data, meta }>.
|
|
54
|
+
const { data } = await searchContacts(
|
|
55
|
+
{ query: "jane" },
|
|
56
|
+
{ connection: "env:GOOGLE_CONTACTS_ACCESS_TOKEN" },
|
|
57
|
+
);
|
|
58
|
+
// data.results[].person is the canonical People API Person resource.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## MCP Server
|
|
62
|
+
|
|
63
|
+
Add one stanza to any MCP-aware client (Claude Desktop, Cursor, Claude Code, …) to auto-discover the tools over stdio:
|
|
64
|
+
|
|
65
|
+
<!-- prettier-ignore -->
|
|
66
|
+
```jsonc
|
|
67
|
+
// e.g. claude_desktop_config.json or .cursor/mcp.json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"google-contacts": {
|
|
71
|
+
"command": "npx",
|
|
72
|
+
"args": ["@zapier/google-contacts-connector", "mcp", "--connection", "zapier:<connection-id>"],
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
No Zapier account? Use the `env:` resolver — point `--connection` at an env-var name and keep the token in `env`: `"args": ["@zapier/google-contacts-connector", "mcp", "--connection", "env:GOOGLE_CONTACTS_ACCESS_TOKEN"]` with `"env": { "GOOGLE_CONTACTS_ACCESS_TOKEN": "xxx" }`.
|
|
79
|
+
|
|
80
|
+
## When to use this
|
|
81
|
+
|
|
82
|
+
Use this connector to manage a person's own Google Contacts — saving and finding people, editing their details, organizing them into groups/labels, and turning auto-saved "other contacts" into real contacts. It's the right pick for contact-CRUD, contact search, and label management against a single Google account over the People API.
|
|
83
|
+
|
|
84
|
+
## When NOT to use this
|
|
85
|
+
|
|
86
|
+
- **Google Workspace directory lookups** (org-wide people search) — not covered; this connector manages the user's personal contacts, not the domain directory.
|
|
87
|
+
- **Bulk/batch contact imports or mass edits** — there are no batch tools; act on one contact at a time.
|
|
88
|
+
- **Contact merge/dedupe** — not supported by these tools.
|
|
89
|
+
|
|
90
|
+
## Links
|
|
91
|
+
|
|
92
|
+
- [`SKILL.md`](SKILL.md) — runtime guidance for agents
|
|
93
|
+
- [Google People API reference](https://developers.google.com/people/api/rest) — the upstream API this connector wraps
|
|
94
|
+
- [Source](https://github.com/zapier/connectors/tree/main/apps/google-contacts)
|
|
95
|
+
|
|
96
|
+
## Legal
|
|
97
|
+
|
|
98
|
+
**Scope of license.** Zapier licenses only the connector code in this package. Zapier grants no rights in Google Contacts's API, services, data, schemas, documentation, or other materials, which remain the property of Google Contacts. Your use of Google Contacts's API is governed by your own agreement with Google Contacts.
|
|
99
|
+
|
|
100
|
+
**Trademarks and affiliation.** Google Contacts and its logos are trademarks of their owner, used here only to identify the service this connector works with. This connector is not affiliated with, endorsed by, or sponsored by Google Contacts.
|
|
101
|
+
|
|
102
|
+
**Your responsibility.** This connector calls Google Contacts's API using credentials you supply. You are responsible for holding a valid Google Contacts account, for complying with Google Contacts's API terms, developer policies, and acceptable use rules, and for the data you send and receive through it.
|
|
103
|
+
|
|
104
|
+
**No warranty.** This connector is provided "as is," without warranty of any kind, and is not an official Google Contacts product. Zapier is not responsible for changes Google Contacts makes to its API or for any consequence of your use of Google Contacts's API. See the repository LICENSE for the full disclaimer.
|
|
105
|
+
|
|
106
|
+
**Forks.** You may fork and modify this connector under the Elastic License 2.0. You may state that your fork is "based on" Zapier's connector, but you may not use the "Zapier" name or logo as the name or branding of your fork, or in any way that suggests Zapier produces, endorses, or supports it.
|
|
107
|
+
|
|
108
|
+
Licensed under the Elastic License 2.0. See the repository LICENSE and NOTICE.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: google-contacts
|
|
3
|
+
description: Agent-callable Google Contacts tools — create, find, update, and delete contacts, manage contact groups (labels) and membership, and read auto-saved other contacts. Use when the user mentions Google Contacts or wants to look up, save, or organize people — including requests that don't name Google Contacts explicitly, e.g. add Jane to my contacts, find Bob's email.
|
|
4
|
+
license: Elastic-2.0
|
|
5
|
+
compatibility: Requires Node.js 22.18+ or Bun 1.x; run `npm install` in this directory first.
|
|
6
|
+
metadata:
|
|
7
|
+
title: Google Contacts
|
|
8
|
+
source: https://github.com/zapier/connectors/blob/main/apps/google-contacts/SKILL.md
|
|
9
|
+
zapier-app-key: GoogleContactsCLIAPI
|
|
10
|
+
api-docs: https://developers.google.com/people/api/rest
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Google Contacts
|
|
14
|
+
|
|
15
|
+
_Independent, unofficial connector for Google Contacts. Not affiliated with, endorsed by, or sponsored by Google Contacts. "Google Contacts" is a trademark of its owner, used only to identify the service this connector works with._
|
|
16
|
+
|
|
17
|
+
Agent-callable tools for Google Contacts, wrapping the [Google People API](https://developers.google.com/people/api/rest). Create, read, update, and delete a person's contacts; search contacts by name, email, or phone; set or remove contact photos; create and manage contact groups (labels) and their membership; and browse the auto-saved "other contacts" surface. Every tool uses a single OAuth connection; capability is gated by the granted scope.
|
|
18
|
+
|
|
19
|
+
## When to use this connector
|
|
20
|
+
|
|
21
|
+
- Saving, finding, updating, or deleting a person's Google Contacts ("add Jane to my contacts", "what's Bob's email", "remove this contact").
|
|
22
|
+
- Organizing contacts into groups/labels and adding or removing members.
|
|
23
|
+
- Setting or removing a contact's photo.
|
|
24
|
+
- Finding someone the user has interacted with (e.g. emailed) but never explicitly saved — the "other contacts" surface — and promoting them into saved contacts.
|
|
25
|
+
|
|
26
|
+
## Scripts
|
|
27
|
+
|
|
28
|
+
One file per tool in [`scripts/`](scripts/); each tool's `inputSchema` / `outputSchema` (Zod) in the script file is the source of truth for its contract. All tools use the single connection `google-contacts`.
|
|
29
|
+
|
|
30
|
+
| Script | Tool name | Connections | Description |
|
|
31
|
+
| ------------------------------------------------------------------------------ | --------------------------- | ----------------- | ------------------------------------------------------------------------------------------ |
|
|
32
|
+
| [`scripts/createContact.ts`](scripts/createContact.ts) | `createContact` | `google-contacts` | Create a contact from structured name, email, phone, address, and organization fields. |
|
|
33
|
+
| [`scripts/getContact.ts`](scripts/getContact.ts) | `getContact` | `google-contacts` | Retrieve a single contact by resource name, with full field detail. |
|
|
34
|
+
| [`scripts/updateContact.ts`](scripts/updateContact.ts) | `updateContact` | `google-contacts` | Update a contact; each array sent replaces that whole field, omitted fields are untouched. |
|
|
35
|
+
| [`scripts/deleteContact.ts`](scripts/deleteContact.ts) | `deleteContact` | `google-contacts` | Delete a contact from the account. |
|
|
36
|
+
| [`scripts/listContacts.ts`](scripts/listContacts.ts) | `listContacts` | `google-contacts` | List the account's contacts, paginated — the primary resourceName resolver. |
|
|
37
|
+
| [`scripts/searchContacts.ts`](scripts/searchContacts.ts) | `searchContacts` | `google-contacts` | Search contacts by name, nickname, email, phone, or organization (prefix match). |
|
|
38
|
+
| [`scripts/updateContactPhoto.ts`](scripts/updateContactPhoto.ts) | `updateContactPhoto` | `google-contacts` | Set or replace a contact's photo from a base64-encoded image. |
|
|
39
|
+
| [`scripts/deleteContactPhoto.ts`](scripts/deleteContactPhoto.ts) | `deleteContactPhoto` | `google-contacts` | Remove a contact's photo, reverting to the default avatar. |
|
|
40
|
+
| [`scripts/listContactGroups.ts`](scripts/listContactGroups.ts) | `listContactGroups` | `google-contacts` | List contact groups (labels), user and system — the contactGroupResourceName resolver. |
|
|
41
|
+
| [`scripts/getContactGroup.ts`](scripts/getContactGroup.ts) | `getContactGroup` | `google-contacts` | Get a single contact group, optionally with its member contact resource names. |
|
|
42
|
+
| [`scripts/createContactGroup.ts`](scripts/createContactGroup.ts) | `createContactGroup` | `google-contacts` | Create a new user contact group (label). |
|
|
43
|
+
| [`scripts/updateContactGroup.ts`](scripts/updateContactGroup.ts) | `updateContactGroup` | `google-contacts` | Rename a user contact group (system groups cannot be renamed). |
|
|
44
|
+
| [`scripts/deleteContactGroup.ts`](scripts/deleteContactGroup.ts) | `deleteContactGroup` | `google-contacts` | Delete a user contact group (label), optionally with its member contacts. |
|
|
45
|
+
| [`scripts/modifyContactGroupMembers.ts`](scripts/modifyContactGroupMembers.ts) | `modifyContactGroupMembers` | `google-contacts` | Add and/or remove contacts in a group without disturbing other memberships. |
|
|
46
|
+
| [`scripts/listOtherContacts.ts`](scripts/listOtherContacts.ts) | `listOtherContacts` | `google-contacts` | List auto-saved "other contacts" (people interacted with but never saved). |
|
|
47
|
+
| [`scripts/searchOtherContacts.ts`](scripts/searchOtherContacts.ts) | `searchOtherContacts` | `google-contacts` | Search "other contacts" by name, email, or phone (prefix match). |
|
|
48
|
+
| [`scripts/copyOtherContact.ts`](scripts/copyOtherContact.ts) | `copyOtherContact` | `google-contacts` | Promote an "other contact" into saved contacts, returning an editable contact. |
|
|
49
|
+
|
|
50
|
+
## Disambiguation & refusals
|
|
51
|
+
|
|
52
|
+
- **Resolve names before writing.** Before `updateContact` / `deleteContact` / `modifyContactGroupMembers` on a contact identified by name, call `searchContacts` (or `listContacts`) and count _exact_, case-insensitive name matches. One match → act on it; don't over-ask. Two or more that tie → **stop, list the candidates with a distinguishing field (email or phone), and ask which one** — never silently pick. The same rule applies to groups via `listContactGroups`.
|
|
53
|
+
- **Editing a list field replaces it.** `updateContact` replaces each array you send (e.g. `emailAddresses`) wholesale. To _add_ a value without dropping the others, `getContact` first, append, then send the full array. For group membership, prefer `modifyContactGroupMembers` (element-level) over `updateContact`.
|
|
54
|
+
- **Out of scope — decline, don't substitute.** This connector does **not** do bulk/batch contact create-update-delete, Google Workspace **directory** lookups, or contact **merge/dedupe**. If asked for one of these, say it isn't supported and stop — do not call another tool and report it as done.
|
|
55
|
+
- **No bulk operations — never loop to fake one.** There is no batch endpoint. If asked to change, add, or delete a field across **many or all** contacts at once (e.g. "set everyone's company to Acme"), **decline and explain it isn't supported** — do **not** loop `updateContact` / `deleteContact` / `modifyContactGroupMembers` over multiple contacts to simulate a bulk operation. Acting on a single, explicitly-identified contact is fine; fanning out across the address book is not.
|
|
56
|
+
|
|
57
|
+
## Output format
|
|
58
|
+
|
|
59
|
+
Every script returns a `{ data, meta }` envelope (same shape across the CLI's JSON output, the imported SDK return value, and the MCP tool's `structuredContent`):
|
|
60
|
+
|
|
61
|
+
- **`data`** — the script's result (the shape declared by its `outputSchema`).
|
|
62
|
+
- **`meta.outputDataValidation`** — what validating `data` did:
|
|
63
|
+
- `{ skipped: false, droppedPaths: null }` — validated, nothing removed.
|
|
64
|
+
- `{ skipped: false, droppedPaths: [...], instruction }` — validated, but those paths (fields the API returned that the `outputSchema` doesn't declare) were stripped from `data`. If you need them, re-run with output validation skipped.
|
|
65
|
+
- `{ skipped: true }` — validation was bypassed; `data` is the raw, unchecked API output.
|
|
66
|
+
|
|
67
|
+
**Reading dropped fields / `skipOutputDataValidation`.** To receive the raw, unvalidated result, set the single token `skipOutputDataValidation` — CLI: append `--skipOutputDataValidation`; MCP: pass `meta: { skipOutputDataValidation: true }` as a tool argument; SDK: pass `{ skipOutputDataValidation: true }` in the run options. Input validation is never skipped.
|
|
68
|
+
|
|
69
|
+
**Trimming the result / `filterOutputData`.** To shrink a large result down to the fields you need, pass a jq expression that post-processes `data` — CLI: append `--filterOutputData '<jq>'`; MCP: pass `meta: { filterOutputData: "<jq>" }` as a tool argument. The jq runs against `data` only, NOT the `{ data, meta }` envelope, so write it rooted at `data` (see this script's output schema). The transformed value replaces `data`, `meta` is preserved, and the result is NOT re-validated against the output schema. The imported SDK has no `filterOutputData` option — reshape the returned `data` in code instead.
|
|
70
|
+
|
|
71
|
+
## Auth
|
|
72
|
+
|
|
73
|
+
Google Contacts uses OAuth 2.0. The connector needs Google "contacts" access (read/write); the other-contacts tools additionally need "other contacts" read access. On a `403`, reconnect with contacts access granted. Two ways to supply the credential:
|
|
74
|
+
|
|
75
|
+
- **Zapier-managed (recommended):** `--connection zapier:<connection-id>` — Zapier holds the OAuth credential and refreshes it automatically. Set `GOOGLE_CONTACTS_ZAPIER_CONNECTION_ID` to select the connection.
|
|
76
|
+
- **Direct token:** `--connection env:GOOGLE_CONTACTS_ACCESS_TOKEN` — a Google OAuth access token sent as a bearer. Good for short-lived/testing use: Google access tokens expire ~1 hour after issue and this path does **not** refresh them, so the Zapier-managed connection is the durable choice.
|
|
77
|
+
|
|
78
|
+
Pass auth as one connection string with `--connection [<resolver>:]<value>` (CLI / MCP) or `{ connection: "[<resolver>:]<value>" }` (imported). The value is a selector, not the secret; the `<resolver>:` prefix is optional (a bare value goes to the first resolver that claims it).
|
|
79
|
+
|
|
80
|
+
## Using this skill
|
|
81
|
+
|
|
82
|
+
### 0. Pre-flight and auth
|
|
83
|
+
|
|
84
|
+
Run the bundled pre-flight check **once** at the start of a session to learn how to run the scripts in the current harness, then run scripts directly — reuse the result for the rest of the session. It detects a usable runtime (Node 22.18+ or Bun) and that dependencies are installed; it does **not** probe the network or auth (the scripts own that). Read `PREFLIGHT_STATUS` first — the single verdict token; `PREFLIGHT_RUNNER` names the runtime.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
./preflight.sh
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Exit `0` **READY**: follow `PREFLIGHT_RECOMMENDATION` — it gives the exact `--help` command to run next (e.g. `node /path/scripts/<name>.ts --help`). The `--help` output lists the connection flag(s) the script reads and every resolver each accepts — value shape and auto-claim behavior. Use the runner from `PREFLIGHT_RUNNER` against the local script path — never `npx` (a sandbox that blocked the dep install may also block registry fetches). If a script call later fails with a network error, egress is blocked — recommend the user set up Zapier's remote MCP at `https://mcp.zapier.com`.
|
|
91
|
+
|
|
92
|
+
Exit `1` **NEEDS_ACTION**: follow `PREFLIGHT_RECOMMENDATION` — it spells out the single self-verifying install step and the exact `--help` command to run afterward. Re-running the pre-flight to reconfirm is optional.
|
|
93
|
+
|
|
94
|
+
The three invocation paths below all assume the pre-flight reported `READY`. See **Auth** above for the two ways to supply the connection.
|
|
95
|
+
|
|
96
|
+
### 1. Execute scripts directly
|
|
97
|
+
|
|
98
|
+
When the agent has shell access to the installed directory, run a script file straight from `scripts/`. Each script is `chmod +x` with a Node-targeted shebang. **Run `--help` first** to read the input contract and confirm an auth resolver is ready:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Inspect the contract + resolvers first
|
|
102
|
+
./scripts/searchContacts.ts --help
|
|
103
|
+
|
|
104
|
+
# Then invoke (direct token — token stays in env)
|
|
105
|
+
GOOGLE_CONTACTS_ACCESS_TOKEN=ya29.xxx ./scripts/searchContacts.ts '{"query":"Ada"}' --connection env:GOOGLE_CONTACTS_ACCESS_TOKEN
|
|
106
|
+
|
|
107
|
+
# Or route through a Zapier connection
|
|
108
|
+
./scripts/getContact.ts '{"resourceName":"people/c123"}' --connection zapier:<connection-id>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Prerequisites: Node.js 22.18+ (or Bun 1.x) on `PATH`, plus `npm install` once in this directory. Pin the runtime explicitly with `node scripts/<name>.ts …` or `bun scripts/<name>.ts …` when needed — all forms run the same script body.
|
|
112
|
+
|
|
113
|
+
### 2. Use the package's CLI
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
GOOGLE_CONTACTS_ACCESS_TOKEN=ya29.xxx npx @zapier/google-contacts-connector run searchContacts '{"query":"Ada"}' --connection env:GOOGLE_CONTACTS_ACCESS_TOKEN
|
|
117
|
+
npx @zapier/google-contacts-connector --help # all scripts
|
|
118
|
+
npx @zapier/google-contacts-connector run searchContacts --help # per-script schema + resolvers
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Same scripts, different entry point. Use `bunx` when `PREFLIGHT_RUNNER` is `bun` (a `bun` verdict often means no usable npm). Some harnesses block `npx`/`bunx` — fall back to (1).
|
|
122
|
+
|
|
123
|
+
### 3. Use as a recipe
|
|
124
|
+
|
|
125
|
+
When no shipped script matches, read this `SKILL.md`, the [`references/`](references/) files, and the `scripts/` files as a recipe to generate custom code. Each script is one `export default defineTool({...})` from `@zapier/connectors-sdk` referencing the connection key `"google-contacts"`; imitate that shape (Zod input/output schemas, a `(input, ctx) => …` run body, and direct-mode auth as a Bearer token in the `Authorization` header). If you persist generated code, add a comment pointing back to this skill's source:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// Source: https://github.com/zapier/connectors/blob/main/apps/google-contacts/SKILL.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## API quirks worth knowing
|
|
132
|
+
|
|
133
|
+
| Reference file | When to load |
|
|
134
|
+
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
135
|
+
| [`references/google-contacts-api-gotchas.md`](references/google-contacts-api-gotchas.md) | Before any tool call — covers error codes, update replacement semantics, etag concurrency, search prefix matching + warmup, write propagation delay, resource name formats, contact group types, membership limits, other-contacts field restrictions, and pagination. |
|
package/cli.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Connector CLI entry point.
|
|
4
|
+
*
|
|
5
|
+
* When dist/cli.js is present (npm install route, or after a local build):
|
|
6
|
+
* → delegates to the compiled CLI, works on any Node version.
|
|
7
|
+
*
|
|
8
|
+
* When dist/ is absent (git-clone route, no build step):
|
|
9
|
+
* → handles the `build` subcommand directly (any Node version, no TS needed),
|
|
10
|
+
* then falls through to cli.ts for all other subcommands (requires Node 22.18+
|
|
11
|
+
* or Bun for TypeScript stripping outside node_modules).
|
|
12
|
+
*
|
|
13
|
+
* `build` subcommand: compiles the connector so that
|
|
14
|
+
* `import { search } from "@zapier/notion-connector"` works on any Node version
|
|
15
|
+
* even when the connector was installed from a git/file source. Invoked
|
|
16
|
+
* automatically by the `prepare` lifecycle hook on git-clone installs.
|
|
17
|
+
* Tries `npx tsup`, falls back to `bunx tsup`, exits 0 regardless so that
|
|
18
|
+
* `npm install` / `pnpm install` never fails in restricted environments.
|
|
19
|
+
*
|
|
20
|
+
* Managed by @zapier/connectors-dev — do not edit; synced byte-for-byte
|
|
21
|
+
* across every connector.
|
|
22
|
+
*/
|
|
23
|
+
import { spawnSync } from "node:child_process";
|
|
24
|
+
import { existsSync } from "node:fs";
|
|
25
|
+
import { dirname, join } from "node:path";
|
|
26
|
+
import { fileURLToPath } from "node:url";
|
|
27
|
+
|
|
28
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
29
|
+
|
|
30
|
+
if (process.argv[2] === "build") {
|
|
31
|
+
if (!existsSync(join(dir, "dist", "cli.js"))) {
|
|
32
|
+
// Try the locally-installed tsup binary first so module resolution for
|
|
33
|
+
// typescript (a required tsup peer) works from the connector's own
|
|
34
|
+
// node_modules. Fall back to npx/bunx for environments without a local
|
|
35
|
+
// install (e.g. fresh git-clone before npm install).
|
|
36
|
+
const localTsup = join(dir, "node_modules", ".bin", "tsup");
|
|
37
|
+
const candidates = existsSync(localTsup)
|
|
38
|
+
? [
|
|
39
|
+
[process.execPath, [localTsup]],
|
|
40
|
+
["npx", ["tsup"]],
|
|
41
|
+
["bunx", ["tsup"]],
|
|
42
|
+
]
|
|
43
|
+
: [
|
|
44
|
+
["npx", ["tsup"]],
|
|
45
|
+
["bunx", ["tsup"]],
|
|
46
|
+
];
|
|
47
|
+
for (const [cmd, args] of candidates) {
|
|
48
|
+
const { status } = spawnSync(cmd, args, {
|
|
49
|
+
stdio: "inherit",
|
|
50
|
+
shell: true,
|
|
51
|
+
cwd: dir,
|
|
52
|
+
});
|
|
53
|
+
if (status === 0) break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Spawn the target as a subprocess so it runs as the entry point.
|
|
60
|
+
// Dynamic import() would set import.meta.main = false, causing
|
|
61
|
+
// runDispatchCli to return early without executing anything.
|
|
62
|
+
const target = existsSync(join(dir, "dist", "cli.js"))
|
|
63
|
+
? join(dir, "dist", "cli.js")
|
|
64
|
+
: join(dir, "cli.ts");
|
|
65
|
+
|
|
66
|
+
const { status } = spawnSync(
|
|
67
|
+
process.execPath,
|
|
68
|
+
[target, ...process.argv.slice(2)],
|
|
69
|
+
{ stdio: "inherit" },
|
|
70
|
+
);
|
|
71
|
+
process.exit(status ?? 1);
|
package/cli.ts
ADDED
package/connections.ts
ADDED
package/dist/cli.js
ADDED