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.
Common errors
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.
Warnings
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.
Install
npm install mcpcat-api yarn add mcpcat-api pnpm add mcpcat-api Imports
- default import wrong
const MCPCatApi = require('mcpcat-api');correctimport MCPCatApi from 'mcpcat-api'; - ApiClient wrong
const ApiClient = require('mcpcat-api').ApiClient;correctimport { ApiClient } from 'mcpcat-api'; - Configuration wrong
import Configuration from 'mcpcat-api/Configuration';correctimport { Configuration } from 'mcpcat-api';
Quickstart
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();