# Use Stacktree from a Vercel app or agent

Source: https://stacktr.ee/vercel-connect

[Skip to content](#main) PFrom Product Hunt? Your first pages are free, no card. Code `PRODUCTHUNT` takes 50% off your first month of Studio.[Start free &rarr;](https://app.stacktr.ee/?join=1&from=producthunt)

&times;   A Stacktree customer sent you. Your first month is 50% off on any plan, taken off at checkout. [Start free &rarr;](https://app.stacktr.ee/?join=1&from=referral)

 &times;    [Stacktree](/)[Developers](/developers)[Agents](/agents)[Docs](/docs)[Use cases](/use-cases)[Pricing](/pricing)[Blog](/blog)[Dashboard](https://app.stacktr.ee)[Sign in →](https://app.stacktr.ee)      By [ Steve Smith ](/about) · Founder, Stacktree  ·  Last updated November 10, 2026          for Vercel Connect

#  Use Stacktree from a Vercel app or agent.

   Stacktree is a connector in the Vercel Connect catalog. Your code asks Vercel for a Stacktree token at the moment it needs one, then publishes HTML to a private link, updates it in place and reads client feedback, with no Stacktree key in your environment variables.

  [ Get started free ](https://app.stacktr.ee/?join=1&from=seo_vercel_connect)   install npx stacktree-install
Copy
      No card · 3 pages free · about a minute

##  How do you call Stacktree from a Vercel app?

Create the Stacktree connector with `vercel connect create stacktree`, then call `getToken` from `@vercel/connect` when your code runs. Each person who uses your app connects their own Stacktree account once. The token works on the MCP server at api.stacktr.ee/mcp and on the REST API at api.stacktr.ee.

## Create the connector

 From the project that will use it. Pick any name; the examples below use `acme-stacktree`, which makes the connector `stacktree/acme-stacktree`.

```
`vercel link
vercel connect create stacktree --name acme-stacktree
vercel env pull`
```

 Or in the dashboard: open [Stacktree in the Vercel Connect catalog](https://vercel.com/connect/stacktree) and press Create Connector. Vercel reads Stacktree's OAuth metadata, registers the client and keeps the tokens.

## Give a model the Stacktree tools

 An AI SDK agent that publishes as the person using your app. Each user connects their own Stacktree account once: they sign in to Stacktree, see what your app is asking to do, and press Allow.

```
`// agent.ts
import { getToken } from '@vercel/connect';
import { createMCPClient } from '@ai-sdk/mcp';
import { generateText, isStepCount } from 'ai';

const userId = 'user_123'; // from your own session, never from the request body
const token = await getToken('stacktree/acme-stacktree', {
  subject: { type: 'user', id: userId },
});

const client = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://api.stacktr.ee/mcp',
    headers: { Authorization: `Bearer ${token}` },
  },
});

try {
  const { text } = await generateText({
    model: 'openai/gpt-5.4',
    tools: await client.tools(), // publish_html, update_site, list_feedback, ...
    stopWhen: isStepCount(10),
    prompt: 'Write the weekly report as one HTML page and publish it to a private link.',
  });
} finally {
  await client.close();
}`
```

## In an eve agent

 Add one connection file. eve asks each user to authorize Stacktree in their browser the first time a tool needs it, and keeps a separate grant per person.

```
`// agent/connections/stacktree.ts
import { defineMcpClientConnection } from 'eve/connections';
import { connect } from '@vercel/connect/eve';

export default defineMcpClientConnection({
  url: 'https://api.stacktr.ee/mcp',
  description: 'Publish HTML to private Stacktree links, update them in place, and read client feedback.',
  auth: connect('stacktree/acme-stacktree'),
});`
```

## Without a model: one REST call

 The same token works as a Bearer token on the REST API, for a route or a cron job that already has the HTML.

```
`import { getToken } from '@vercel/connect';

export async function publishReport(userId: string, html: string) {
  const token = await getToken('stacktree/acme-stacktree', {
    subject: { type: 'user', id: userId },
  });

  const res = await fetch('https://api.stacktr.ee/sites', {
    method: 'POST',
    headers: { Authorization: `Bearer ${token}`, 'content-type': 'application/json' },
    body: JSON.stringify({ html }),
  });
  if (!res.ok) throw new Error(`Stacktree publish failed: ${res.status}`);
  const { url } = await res.json();
  return url; // a private, unguessable link
}`
```

## What a token can do

  - Everything the Stacktree account can do through the API: publish, update a page in place on the same link, set a passcode or an expiry, read and resolve viewer feedback, and delete pages. Stacktree lists two scopes, sites:write and sites:read, but neither narrows a token today, so treat any Stacktree token as full access to that account.
 - Access tokens last 30 days. Vercel Connect renews them with a refresh token, so a connection in regular use does not lapse.
 - To remove access, delete the connector or revoke its token in Vercel.

Keep reading

## Related guides

   -  [ The MCP publish tool What publish_html and the other tools do, for any MCP client. ](/mcp-publish-html)
-  [ Share with clients Passcodes, email gates, expiry and your own domain on the pages your agent publishes. ](/share-with-clients)
-  [ Client feedback loop The on-page comments an agent can read back and resolve. ](/client-feedback-loop)

##  Give your Vercel agent a publish step.

 Connect Stacktree once. Every page your agent makes gets a private link.

 [ Sign up free → ](https://app.stacktr.ee/?join=1&from=cta_vercel_connect)   install npx stacktree-install
Copy
       Private hosting for the HTML your agents make.

[](https://betalist.com/startups/stacktree?utm_campaign=badge-stacktree&utm_medium=badge&utm_source=badge-featured)[Featured on](https://devhunt.org/tool/stacktree)[](https://buildlist.io)[Get started free](https://app.stacktr.ee/?join=1)

## Product

- [Page video](/page-video)
- [Ask this page](/ask-this-page)
- [Client spaces](/client-spaces)
- [Templates](/templates)
- [Example deliverables](/examples)
- [Custom domains](/custom-domains)
- [Client feedback](/client-feedback-loop)
- [One-time links](/one-time-view-links)
- [See how pages get read](/page-engagement)
- [Made with Stacktree](/made-with)
- [Security](/security)
- [Watch the demo](/demo)

## Agents

- [All integrations](/agents)
- [Claude Code](/claude-code)
- [OpenAI Codex](/codex)
- [Cursor](/cursor)
- [Claude.ai connector](/claude-ai-connector)
- [Claude Cowork](/what-is-claude-cowork)
- [Meta Muse](/muse)
- [MCP server](/mcp-publish-html)
- [Deploy from Claude Code](/deploy-html-from-claude-code)
- [Skills](/skills)
- [Slack app](/slack)
- [n8n node](/n8n)
- [Agent payments (x402)](/x402)

## Alternatives

- [All comparisons](/alternatives)
- [Head-to-head comparisons](/compare)
- [Tiiny Host](/tiiny-host-alternative)
- [GitHub Pages (private)](/github-pages-private-alternative)
- [Vercel](/vercel-alternative-for-agents)
- [ngrok](/ngrok-alternative-for-html)
- [Display.dev](/display-dev-alternative)
- [Static.app](/static-app-alternative)
- [OpenAI Codex Sites](/openai-codex-sites-alternative)
- [here.now](/here-now-alternative)
- [Shippage](/shippage-ai-alternative)
- [Best private hosting](/best-private-html-hosting)

## Use cases

- [All use cases](/use-cases)
- [Share with clients](/share-with-clients)
- [Send a file to a client](/share-html-file-with-client)
- [Share Claude artifacts](/share-claude-artifacts)
- [Share Jupyter notebooks](/share-jupyter-notebook-html)
- [Host Storybook privately](/host-storybook-privately)
- [Architecture diagrams](/share-architecture-diagrams)
- [AI-generated reports](/host-ai-reports)
- [Internal HTML tools](/internal-tool-hosting)
- [Private HTML hosting](/private-html-hosting)
- [Vibe-coded page hosting](/vibe-coding-hosting)
- [Leave a website builder](/website-builder-migration)

## Learn

- [Blog](/blog)
- [Glossary](/glossary)
- [FAQ](/faq)
- [Where AI output should live](/where-ai-output-lives)
- [Agent-loop hosting](/agent-loop-hosting)
- [Why agents need a publish primitive](/blog/why-agents-need-a-publish-primitive)
- [MCP servers explained](/blog/mcp-servers-explained-for-developers)
- [What changed in the 2026-07 MCP spec](/blog/mcp-2026-spec-changes)
- [Sites in Codex explained](/blog/sites-in-codex-explained)
- [Private-by-default hosting](/blog/private-by-default-html-hosting)
- [An agent paid us $1 (x402)](/blog/agent-paid-to-provision-itself)
- [When a loop hits a paywall](/blog/loop-engineering-paywall)
- [Pricing](/pricing)
- [Self-host (new)](/self-host)
- [Changelog](/changelog)
- [Docs](https://stacktr.ee/docs)
- [About](/about)
© 2026 Stacktree · stacktr.ee

[Privacy](/privacy)[Terms](/terms)[Security](/security)[Dashboard](https://app.stacktr.ee)[npm](https://www.npmjs.com/package/stacktree-mcp)[Sitemap](/sitemap.xml)[llms.txt](/llms.txt)[API spec](/openapi.json)

---
Full markdown summary of the Stacktree marketing surface: https://stacktr.ee/llms-full.txt
