Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ jobs:
[[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
[[ "$GITHUB_REF_NAME" == "v$(node -p "require('./package.json').version")" ]]
git merge-base --is-ancestor HEAD origin/main
- name: Load the installed npm package
- name: Verify the npm package in clean Node and Bun projects
run: |
directory="$RUNNER_TEMP/package"
mkdir -p "$directory"
artifact="$(npm pack --ignore-scripts --pack-destination "$directory" --silent)"
(cd "$directory" && sha256sum "$artifact" > SHA256SUMS)
cd "$(mktemp -d)"
bun add --ignore-scripts "$directory/$artifact"
bun -e 'import { providers } from "@checkfu/integrations/providers"; if (!providers.openai) process.exit(1)'
bun -e 'import { connectors } from "@checkfu/integrations/connectors"; if (!connectors.linear) process.exit(1)'
node --input-type=module -e 'import { searchToolCatalog } from "@checkfu/integrations/tool-catalog"; if (searchToolCatalog([{ name: "listIssues" }], "list issues").items[0]?.name !== "listIssues") process.exit(1)'
node --input-type=module -e 'import { catalogByKind } from "@checkfu/integrations/catalog"; if (!catalogByKind.channel.some(entry => entry.id === "discord")) process.exit(1)'
node --input-type=module -e 'import { discordReplyRequest } from "@checkfu/integrations/channels"; if (discordReplyRequest("123", "fixture", "reply").redirect !== "manual") process.exit(1)'
bun run verify:installed "$directory/$artifact"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: verified-package
Expand Down
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ A standalone catalog and protocol library for model providers, MCP connectors, i

## Install

Install the package with Bun. Git snapshots include JavaScript modules and TypeScript declarations. The modules run in Bun and Node.js 22 or newer and use standard Web Crypto and Fetch APIs.
The package includes JavaScript modules and TypeScript declarations for Bun and Node.js 22 or newer. It uses standard Web Crypto and Fetch APIs.

```sh
bun add github:checkfu/integrations
npm install @checkfu/integrations
# Or with Bun
bun add @checkfu/integrations
```

Append `#` and a full commit SHA to pin the same catalog across installs.
To try an unpublished catalog change, install a Git snapshot by its full commit SHA.

```sh
bun add 'github:checkfu/integrations#<full-commit-sha>'
```

## Browse the catalog

Expand Down Expand Up @@ -52,7 +58,7 @@ Use the URL with a Streamable HTTP MCP client. The catalog lists the supported a

## Tool catalogs

Use `@checkfu/integrations/tool-catalog` to present the tools your application has discovered. Supply definitions from an MCP client's `tools/list` response or any source with tool names. Each result keeps the original definition and exact callable name.
Use [`searchToolCatalog`](src/tool-catalog.ts) from `@checkfu/integrations/tool-catalog` to present the tools your application has discovered. Supply definitions from an MCP client's `tools/list` response or any source with tool names. Each result keeps the original definition and exact callable name.

```ts
import { searchToolCatalog } from "@checkfu/integrations/tool-catalog"
Expand All @@ -69,9 +75,20 @@ const next = page.nextOffset === null

Search prefers a name match over a title or description match and accepts camel case, underscores, hyphens, and spaces. An empty query lists the available tools in input order. Queries have a 256-character limit and pages have a 100-entry limit. Keep the input catalog stable when paging. The results contain only tools the caller supplied. The host supplies the connection and decides what each user or agent may access.

### Run the MCP catalog example

Run these commands in a new project. The package contains the example from version 0.0.2 onward.

```sh
npm install @checkfu/integrations@0.0.2 @modelcontextprotocol/client@2.4.0
node node_modules/@checkfu/integrations/examples/mcp-catalog.mjs
```

For Bun, use `bun add` and run the same script with `bun`. The [example](examples/mcp-catalog.mjs) uses a local MCP endpoint with a generated bearer token and a second endpoint with anonymous access. It reads two pages from each endpoint, ranks matching tools, and prints the exact name and schemas of the selected tool. The server's request log verifies zero tool invocations. The example requires no provider account.

## Incoming events and channels

The [generic signed webhook](catalog/triggers/webhook.yaml) uses Standard Webhooks. The verifier returns the exact authenticated delivery ID. IDs are opaque, nonempty strings that exclude the signing delimiter (`.`). Apply the host's transport and storage limits when using them as idempotency keys. The `@checkfu/integrations/webhooks` export verifies native GitHub, Linear, and Notion deliveries and returns a verified event, account, and deduplication ID. The [Discord channel](catalog/services/discord.yaml) uses signed interactions. Its reply builder returns a standard Fetch request with redirects disabled through manual handling. The host sends the request and handles the response.
The [generic signed webhook](catalog/triggers/webhook.yaml) uses Standard Webhooks. The verifier returns the exact authenticated delivery ID. IDs are opaque, nonempty strings that exclude the signing delimiter (`.`). Apply the host's transport and storage limits when using them as idempotency keys. [`verifyNativeWebhook`](src/webhooks.ts) from `@checkfu/integrations/webhooks` verifies native GitHub, Linear, and Notion deliveries and returns a verified event, account, and deduplication ID. The [Discord channel](catalog/services/discord.yaml) uses signed interactions. Its reply builder returns a standard Fetch request with redirects disabled through manual handling. The host sends the request and handles the response.

Hosts own credential storage, replay protection, permissions, routing, and deployment. Each catalog surface describes what this library can provide to a host. [Standard Webhooks](https://www.standardwebhooks.com/) · [Discord interactions](https://docs.discord.com/developers/interactions/receiving-and-responding)

Expand All @@ -86,7 +103,12 @@ 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.

`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 runs the full verification, checks distribution freshness, and smoke-tests an installed package.
`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.

```sh
archive="$(npm pack --ignore-scripts --silent)"
bun run verify:installed "$archive"
```

Preview a reference update before importing it. Pass a local checkout and a full Git commit SHA.

Expand Down
86 changes: 86 additions & 0 deletions examples/mcp-catalog-fixture.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { once } from "node:events"
import { createServer } from "node:http"
import { text } from "node:stream/consumers"

export const exactTool = {
name: "listIssues",
title: "List issues",
description: "Find issues in a workspace.",
inputSchema: {
type: "object",
properties: {
project: { type: "string" },
limit: { type: "integer", minimum: 1, maximum: 20 },
},
required: ["project"],
additionalProperties: false,
},
outputSchema: {
type: "object",
properties: { count: { type: "integer", minimum: 0 } },
required: ["count"],
},
annotations: { readOnlyHint: true },
}

const archiveTool = {
name: "archiveProject",
description: "Archive a project after you list its issues.",
inputSchema: { type: "object", properties: { project: { type: "string" } } },
}

export async function startCatalogFixture(token) {
const calls = []
async function respond(request, response) {
if (request.method !== "POST") {
response.writeHead(405).end()
return
}
const { id, method, params } = JSON.parse(await text(request))
const authorization = request.headers.authorization
calls.push({ path: request.url, method, cursor: params?.cursor, authorization })
const expected = request.url === "/authenticated" ? `Bearer ${token}` : undefined
if (authorization !== expected ||
(request.url !== "/authenticated" && request.url !== "/public")) {
response.writeHead(401).end()
return
}
if (id === undefined) {
response.writeHead(202).end()
return
}
const result = method === "initialize"
? {
protocolVersion: params.protocolVersion,
capabilities: { tools: {} },
serverInfo: { name: "Catalog fixture", version: "1.0.0" },
}
: method === "tools/list"
? params?.cursor === "second"
? { tools: [exactTool] }
: { tools: [archiveTool], nextCursor: "second" }
: undefined
const message = result === undefined
? { error: { code: -32601, message: "Method unavailable" } }
: { result }
response.writeHead(200, { "content-type": "application/json" })
.end(JSON.stringify({ jsonrpc: "2.0", id, ...message }))
}
const server = createServer((request, response) => {
void respond(request, response).catch(() => {
if (response.headersSent) response.destroy()
else response.writeHead(400).end()
})
})
server.listen(0, "127.0.0.1")
await once(server, "listening")
const address = server.address()
if (address === null || typeof address === "string") throw new Error("Fixture has no HTTP port.")
return {
url: new URL(`http://127.0.0.1:${address.port}/`),
calls,
close: () => new Promise((resolve, reject) => {
server.close(error => error ? reject(error) : resolve())
}),
}
}
67 changes: 67 additions & 0 deletions examples/mcp-catalog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import assert from "node:assert/strict"
import { randomUUID } from "node:crypto"
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client"
import { connectors } from "@checkfu/integrations/connectors"
import { searchToolCatalog } from "@checkfu/integrations/tool-catalog"
import { exactTool, startCatalogFixture } from "./mcp-catalog-fixture.mjs"

