MC

mark1russell7/client

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

0 stars 0 forks 质量 77 趋势 20MIT

TypeScript 的过程数据:一个用于进程中调用的类型调用模型,包括 HTTP、WebSocket、CLI 和 MCP(Claude)——支持流式、中间件和可视化作曲器。

概览

你定义一个过程一次:路径、Zod 输入、Zod 输出和处理器。然后在同一进程中使用它,通过 HTTP 或 WebSocket,通过标记 CLI,或从 Claude 作为 MCP 工具使用。程序是纯 JSON:调用、对早期结果的引用和控制流。客户端提供流、中间件、重试和缓存。 有Composer(从模块构建程序,然后在浏览器中启动)、中间件实验室、过程目录和状态板。 这些软件包需要Node.js 22年或更高。它们是ES模块。 用 HttpTransport 或 WebSocketTransport 替换 LocalTransport,以便在服务器上使用相同的过程。PROGRAM-FORMAT.md 表示程序的规则。 tRPC 是单个应用程序中从服务器到客户端进行类型推断的更好选择。该仓库用于许多主机使用的过程:程序、CLI、服务器和 Claude。 所有包都包含在包/中。公用包属于npm范围@procedures,一个版本一起。

概述(AI 翻译)

**将过程作为TypeScript的数据。**你定义一个过程一次:路径、Zod输入、Zod输出和处理器。然后在同一进程中使用它,通过HTTP或WebSocket,通过mark CLI,或Claude作为MCP工具使用。程序是纯JSON:调用、对早期结果的引用和控制流。客户端提供流、中间件、重试和缓存。

网站有Composer(从块构建程序,然后在浏览器启动)、中间件实验室、过程目录和状态板。

安装

这些软件包需要Node.js 22年或更高。它们是ES模块。

示例

将LocalTransport替换为HttpTransport或WebSocketTransport,以便在服务器上使用相同的过程。PROGRAM-FORMAT.md 表示程序的规则。

与其他工具相比

客户端 tRPC JSON-RPC 2.0 MCP TypeScript SDK
工作单元 一个过程:路径、Zod 输入输出、处理器 查询、变异和订阅的路由器 方法名称及其参数 工具、资源和提示符

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

client

Procedures as data for TypeScript. You define a procedure one time: a path, a Zod input, a Zod output and a handler. Then you use it in the same process, over HTTP or WebSocket, from the mark CLI, or from Claude as an MCP tool. A program is plain JSON: calls, references to earlier results, and control flow. The client gives streams, middleware, retries and a cache.

The site has the Composer (build a program from blocks, then start it in your browser), the middleware lab, the procedure catalog and the status board.

Install

npm install @procedures/client zod

The packages need Node.js 22 or later. They are ES modules.

Example

import { z } from "zod";
import { Client, LocalTransport, PROCEDURE_REGISTRY, allCoreProcedures, createProcedure, zodAdapter } from "@procedures/client";
import "@procedures/client/register"; // the control flow: client.chain and the others

// A procedure: a path, a typed input and output, and a handler
PROCEDURE_REGISTRY.register(
  createProcedure()
    .path(["greet"])
    .input(zodAdapter(z.object({ name: z.string() })))
    .output(zodAdapter(z.string()))
    .handler(async ({ name }) => `Hello, ${name}!`)
    .build(),
);
for (const p of allCoreProcedures) if (!PROCEDURE_REGISTRY.has(p.path)) PROCEDURE_REGISTRY.register(p);

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
console.log(await client.exec({ $proc: ["greet"], input: { name: "Ada" } }));
// Hello, Ada!

// A program is JSON: the second step reads the result of the first step
const result = await client.exec({
  $proc: ["client", "chain"],
  input: {
    steps: [
      { $proc: ["client", "add"], input: { a: 2, b: 3 } },
      { $proc: ["client", "multiply"], input: { a: { $ref: "$last" }, b: 4 } },
    ],
  },
});
console.log(result.final);
// 20

Replace LocalTransport with HttpTransport or WebSocketTransport to use the same procedures on a server. PROGRAM-FORMAT.md tells the rules of programs.

Compared with other tools

在 GitHub 查看完整 README

安装

npx -y @procedures/mcp-dev-tools
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "dev-tools": { "command": "npx", "args": ["-y", "@procedures/mcp-dev-tools"] } } }