UNPKG

@nutrient-sdk/dws-mcp-server

Version:

MCP server for Nutrient DWS Processor API

29 lines (28 loc) 913 B
import FormData from 'form-data'; import axios from 'axios'; import { getApiKey } from './utils.js'; import { getVersion } from '../version.js'; /** * Makes an API call to the Nutrient API * @param endpoint The API endpoint to call (e.g., 'sign', 'build') * @param data The data to send (FormData or JSON object) * @returns The API response */ export async function callNutrientApi(endpoint, data) { const apiKey = getApiKey(); const isFormData = data instanceof FormData; const defaultHeaders = { Authorization: `Bearer ${apiKey}`, 'User-Agent': `NutrientDWSMCPServer/${getVersion()}`, }; const headers = isFormData ? defaultHeaders : { ...defaultHeaders, 'Content-Type': 'application/json', }; return axios.post(`https://api.nutrient.io/${endpoint}`, data, { headers, responseType: 'stream', }); }