|
| 1 | +--- |
| 2 | +title: Vercel Connect |
| 3 | +description: Use @github-tools/sdk/connect to mint scoped GitHub tokens from a Vercel Connect connector — preset-derived scopes, zero boilerplate. |
| 4 | +navigation: |
| 5 | + title: Vercel Connect |
| 6 | +path: /guide/vercel-connect |
| 7 | +links: |
| 8 | + - label: Tokens & Auth |
| 9 | + icon: i-lucide-key-round |
| 10 | + to: /guide/tokens-and-auth |
| 11 | + color: neutral |
| 12 | + variant: subtle |
| 13 | + - label: Scope with presets |
| 14 | + icon: i-lucide-layers |
| 15 | + to: /guide/presets |
| 16 | + color: neutral |
| 17 | + variant: subtle |
| 18 | +--- |
| 19 | + |
| 20 | +For agents deployed on Vercel, [Vercel Connect](https://vercel.com/docs/connect) replaces long-lived PATs. Attach a **GitHub connector** to your project and mint **short-lived, scoped tokens** at runtime — no secret to store. |
| 21 | + |
| 22 | +The `@github-tools/sdk/connect` subpath wraps Connect with preset-derived scopes so you only think about the connector and preset. |
| 23 | + |
| 24 | +## Quick start (AI SDK) |
| 25 | + |
| 26 | +```ts [connect-tools.ts] |
| 27 | +import { connectGithubTools } from '@github-tools/sdk/connect' |
| 28 | +import { generateText } from 'ai' |
| 29 | + |
| 30 | +const tools = connectGithubTools('github/my-connector', { |
| 31 | + preset: 'code-review', |
| 32 | +}) |
| 33 | + |
| 34 | +const { text } = await generateText({ |
| 35 | + model: 'anthropic/claude-sonnet-4.6', |
| 36 | + tools, |
| 37 | + prompt: 'Summarize open PRs on my-org/my-repo.', |
| 38 | +}) |
| 39 | +``` |
| 40 | + |
| 41 | +Scopes are derived automatically from the preset — see the [preset → Connect scope matrix](/guide/tokens-and-auth#map-permissions-to-presets). |
| 42 | + |
| 43 | +## eve agent |
| 44 | + |
| 45 | +```ts [eve-agent.ts] |
| 46 | +// agent/agent.ts |
| 47 | +import { defineAgent } from 'eve' |
| 48 | + |
| 49 | +export default defineAgent({ |
| 50 | + model: 'anthropic/claude-sonnet-5', |
| 51 | + // TODO(eve-connect-bundle): remove when eve externalizes transitive @vercel/connect |
| 52 | + build: { |
| 53 | + externalDependencies: ['@vercel/connect'], |
| 54 | + }, |
| 55 | +}) |
| 56 | +``` |
| 57 | + |
| 58 | +```ts [eve-connect.ts] |
| 59 | +// agent/tools/github.ts |
| 60 | +import { connectGithubTools } from '@github-tools/sdk/connect/eve' |
| 61 | + |
| 62 | +export default connectGithubTools('github/my-connector', { |
| 63 | + preset: 'maintainer', |
| 64 | +}) |
| 65 | +``` |
| 66 | + |
| 67 | +::note |
| 68 | +**eve bundling** — `build.externalDependencies` keeps `@vercel/connect` out of the authored-module bundle. Without it, `eve dev` fails when the SDK is workspace-linked. This is temporary until eve handles transitive Connect imports upstream. |
| 69 | +:: |
| 70 | + |
| 71 | +See [`examples/eve-agent`](https://github.com/vercel-labs/github-tools/tree/main/examples/eve-agent) for a runnable example. |
| 72 | + |
| 73 | +## Token provider only |
| 74 | + |
| 75 | +When you need a lazy token for custom tool factories: |
| 76 | + |
| 77 | +```ts [connect-token.ts] |
| 78 | +import { connectGithubToken } from '@github-tools/sdk/connect' |
| 79 | +import { createGithubTools } from '@github-tools/sdk' |
| 80 | + |
| 81 | +const tools = createGithubTools({ |
| 82 | + preset: 'ci-ops', |
| 83 | + token: connectGithubToken('github/my-connector', { preset: 'ci-ops' }), |
| 84 | +}) |
| 85 | +``` |
| 86 | + |
| 87 | +Pass the same `preset` to both calls — `connectGithubToken` derives Connect scopes from its own `preset` option, independently of the one you give `createGithubTools`. Omitting it mints a token scoped to the union of every preset instead of just `ci-ops`. |
| 88 | + |
| 89 | +## Multi-tenant and repository scoping |
| 90 | + |
| 91 | +Override Connect parameters when you need installation targeting or narrower repository access: |
| 92 | + |
| 93 | +```ts [connect-override.ts] |
| 94 | +import { connectGithubTools } from '@github-tools/sdk/connect' |
| 95 | + |
| 96 | +const tools = connectGithubTools('github/my-connector', { |
| 97 | + preset: 'issue-triage', |
| 98 | + connect: { |
| 99 | + installationId: 'inst_abc', |
| 100 | + repositories: ['vercel-labs/github-tools'], |
| 101 | + scopes: ['issues:write'], // replaces preset-derived scopes when provided |
| 102 | + }, |
| 103 | +}) |
| 104 | +``` |
| 105 | + |
| 106 | +`subject` is always `{ type: 'app' }` — same as `connectGitHubAdapter` from `@vercel/connect`. |
| 107 | + |
| 108 | +## Setup checklist |
| 109 | + |
| 110 | +::steps{level="3"} |
| 111 | +### Create a GitHub connector |
| 112 | + |
| 113 | +Create a connector from the [Vercel dashboard](https://vercel.com/docs/connect) (or `vercel connect` in the CLI), then install it on the GitHub org or user account your agent needs. |
| 114 | + |
| 115 | +Or jump straight to the GitHub connector creation form with this [deeplink](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fconnect%2Fcreate%3Ftype%3Dgithub). |
| 116 | + |
| 117 | +### Link it to your project |
| 118 | + |
| 119 | +Link the connector to the Vercel project that runs your agent. On Vercel, the SDK authenticates automatically with the deployment OIDC token. For local development, run `vercel link` then `vercel env pull`. |
| 120 | + |
| 121 | +### Install the peer dependency |
| 122 | + |
| 123 | +```sh |
| 124 | +pnpm add @vercel/connect |
| 125 | +``` |
| 126 | + |
| 127 | +`@vercel/connect` is an optional peer dependency of `@github-tools/sdk` — install it only when using the `/connect` subpath. |
| 128 | +:: |
| 129 | + |
| 130 | +## Manual `getToken` (escape hatch) |
| 131 | + |
| 132 | +If you need full control over every `ConnectTokenParams` field, call `getToken` directly and pass the result as `token`. See [Tokens & Auth](/guide/tokens-and-auth#mint-tokens-with-vercel-connect). |
| 133 | + |
| 134 | +## API reference |
| 135 | + |
| 136 | +- [`connectGithubTools`](/api/reference#connectgithubtools) — AI SDK tool set |
| 137 | +- [`connectGithubTools` (eve)](/api/reference#connectgithubtools--eve) — eve `defineDynamic` sentinel |
| 138 | +- [`connectGithubToken`](/api/reference#connectgithubtoken) — lazy token provider |
| 139 | +- [`connectGithubScopesForPreset`](/api/reference#connectgithubscopesforpreset) — scope helper |
| 140 | + |
| 141 | +## External references |
| 142 | + |
| 143 | +- [Vercel Connect documentation](https://vercel.com/docs/connect) |
| 144 | +- [Vercel Connect SDK reference](https://vercel.com/docs/connect/ts-sdk-reference) |
0 commit comments