MCPCat API TypeScript SDK

raw JSON →
0.1.8 verified Sat Apr 25 auth: no javascript

MCPCat API is a TypeScript/JavaScript SDK for interacting with the MCPCat service. Version 0.1.8 provides a generated client using the Fetch API, supporting both Node.js and browser environments. It compiles to ES5/ES6 and works with CommonJS or ES module systems, with built-in TypeScript definitions. The SDK is generated from OpenAPI specs and is in early development with a focus on type safety and REST API integration.

error TypeError: fetch is not defined
cause The SDK requires the fetch API, which is missing in Node.js versions before 18.
fix
Upgrade to Node.js 18+ or install a fetch polyfill like 'node-fetch'.
error Error: Configuration must include 'apiKey'
cause The SDK configuration requires an API key for authentication.
fix
Pass an apiKey property when creating a new MCPCatApi instance.
error Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data')
cause The response may be undefined if an error occurs and is not caught.
fix
Wrap API calls in try-catch blocks to handle errors.
gotcha The SDK uses fetch, which is not available in older Node.js versions (<18).
fix Use Node.js 18+ or polyfill global fetch.
deprecated The constructor option 'baseUri' is deprecated; use 'basePath' instead.
fix Replace 'baseUri' with 'basePath' in the configuration object.
gotcha API key must be a string; passing a non-string will cause a runtime error.
fix Ensure apiKey is a string, e.g., from environment variables.
npm install mcpcat-api
yarn add mcpcat-api
pnpm add mcpcat-api

Initializes the MCPCat API client with base URL and API key, then fetches a list of models.

import MCPCatApi from 'mcpcat-api';

const api = new MCPCatApi({
  basePath: 'https://api.mcpcat.com',
  apiKey: process.env.MCPCAT_API_KEY ?? ''
});

async function getModels() {
  try {
    const response = await api.listModels();
    console.log(response.data);
  } catch (error) {
    console.error('Error:', error);
  }
}

getModels();