Skip to Content
Spiti

Build an integration

Start with a standalone example, test your connector, and give a plugin access to its tools.

Start an integration with Spiti's template:

spiti plugin new weather --integration --name "Weather"

It creates the weather folder as its own git repository, with one tool that reads the version of Git on the Mac running your hub, its tests, a GitHub Actions workflow, and Spiti's SDK. It installs its libraries and makes the first commit. The options are in Build a plugin. Integration Demo is the same starter as a repository you can read.

Develop and test

Use Node.js 24 or later and the Bun version in package.json. Run these commands from the integration repo.

bun install --frozen-lockfile
bun run check
bun run build

The repo includes its own lockfile, TypeScript configuration, Vitest suite, and CI workflow. bun run check enforces 100% line, statement, function, and branch coverage of the integration source. Tests use the real SDK and replace only the provider ports. A versioned development copy of the SDK is included until the SDK is published. Release it with spiti plugin publish, as in Build a plugin.

Add your provider

  1. Change the ID, version, authentication method, and requested permissions in spiti.json. Keep the version in package.json in sync. Refresh the lockfile with bun install when you change package metadata or dependencies.
  2. Export createIntegration(sdk) from the entry named in spiti.json. Use sdk.tool with Zod input and output schemas and implement the tool with the port for your service. Keep the provider code and tests in the same repo.
  3. With a Spiti 0.6.0 hub, run spiti plugin check ., then spiti install .. Approve the permissions in Spiti.app and connect the account from its page under Integrations.
ProviderSDK port
HTTPS APIctx.request uses the connected account and reviewed host grant.
Local CLIctx.run runs the declared executable. Local CLI package installs need a local source or an official repo.
Hosted MCP serverctx.callMcp invokes the discovered tool the account is allowed to use.
External SQL databasectx.readSql lists tables or reads a bounded page of rows.

ctx.request takes GET, HEAD, POST, PUT, PATCH and DELETE with your own headers and a JSON, text or base64 body, and follows redirects that stay on the same origin. A path such as /issues goes after auth.url. It returns the parsed JSON body; set responseType to "text" or "base64" for other content, or response: "full" for the status and headers of any reply. A port call can use the tool's whole timeoutMs.

Choose how an HTTPS account signs in with auth in spiti.json:

  • credentials asks for a token and sends it as a bearer token. Set scheme to { "header": "X-Api-Key", "prefix": "Key " } for an API key in a header of your choice, or to "basic" for a user name and password. Add accountUrl: true when each account has its own site; list a wildcard host such as *.example.com so the sites fit your permissions.
  • oauth2 signs in with your own OAuth app. Register it with the provider as a public app that allows a loopback redirect (http://127.0.0.1), then name its clientId, tokenUrl, and authorizationUrl for sign-in in the browser or deviceAuthorizationUrl for sign-in with a code. Spiti uses PKCE, so never ship a client secret. Put the scopes each tool needs on the tool and describe each in auth.scopes; the owner chooses them when connecting, and Spiti refreshes the tokens.

A Local CLI package can pass up to 8 of your environment variables to its program with forwardEnvironment in auth, set fixed ones with environment (named with the command's prefix, such as GH_), and list home folders to look for the program in with directories. Spiti refuses the variables it sets for every program, such as PATH and HOME, and the ones that change how programs load, such as DYLD_* and NODE_*. The install review lists all three.

To implement a shared interface such as calendar@1, list it under contracts in spiti.json and give its tools the same names and schemas as the other integrations that implement it. Spiti keeps no schemas for a contract: plugins that use it check that the installed providers agree when they generate their client.

If your connector needs local state, add database to spiti.json and supply a schema and SQLite migrations. In the install review you can choose a dedicated file or a named connection. Use ctx.db for tables, ctx.kv for small values, and ctx.accountId for account-specific data. Choose an integration database

Call the demo

After installing the starter locally, connect Integration Demo and enable CLI and agent access. Copy its connection ID from spiti integrations list.

spiti integration-demo getGitVersion --account <connection-id>

To call it from a plugin, declare a requires.integrations slot for local:integration-demo with "tools": ["getGitVersion"] and bind the demo's account at install. Run spiti plugin check in the plugin directory to generate the typed client; it reads the installed package, so no account is needed for this step. Call withIntegrations(ctx).integrations.git.getGitVersion(accountId, {}) when the slot is named git. Build a plugin that uses an integration

On this page