@decocms/bindings

中文文档
1.6.3发布于 2026/10/10ES Module构建来源已验证近 30 天下载 5296

Defines typed, reusable contracts for capabilities exposed through Model Context Protocol tools.

原始使用文档
文档目录7 节
  1. Overview
  2. Responsibilities
  3. Usage
  4. Architecture
  5. Development
  6. Boundaries
  7. Related documentation

@decocms/bindings

Defines typed, reusable contracts for capabilities exposed through Model Context Protocol tools.

AttributeValue
Workspace@decocms/bindings (packages/bindings)
KindTypeScript contract library
RuntimeNode.js 24+
DistributionPublic npm package

Overview

A binding is a list of MCP tool names paired with Zod input and output schemas. It gives producers and consumers one shared description of a capability without coupling either side to a Studio application.

The package includes the binding primitives, typed client adapters, connection types, and well-known contracts for collections, language models, object storage, MCP configuration, assistants, prompts, AI gateway billing, triggers, and event subscribers.

Responsibilities

  • Define Binder and ToolBinder contracts for required and optional tools.
  • Check whether a tool list contains every required binding member.
  • Produce typed clients for an existing MCP client or an MCP connection.
  • Publish reusable Zod schemas and TypeScript types for well-known contracts.
  • Define collection query, pagination, sorting, and CRUD shapes.

Usage

Install the public package:

bun add @decocms/bindings

Define a binding and check whether an MCP tool list implements it:

import {
  createBindingChecker,
  type Binder,
} from "@decocms/bindings";
import { z } from "zod";

const SEARCH_BINDING = [
  {
    name: "SEARCH" as const,
    inputSchema: z.object({ query: z.string() }),
    outputSchema: z.object({ results: z.array(z.string()) }),
  },
  {
    name: "SEARCH_SUGGEST" as const,
    inputSchema: z.object({ prefix: z.string() }),
    outputSchema: z.object({ suggestions: z.array(z.string()) }),
    opt: true,
  },
] as const satisfies Binder;

const checker = createBindingChecker(SEARCH_BINDING);
const supported = checker.isImplementedBy([{ name: "SEARCH" }]);

Supported package exports:

Import pathSurface
@decocms/bindingsBinding primitives plus event subscriber, trigger, and object-storage exports
@decocms/bindings/collectionsCollection schemas, factories, and types
@decocms/bindings/llmDeprecated language-model binding
@decocms/bindings/object-storageObject-storage binding
@decocms/bindings/connectionMCP connection descriptor types
@decocms/bindings/clientTyped MCP clients and HTTP transport
@decocms/bindings/mcpMCP configuration binding
@decocms/bindings/assistantAssistant collection binding
@decocms/bindings/promptPrompt schemas and types
@decocms/bindings/ai-gatewayAI gateway billing binding
@decocms/bindings/triggerTrigger binding and typed client

Architecture

src/core/binder.ts owns the binding model, compatibility checker, and typed client factory. src/core/client/ adapts either a live MCP client or a connection descriptor into callable, binding-shaped methods.

src/well-known/ contains capability-specific schemas and tool lists. The package export map exposes only the supported entry points listed above; the root barrel intentionally re-exports only the most commonly shared contracts.

Collection bindings generate COLLECTION_<NAME>_LIST and COLLECTION_<NAME>_GET as required tools. Unless readOnly: true is set, they also describe optional create, update, and delete tools. The canonical base entity schema includes identity, title, description, timestamps, and audit fields.

Development

Run commands from the repository root:

bun install
bun run --cwd=packages/bindings check
bun run --cwd=packages/bindings test

Run the focused MCP binding test with:

bun test packages/bindings/test/mcp.test.ts

The package publishes TypeScript source directly and has no separate build script.

Boundaries

This package owns capability contracts, not implementations. Database access, authorization, HTTP route handling, Studio application state, and UI behavior belong elsewhere.

Do not import unpublished files under src/; use a package export. Do not add app aliases or reach into apps/api or apps/web.

createBindingChecker currently verifies required tool-name coverage, including regular-expression names and optional entries. The schemas remain part of the binding contract, but the checker does not currently perform structural schema compatibility validation.

The /llm binding targets an older AI SDK provider abstraction and is deprecated. New model integrations use native provider adapters instead of extending that binding.

版本与发布记录

@decocms/bindings 共发布 79 个版本,首次发布于 2025/11/22;过去 12 个月发布了 79 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.6.3latest2026/10/101 个月前
1.6.22026/09/231 个月前
1.6.12026/08/132 个月前
1.6.02026/07/303 个月前
1.5.02026/07/283 个月前
1.4.122026/07/223 个月前

其他发布通道:0x → 0.2.5,next → 1.0.1-alpha.27。

关于 @decocms/bindings 的常见问题

@decocms/bindings 是什么?

Defines typed, reusable contracts for capabilities exposed through Model Context Protocol tools.

如何安装 @decocms/bindings?

在项目目录运行 npm install @decocms/bindings,或使用 pnpm add / yarn add / bun add。

@decocms/bindings 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/decocms__bindings 是否存在。

@decocms/bindings 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@decocms/bindings 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@decocms/bindings 可以商用吗?

@decocms/bindings 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@decocms/bindings 的下载量有多少?

根据 npm 官方下载统计,@decocms/bindings 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,296 次,日均约 177 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@decocms/bindings 还在维护吗?

最新版本 1.6.3 发布于 2026/10/10(1 个月前);至今共发布 79 个版本,其中过去 12 个月发布了 79 个;首次发布于 2025/11/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。