REST API工具集

提供构建Model Context Protocol (MCP)服务器的共享REST API工具集,包含HTTP客户端、工具工厂、类型安全配置和统一错误处理等功能。

  • by munch-group
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 munch-group/mcp-rest-utils

使用说明

MCP REST实用程序

用于构建模型上下文协议(MCP)服务器的共享REST API实用程序。

特性

  • RestClient:具有自动重试、超时处理和错误管理功能的HTTP客户端
  • RestToolFactory:创建和执行MCP工具的工厂模式
  • 类型安全配置:REST工具定义的TypeScript接口
  • 错误处理:跨所有服务器的统一错误处理

安装

来自GitHub

npm install git+https://github.com/munch-group/mcp-rest-utils.git

来源

git clone https://github.com/munch-group/mcp-rest-utils.git
cd mcp-rest-utils
npm install
npm run build

用法

import { RestClient, RestToolFactory } from "@mcp/rest-utils";

// Create a REST client
const client = new RestClient({
  baseUrl: "https://api.example.com",
  defaultHeaders: { "Content-Type": "application/json" },
  timeout: 30000,
  retries: 3,
});

// Define tools
const tools = [{
  name: "get_data",
  description: "Get data from API",
  method: "GET",
  endpoint: (args) => `/data/${args.id}`,
  inputSchema: { /* ... */ },
}];

// Create tool factory and execute
const factory = new RestToolFactory(client);
const result = await factory.executeTool(tools[0], { id: "123" });

建筑

npm run build

许可证

国际学生委员会