Shared REST API utilities for building Model Context Protocol (MCP) servers.
- RestClient: HTTP client with automatic retries, timeout handling, and error management
- RestToolFactory: Factory pattern for creating and executing MCP tools
- Type-safe configuration: TypeScript interfaces for REST tool definitions
- Error handling: Unified error handling across all servers
npm install git+https://github.com/munch-group/mcp-rest-utils.gitgit clone https://github.com/munch-group/mcp-rest-utils.git
cd mcp-rest-utils
npm install
npm run buildimport { 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 buildISC