From 821400d6c70143c79a6123f4caf2db570d0dc0c0 Mon Sep 17 00:00:00 2001 From: Andrew Lee <5784515+andyrewlee@users.noreply.github.com> Date: Fri, 4 Dec 2026 15:35:00 -0800 Subject: [PATCH] Generate provider routes from the catalog --- README.md | 6 +++--- catalog/providers/anthropic.yaml | 2 +- catalog/providers/openai.yaml | 2 +- catalog/providers/openrouter.yaml | 2 +- package.json | 2 +- scripts/generate.mjs | 17 ++++++++++++++--- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 077b00a..026b1d3 100644 --- a/README.md +++ b/README.md @@ -77,10 +77,10 @@ Search prefers a name match over a title or description match and accepts camel ### Run the MCP catalog example -Run these commands in a new project. The package contains the example from version 0.0.2 onward. +Run these commands in a new project. ```sh -npm install @checkfu/integrations@0.0.2 @modelcontextprotocol/client@2.4.0 +npm install @checkfu/integrations @modelcontextprotocol/client@2.4.0 node node_modules/@checkfu/integrations/examples/mcp-catalog.mjs ``` @@ -101,7 +101,7 @@ bun install --frozen-lockfile bun run verify ``` -Edit one YAML file per service or provider. Start with [Linear](catalog/services/linear.yaml) for an MCP connector or follow an existing file in [catalog/providers](catalog/providers). Keep the filename and `id` in sync. Runtime fields live alongside the imported `reference` metadata. After editing YAML, run `bun run generate`, then run `bun run verify` and commit the YAML and generated files together so anyone can install directly from Git. +Edit one YAML file per service or provider. Start with [Linear](catalog/services/linear.yaml) for an MCP connector or follow an existing file in [catalog/providers](catalog/providers). Keep the filename and `id` in sync. Set a runtime provider endpoint to `null` to use the corresponding base URL from `reference.speaks`. Give it a URL when the reference does not describe that route. After editing YAML, run `bun run generate`, then run `bun run verify` and commit the YAML and generated files together so anyone can install directly from Git. `bun run verify` checks generated source, rebuilds the distribution, runs the type checker, and tests under Bun and Node.js. Use `bun run test` for a fresh build and the Bun suite. Use `bun run test:built` or `bun run test:node` after an explicit build to exercise the existing distribution. CI installs the release tarball in clean Node and Bun projects and checks the public types, the MCP example, and signed event verification. diff --git a/catalog/providers/anthropic.yaml b/catalog/providers/anthropic.yaml index d578f91..0a38660 100644 --- a/catalog/providers/anthropic.yaml +++ b/catalog/providers/anthropic.yaml @@ -3,7 +3,7 @@ id: anthropic name: Anthropic endpoints: # The Messages client appends /v1/messages. - anthropic-messages: https://api.anthropic.com + anthropic-messages: null auth: kind: api_key_header header: x-api-key diff --git a/catalog/providers/openai.yaml b/catalog/providers/openai.yaml index 0f2a96e..7826e49 100644 --- a/catalog/providers/openai.yaml +++ b/catalog/providers/openai.yaml @@ -2,7 +2,7 @@ format: 1 id: openai name: OpenAI endpoints: - openai-responses: https://api.openai.com/v1 + openai-responses: null auth: kind: bearer reference: diff --git a/catalog/providers/openrouter.yaml b/catalog/providers/openrouter.yaml index 7ee6641..e2ba2b4 100644 --- a/catalog/providers/openrouter.yaml +++ b/catalog/providers/openrouter.yaml @@ -3,7 +3,7 @@ id: openrouter name: OpenRouter endpoints: anthropic-messages: https://openrouter.ai/api - openai-completions: https://openrouter.ai/api/v1 + openai-completions: null auth: kind: bearer reference: diff --git a/package.json b/package.json index 36e2b72..d135699 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@checkfu/integrations", - "version": "0.0.2", + "version": "0.0.3", "description": "Integration catalogs for Checkfu and other TypeScript and JavaScript hosts.", "license": "MIT", "type": "module", diff --git a/scripts/generate.mjs b/scripts/generate.mjs index d0d08f3..0ea1b5a 100644 --- a/scripts/generate.mjs +++ b/scripts/generate.mjs @@ -51,6 +51,19 @@ function render(entries, folder, exportName, typeName, project) { ].join("\n")) } +function runtimeProvider({ name, endpoints, auth, reference }) { + if (endpoints === undefined) return null + const routes = Object.entries(endpoints).map(([format, endpoint]) => { + if (endpoint !== null) return [format, endpoint] + const matches = reference?.speaks?.filter((route) => route.format === format) ?? [] + if (matches.length !== 1 || typeof matches[0].base_url !== "string") { + throw new Error(`${name} must define one reference base URL for the ${format} endpoint`) + } + return [format, matches[0].base_url] + }) + return { name, endpoints: Object.fromEntries(routes), auth } +} + function serviceCapabilities({ surfaces, reference }) { const upstream = reference?.surfaces const capabilities = [] @@ -100,9 +113,7 @@ function renderCatalog(providers, services, triggers) { if (!check) await mkdir(output, { recursive: true }) const [providers, services, triggers] = await Promise.all(["providers", "services", "triggers"].map(readFolder)) await Promise.all([ - render(providers, "providers", "providers", "ProviderDefinition", ({ reference, ...definition }) => - definition.endpoints === undefined ? null : definition, - ), + render(providers, "providers", "providers", "ProviderDefinition", runtimeProvider), render(services, "services", "connectors", "ConnectorDefinition", ({ name, surfaces }) => surfaces?.mcp === undefined ? null : { name, mcp: surfaces.mcp }, ),