---
name: houston-connector
description: Create, rewrite or migrate a Houston connector bundle, from provider research through fixtures and Houston Hub publication. Use when asked to create, add, bring back or rewrite a provider's connector.
---

# Create a Houston connector

Process and lessons from the Houston team's connector work. Work in a checkout
of the public [houston-hub](https://github.com/aibakery/houston-hub) repository
or your own repository with the same layout; paths below are relative to its
root. The contract is `AUTHORING.md`: read it first and treat it as the
authority. Consult `docs/luau-practices.md` (Luau style) when a question comes
up. In the Houston repository, the hub is the `hub/` submodule: also follow
[houston-repository.md](houston-repository.md), and for a new native protocol
(beyond HTTP, SQL, Redis and IMAP) [native-protocol.md](native-protocol.md).

Write the connector from scratch on the current runtime. An older bundle of the
same provider is only a checklist for API coverage.

## 1. Pick the closest sibling

Read one or two bundles of the same shape in `connectors/` before designing:

| Shape | Siblings |
| --- | --- |
| REST + API token | `mercury`, `x`, `calcom` |
| REST + per-connection OAuth app | `calendly` (token or OAuth) |
| Publisher-owned OAuth client | `notion` (OAuth, token or admin), `dropbox`, `github`, `linkedin`, `slack`, `carta` and `gusto` (optional own app), `gmail`, `gcalendar`, `gdrive`, `gsheets`, `gforms`, `gdocs`, `gslides` |
| Self-hosted origin (`{{config.store_host}}`, `{{config.site_host}}`) | `woocommerce`, `wordpress` (shares the WordPress REST request layer) |
| Broad REST API coverage | `notion`, `gdrive`, `dropbox`, `calcom`, `woocommerce`, `wordpress` |
| Files through `fs` | `dropbox`, `gdrive`, `gmail` |
| Native protocol | `postgres`, `mysql`, `clickhouse`, `redis`, `imap` |
| Same protocol, different product | `supabase` (Postgres), `mariadb` (MySQL) |

Use siblings to understand provider and transport behavior. For code organization,
follow the sequential help/function layout below rather than copying an older
connector's registration machinery.

## 2. Research

- Have a background subagent save the official OpenAPI or spec, docs and brand
  kit to a scratch directory outside the repository, and produce an endpoint
  table: method, path, params, required body fields, read or write, scope, plan
  or role limits, doc link. Also cover auth options, ID formats, pagination,
  the error envelope, rate limits and every host (API, upload, download, signed
  storage). Check later work against these files. Unauthenticated probes (to
  see the error envelope) are fine; never call the API with real credentials.
- When docs render with JavaScript and fetching returns nothing, clone the
  provider's spec repo or SDK (Dropbox: `dropbox-api-spec`).
- Settle ambiguities from the official SDK source. LinkedIn documents
  space-separated scopes but replies with commas.
- Auth: prefer an API token when OAuth needs provider approval (Cal.com). With
  a self-serve OAuth app, the connection owns the client
  (`config.client_id`/`config.client_secret`). A publisher-owned client
  (`publisher.*`) is a product decision, so ask the user.
- Sharing: if the provider's terms forbid letting other people use one person's
  authorization, set `connections` to `personal-only` (AUTHORING.md).
- Terms: before writing code, have the research subagent quote the API terms on AI,
  agents, MCP servers and integration platforms. Some providers forbid AI or agent
  access to their API outright. Show the quoted clauses to the user and let them
  decide whether to continue.

## 3. Write the bundle

In `connectors/<provider>/`:

- `houston.json`: root fields in AUTHORING.md's order, with
  `"schema_version": 2`. Declare `access` rows (one `data` row with `read` and
  `write` for a single kind of access; one row per resource when the provider
  separates them), and gate write rules and scopes with
  `"if": "{{ allows access.data \"write\" }}"`.
- `connector.luau`:
  - A one-line header naming the API version, plus "Arguments and results keep
    <Provider>'s native field names".
  - Write operations sequentially, with each help record immediately before
    `function exports.name(...)`. Put a write operation and its help record
    inside the same `if houston.allows("data:write") then` block.
  - Validate input before any request, and return the provider's JSON
    unchanged.
  - Errors: `houston.fail({operation, layer = "upstream", upstream_status,
    retryable, message})`, with bounded error bodies and `Retry-After`.
  - Export structured `help` metadata, following the required contract below.
    Houston generates signatures/examples and returns complete references.
- `README.md`, `SETUP.md`: SETUP gives numbered steps with the provider
  console's current labels and direct links, the exact scopes to tick, and
  troubleshooting under `## Advanced`. Both files and all user-facing form
  labels/descriptions address people, not agents. Keep capabilities and setup
  simple; never include `help()`, operation calls, Lua, MCP instructions or
  runtime implementation details. Agents learn usage through MCP initialization,
  system instructions and Lua `help()`. Preserve technical guidance there.
- `icon.svg`: the provider's official mark with paths unchanged and no ®
  symbols.
- `tests/*.luau`, named by scenario (`read_only.luau`, `reads.luau`, `writes.luau`,
  `errors.luau`). Together they cover every auth method and enabled proxy rule;
  assert the exact export set (writes absent at the read level) and exact URLs,
  headers and bodies, with no `Authorization` header (the proxy injects it);
  show invalid input never reaches the network; and cover error mapping,
  `retryable` (as `calendly/tests/errors.luau` asserts it), and empty and
  populated arrays.
- Helpers may go under `lib/`. A request layer shared by several bundles is
  copied verbatim into each `connector.luau` (not `lib/`) between the markers
  `-- Request layer shared verbatim by the <Group> connectors` and
  `-- End of the shared request layer.`.
  Hub's generic shared-layer check discovers these markers and exercises each
  implementation against every consumer's fixtures. Use neutral group names such
  as `endpoint-table`. An endpoint-table bundle can call `m.endpointRules()`
  from a Luau contract fixture to compare its table with its manifest routes.

When adding an official bundle:

- Add `tests/manifest.luau` returning `{contract = function(m) ... end}` for
  manifest resolution, scope selection, credential injection and allowed/denied
  routes, including lookalike hosts and token endpoints. Use the helpers documented
  in AUTHORING.md and sibling bundle tests.
- Keep all provider-specific inputs and assertions in Luau. The public Go checker
  discovers bundles and fixtures automatically; adding one requires no Go changes.
- Keep publishing guidance generic in `AUTHORING.md` under "Publish a Connector
  on Houston Hub". Derive publisher settings and OAuth ownership from
  `houston.json`, rather than maintaining provider-specific publishing
  instructions. Record coverage, deliberate omissions, version pins, icon
  sources and deployment dependencies in the PR.

### Required help authoring

New/reworked connectors must export structured help, either a static plain table
or a pure zero-argument producer returning that table. Use one record per exact
configured operation, registered under the same access conditions as its function.
Make the file easy to review from top to bottom: shared constants and helpers,
then each function's complete help record immediately followed by its implementation.
Assign the function directly to `exports`; keep its description and examples in
the adjacent record. Avoid separate implementation, description or example maps,
registration helpers, and loops that assemble the final exports/help tables.
Prefer a few more explicit lines when they make the behavior and access conditions
easier to follow. Reuse genuinely shared transport logic and schema definitions,
without hiding operation registration behind abstractions. Never maintain a second
signature list or custom help router. The PostgreSQL connector in
`connectors/postgres/connector.luau` demonstrates this layout for Read and Write
operations. Existing Hub connectors migrate in small PRs; publication
continues to accept legacy/text-only help.

```luau
local help = {text = "Notes use plain-text bodies.", functions = {}, sections = {formatting = "Use actual newlines."}}
local exports = {help = help}
help.functions.getNote = {
    description = "Read one note. Returns the note object; inaccessible IDs fail.",
    args = {"id"},
    inputSchema = {
        type = "object", properties = {id = {type = "string", minLength = 1}},
        required = {"id"}, additionalProperties = false, examples = {{id = "note-example"}},
    },
    annotations = {readOnlyHint = true},
}
function exports.getNote(id: string)
    assert(id ~= "", "id must not be empty")
    local response = await(http.request({
        method = "GET", url = "https://api.example.com/notes/" .. url.segment(id),
    }))
    if response.statusCode ~= 200 then
        response.body:close()
        houston.fail({operation = "getNote", layer = "upstream",
            upstream_status = response.statusCode,
            retryable = response.statusCode == 429 or response.statusCode >= 500,
            message = "Could not read the note"})
    end
    return json.decode(await(response.body:readAll()))
end
return exports
```

Function records use MCP names: required `description` and `inputSchema`, optional
`outputSchema`, `annotations` and `title`. The function-map key is its name.
Use Draft 2020-12 JSON Schema, including required/optional and nested fields,
defaults, constraints, enums, discriminators/oneOf, conditionals and local `$ref`
with `$defs`. Other dialects and external references fail validation; valid schema
extensions remain allowed. Define real accepted payloads and at least one complete
valid object in `inputSchema.examples`; no placeholder schemas or parallel example
format. Defaults describe behavior without changing inputs. Stable single-object
results may supply `outputSchema`; preserve scalar/array/multiple-return APIs and
describe their results in prose. MCP hints never grant permission.

Omit `args` for an options object. Existing positional APIs use `args={"id"}` or
`{"id","options"}`; every top-level property is bound once, with optionality from
`required`. Use `args={}` for zero arguments and a final array rest binding such
as `{"command","...values"}` for variadic APIs. Preserve nulls, omitted positions,
empty arrays/objects and Luau keyword keys. Use `json.decode('[]')`/`json.decode('{}')`
when needed; only known list fields normalize empty tables.

Runtime compatibility includes all four forms: `help="text"`, `help={text="text"}`,
`help=function() return "text" end`, and `help=function() return {text="text"} end`.
Producers may return complete structured metadata. Houston invokes them with zero
arguments during each offline discovery evaluation; static and dynamic results
receive identical validation. Use immutable effective public config and pure
helpers, never I/O, credentials, customer data, time, randomness or mutable state.
Malformed metadata, producer errors, unknown record keys, missing/orphaned docs,
invalid schemas/examples and function/topic collisions fail with precise paths.
Test every applicable configuration/auth/access scenario. Omitted `functions`
retains legacy text and named-function fallback; an explicit empty map does not
excuse missing records. Incremental migration does not require rewriting stored
releases, republishing or reconnecting accounts.

### Namespace tables

Group a large connector into ordinary nested export tables. Each table owns its
local functions and help records; no registration API is needed. Document the
function next to its implementation:

```lua
local websites = {help = {text = "Manage tracked websites.", functions = {}}}

websites.help.functions.list = {
    description = "List websites.",
    inputSchema = {
        type = "object",
        properties = {page = {type = "integer", minimum = 1}},
        examples = {{page = 1}},
    },
}
function websites.list(options)
    return listWebsites(options)
end

return {
    websites = websites,
    help = {
        text = "Website analytics.",
        functions = {},
        namespaces = {websites = "Manage tracked websites."},
    },
}
```

`listWebsites` above is the connector's private request helper. Scripts call
`connection.websites.list({page=1})`. They discover immediate function names through
`connection.websites.functions` and child namespaces through
`connection.websites.namespaces`. `connection.help()` lists root functions and
namespaces; `connection.websites.help()` lists only that namespace's contents;
`connection.websites.help({section="list"})` supplies the complete function reference.
Namespaces may contain further namespaces with the same contract, up to eight
levels. Every namespace and its parent supplies help metadata.

`help.namespaces` is an optional map of child namespace names to short summaries.
When omitted, summaries come from child help text. Keep schemas and examples in
the owning namespace's `help.functions`, using local names. Omit disabled
operations and their records together, and omit namespaces with no enabled
operations. Export tables must be plain and acyclic. Names cannot contain dots;
qualified operation paths are constructed by Houston. Within a namespace,
`help`, `functions`, and `namespaces` are reserved for documentation and discovery.
Root connection metadata names remain reserved at the root.

Fixture calls use the same nested tables. `fixture.example("websites.list")`
generates a call from that leaf's schema and checks its output schema. Namespace
help producers obey the same offline initialization rules as root help.

The connector reference path is `connections.get(id).help(...)`, with the same
method available on each namespace. No
argument, nil, an empty table or empty section returns the complete overview and
configured local function/namespace/topic index. Only `{section="exactName"}` selects a
complete function or topic case-sensitively. Topics start with a letter and use
letters, digits, underscores or hyphens. `section` is the only option: no aliases
or pagination. Unsupported keys, wrong types, extra arguments, positional strings,
and unknown sections fail with bounded invalid_argument diagnostics, even alongside
a valid or empty section. Invalid calls never append documentation. Legacy function
lookup without dedicated detail fails truthfully and points to the explicit owning
.help() overview, where the complete legacy reference remains available. Root help
alone accepts intent; it never grants authorization or changes exact section lookup.
Help never calls provider operations. Runtime changes may break saved scripts;
repair callers using current help and the error's replacement guidance.

Houston automatically adds `help_hint` for operation errors while preserving their
structured details and failure status. Do not append hints in every connector.
Follow the hint through the same configured connection; access/configuration
recovery still takes priority. Test generated calls with `fixture.example(name,
index?)` against deterministic provider mocks; output schemas are checked against
fixture results. Never validate documentation with production writes.

Help has no special length cap. Oversized execution results include an immediate
signed `file.download_url` and expiry; the downloaded JSON contains complete
`returns[0]` for one help string. Signing/storage failures carry explicit output
diagnostics. Set the MCP `run` argument `max_bytes` to choose an output budget:
16 KiB by default, from 1 KiB to 256 KiB. This is an invocation option, never a
help option or part of reusable source. Truncated output includes a UTF-8 `chunk`
and `cursor`; call the read-only MCP `read_output` tool with that cursor and an
optional `max_bytes` to continue without replaying the script. Module-level
`truncate` is deprecated compatibility: `true` maps to 16 KiB, `false` to 256 KiB,
and an explicit `max_bytes` wins. Each explicit legacy use emits a structured
deprecation warning. Retrieve already-saved results of mixed scripts/writes
instead of replaying them. Keep
saved-script module help separate. Read AUTHORING.md's complete contract.

## 4. Validate

Connector implementations and tests are Luau. Shared Go validation tooling lives
in the public Hub's `manifest/`, `assets/` and `tools/` directories. The source
policy rejects Go in connector bundles. Do not add provider-specific Go tests.

Hub publication runs the full validation: manifest, private imports, configured
exports and help, Luau type checking and every fixture. Publish the branch
(step 6): until it validates, only your workspace sees the publication and its
errors. Fix, push and select **Refresh now** until it validates. With a Houston runtime (`HOUSTON_RUNTIME`)
and the pinned `luau-analyze` on `PATH`, run the same checks from a Houston
checkout with this Hub revision in `hub/`:

```sh
go -C tools/runtime run . test-connectors connectors/<provider>
go -C hub vet ./...
go -C hub test -count=1 ./...
```

Prove the fixtures can fail: break one check in the connector, confirm the
validator fails, then restore it.

## 5. Review while building

Run independent read-only subagent reviews: one per connector against the
saved spec, one on security, design and tests. Send fixes back to the same
reviewer for re-review. Fix security gaps rather than listing them as caveats.
Make one commit per review fix, starting with a reproducing test when
practical.

## 6. Publish and verify

- Commit and push the bundle. In Houston Hub, open **My connectors** and
  publish the GitHub repository, branch and connector path. Houston validates
  the source in the background; the connector appears once validation passes.
  Validated pushes to that branch become new releases, so allow a minute or
  more after each push.
- Enter the publisher settings declared in `houston.json` and register the OAuth
  callback Houston shows, following AUTHORING.md's generic "Publish a Connector
  on Houston Hub" section. Account setup follows the bundle's `SETUP.md`.
- Live test as an account user (AUTHORING.md workflow step 6): discovery,
  `help()` per access level, read-only behavior, paging, OAuth sign-in and
  refresh, and one provider-confirmed write on disposable data. List
  unverified steps as remaining; don't claim them.
- On a rewrite, check which changes force existing connections to set up again
  (AUTHORING.md's "Publish a Connector on Houston Hub") and state the impact.

## Gotchas

**OAuth scopes**
- When the token reply lists scopes, every requested scope must appear in it
  verbatim. Google returns `email` as
  `https://www.googleapis.com/auth/userinfo.email`, so request the full URL.
  `scope_separator` governs both requesting and parsing.
- When the reply omits scopes, Houston assumes the requested ones on first
  sign-in but keeps the previous grant on refresh, so a newly added scope fails
  ("requested OAuth scopes not granted") until the user reconnects.
- Mock token replies in the provider's real format; echoing the request hid
  the scope bug.
- Request read scopes at every access level and put write scopes behind
  `allows`. When a provider collapses scopes (Google), use one complete set per
  level, each behind `is access.<row> "<level>"`, which only scope groups may use.
- A provider may grant fewer scopes than requested. Houston lowers a new
  connection's rows to what was granted and tells the person; a reconnect that
  grants less fails and keeps the previous grant.
- Any access change on an OAuth or Composio connection, up or down, asks the
  account holder to authorize again, and so does any settings change unless the
  field declares `"reauthorize_on_change": false`. Never write in `SETUP.md` that
  switching access takes effect without signing in again.
- `token_response.label` names the account from the code exchange itself when it
  carries a profile (for example `/user/name`), with no `account` request.

**Manifest**
- Config `if` can't reference `auth`; make client fields optional instead
  (Calendly).
- Unused publisher, secret config and auth fields are rejected.
- The read-only proxy rule lists explicit GET paths. Houston itself refuses
  the standard method overrides (`X-HTTP-Method-Override`, `X-HTTP-Method`,
  `X-Method-Override`, and the `$httpMethod` and `_method` query parameters).
  The proxy can't filter other queries, so reject provider-specific overrides
  such as WordPress's `rest_route` or Dolibarr's `http_method` in Lua, and test
  that (WooCommerce does). Signed storage URLs get separate credential-free
  rules. The API token must never match token or OAuth endpoints. Redirects
  aren't followed.
- Write custom methods with their verb, `/v1/items/{id}:archive`, so the rule
  allows only that verb. Placeholders refuse values with colons, so a bare
  `{id}` never matches `id:delete`: list parameters that may contain colons
  (URNs, search text) in `colon_path_parameters`; opaque parameters, such as
  Sheets ranges, accept colons already.
- Never expose an endpoint whose response contains the connection's own
  credential (such as a profile endpoint echoing the API token): deny it and
  test the denial. Endpoints returning other secrets (webhook signing secrets,
  settings) need Write even to read. An all-POST RPC API (Dropbox) enforces
  the read level through the export surface.

**Luau**
- `x or {}` fails typechecking when iterated; use a typed local or a frozen
  `NONE`. Calling a union of function types fails; annotate the local.
- `pcall(fs.open, …)` fails; open the file before the request.
- `end` is a keyword: write `['end'] = …` in help examples. Parameters named
  `read` or `text` shadow helpers.
- NaN isn't plain data. Lowercase user-entered hosts.
- `json.decode` returns doubles, so integers beyond 2^53 lose digits
  (`9007199254740993` becomes `9007199254740992`). When an API returns such IDs,
  quote those tokens before decoding, accept IDs as integers or digit strings and
  say so in `help()`. One official connector does this today; a second one needing
  it should add a runtime `json.decode` option rather than copy that scanner.
- Build large binary data with `buffer`, and await file writes inside loops
  ("file queue capacity exceeded").
- Runtime limits are in AUTHORING.md's "Execution and waiting" and "Bounded
  independent work". State those that matter to callers in `help()`.

**Fixtures and tooling**
- Conformance checks help separately. Use `fixture.example(name, index?)` to
  execute the generated documented call against the fixture's provider mocks;
  fixtures retain the real exported operation and its data-only boundary.
- When the request count is off, check the spec before changing either side:
  an extra page request or duplicate write is a connector bug.
- `LocalUnused` analyzer lines are noise.
- Pin dated API versions (`LinkedIn-Version`, Notion, `cal-api-version`) and
  note their sunset in AUTHORING.md.

## Done means

- Bundle, fixtures and docs written; validation passes locally or in Hub.
- The last review found nothing you would fix.
- Remaining manual steps listed: Hub publication, provider app setup, live test.