async function previewCatalog(transport, query, callableName) {
const client = new Client({ name: "Catalog preview", version: "1.0.0" })
try {
await client.connect(transport)
const catalog = []
const cursors = new Set()
let cursor
do {
const page = await client.listTools(cursor === undefined ? undefined : { cursor })
catalog.push(...page.tools)
cursor = page.nextCursor
if (cursor !== undefined) {
if (cursors.has(cursor) || cursors.size >= 19) throw new Error("Catalog pagination did not finish.")
cursors.add(cursor)
}
} while (cursor !== undefined)

const matches = searchToolCatalog(catalog, query, { limit: 1 })
const more = matches.nextOffset === null
? null
: searchToolCatalog(catalog, query, { offset: matches.nextOffset, limit: 1 })
const exact = searchToolCatalog(catalog, callableName).items.find(tool => tool.name === callableName)
assert.ok(exact, `No tool called ${callableName}`)
assert.equal(exact, catalog.find(tool => tool.name === callableName))
return { matches, more, exact }
} finally {
await client.close()
}
}

const { name, mcp: { url, transport, auth } } = connectors.linear
assert.equal(transport, "streamable-http")
assert.ok(auth.includes("bearer"))
const token = randomUUID()
const fixture = await startCatalogFixture(token)
try {
// Supply the endpoint and optional authorization in your transport.
const choices = [
{ route: "authenticated", requestInit: { headers: { Authorization: `Bearer ${token}` } } },
{ route: "public", requestInit: {} },
]
const results = []
for (const { route, requestInit } of choices) {
const connection = new StreamableHTTPClientTransport(new URL(route, fixture.url), { requestInit })
const { matches, more, exact } = await previewCatalog(connection, "list issues", "listIssues")
assert.deepEqual(matches.items.map(tool => tool.name), ["listIssues"])
assert.deepEqual(more?.items.map(tool => tool.name), ["archiveProject"])
assert.equal(more?.nextOffset, null)
assert.deepEqual(exact, exactTool)
const lists = fixture.calls.filter(call => call.path === `/${route}` && call.method === "tools/list")
assert.deepEqual(lists.map(call => call.cursor), [undefined, "second"])
assert.deepEqual(lists.map(call => call.authorization), Array(2).fill(requestInit.headers?.Authorization))
results.push({ route, listedPages: lists.length, matches: [matches.items[0].name, more.items[0].name], exact })
}
const toolCalls = fixture.calls.filter(call => call.method === "tools/call").length
assert.equal(toolCalls, 0)
console.log(JSON.stringify({ connector: { name, url, transport, auth }, results, toolCalls }, null, 2))
} finally {
await fixture.close()
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@checkfu/integrations",
"version": "0.0.1",
"version": "0.0.2",
"description": "Integration catalogs for Checkfu and other TypeScript and JavaScript hosts.",
"license": "MIT",
"type": "module",
Expand All @@ -19,7 +19,8 @@
},
"files": [
"catalog",
"dist"
"dist",
"examples"
],
"exports": {
"./catalog": { "types": "./dist/catalog.d.ts", "default": "./dist/catalog.js" },
Expand All @@ -40,7 +41,8 @@
"test:built": "bun test ./test/*.test.mjs",
"test:node": "node --test test/*.test.mjs",
"test": "bun run generate:check && bun run build && bun run test:built",
"verify": "bun run generate:check && bun run build && bun run typecheck && bun run test:built && bun run test:node"
"verify": "bun run generate:check && bun run build && bun run typecheck && bun run test:built && bun run test:node",
"verify:installed": "node scripts/verify-installed.mjs"
},
"devDependencies": {
"typescript": "7.0.2",
Expand Down
53 changes: 53 additions & 0 deletions scripts/verify-installed.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import assert from "node:assert/strict"
import { execFileSync } from "node:child_process"
import { createHash } from "node:crypto"
import { copyFile, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rm, writeFile } from "node:fs/promises"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { fileURLToPath } from "node:url"

const [path] = process.argv.slice(2)
if (path === undefined) throw new Error("Supply the npm tarball to install and verify.")

const archive = await realpath(path)
const sha256 = createHash("sha256").update(await readFile(archive)).digest("hex")
const root = await mkdtemp(join(tmpdir(), "integrations-installed-"))
const mcpClient = "@modelcontextprotocol/client@2.4.0"
const tsc = fileURLToPath(new URL("../node_modules/.bin/tsc", import.meta.url))
const environments = [
{ name: "Node", runtime: process.execPath, installer: "npm", args: ["install", "--ignore-scripts", "--no-audit", "--no-fund"] },
{ name: "Bun", runtime: "bun", installer: "bun", args: ["add", "--ignore-scripts"] },
]
const run = (command, args, cwd) =>
execFileSync(command, args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"], timeout: 120_000 })

try {
for (const { name, runtime, installer, args } of environments) {
const consumer = join(root, name.toLowerCase())
await mkdir(consumer)
await writeFile(join(consumer, "package.json"), '{"name":"integration-example","private":true,"type":"module"}\n')
run(installer, [...args, archive, mcpClient], consumer)
const scope = join(consumer, "node_modules", "@checkfu")
assert.deepEqual(await readdir(scope), ["integrations"])
const installed = join(scope, "integrations")
assert.equal((await lstat(installed)).isSymbolicLink(), false)
for (const file of ["installed-exports.mjs", "installed-types.ts"]) {
await copyFile(new URL(`../test/${file}`, import.meta.url), join(consumer, file))
}
run(tsc, [
"--noEmit", "--strict", "--noUncheckedIndexedAccess", "--exactOptionalPropertyTypes",
"--target", "ES2022", "--module", "NodeNext", "installed-types.ts",
], consumer)
run(runtime, ["installed-exports.mjs"], consumer)
const report = JSON.parse(run(runtime, [join(installed, "examples", "mcp-catalog.mjs")], consumer))
assert.deepEqual(report.results.map(({ route, listedPages }) => [route, listedPages]), [
["authenticated", 2],
["public", 2],
])
assert.equal(report.toolCalls, 0)
process.stdout.write(`${name} ${run(runtime, ["--version"], consumer).trim()} verified types, exports, signed delivery, and two catalog pages per authorization mode.\n`)
}
process.stdout.write(`Verified archive SHA-256 ${sha256}\n`)
} finally {
await rm(root, { recursive: true, force: true })
}
32 changes: 32 additions & 0 deletions test/installed-exports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import assert from "node:assert/strict"
import { createHash, createHmac, randomBytes } from "node:crypto"
import { catalogByKind } from "@checkfu/integrations/catalog"
import { discordReplyRequest } from "@checkfu/integrations/channels"
import { connectors } from "@checkfu/integrations/connectors"
import { providers } from "@checkfu/integrations/providers"
import { searchToolCatalog } from "@checkfu/integrations/tool-catalog"
import { triggers } from "@checkfu/integrations/triggers"
import { verifyNativeWebhook } from "@checkfu/integrations/webhooks"

assert.ok(Object.values(providers).some(provider => Object.keys(provider.endpoints).length > 0))
assert.equal(connectors.linear.mcp.transport, "streamable-http")
assert.ok(catalogByKind.channel.some(entry => entry.id === "discord"))
assert.equal(discordReplyRequest("123", "fixture", "reply").redirect, "manual")
assert.equal(searchToolCatalog([{ name: "listIssues" }], "list issues").items[0]?.name, "listIssues")
assert.equal(triggers.webhook.protocol, "standard-webhooks")

const organizationId = "ae69a7ad-9d20-459f-9d46-152f5376b8a3"
const event = { organizationId, type: "Issue", action: "create", data: { id: "fixture-issue" } }
const now = Date.now()
const body = Buffer.from(JSON.stringify({ ...event, webhookTimestamp: now }))
const secret = randomBytes(32).toString("hex")
const signature = createHmac("sha256", secret).update(body).digest("hex")
const headers = new Headers({ "linear-signature": signature })
const expected = {
type: "event",
event: "Issue.create",
account: organizationId,
id: createHash("sha256").update(JSON.stringify(event)).digest("hex"),
}
assert.deepEqual(await verifyNativeWebhook("linear", body, headers, secret, now), expected)
assert.deepEqual(await verifyNativeWebhook("linear", body.subarray(0, -1), headers, secret, now), { type: "invalid" })
Loading
Loading