@boldsign/mcp
Version:
Model Context Protocol (MCP) server for BoldSign API
64 lines (63 loc) • 2.31 kB
JavaScript
import { isNullOrUndefined, stringEquals } from './utils.js';
class Configuration {
static US_REGION_BASE_PATH = 'https://api.boldsign.com';
static EU_REGION_BASE_PATH = 'https://api-eu.boldsign.com';
static CA_REGION_BASE_PATH = 'https://api-ca.boldsign.com';
static BOLDSIGN_API_KEY = 'BOLDSIGN_API_KEY';
static BOLDSIGN_API_REGION = 'BOLDSIGN_API_REGION';
static BOLDSIGN_LOGGING = 'BOLDSIGN_LOGGING';
static instance;
basePath;
apiKey;
enableLogging;
constructor(apiKey, region, logging) {
if (isNullOrUndefined(apiKey)) {
throw new Error(`Missing BoldSign API Key. Please ensure the ${Configuration.BOLDSIGN_API_KEY} environment variable is set with your valid API key in your MCP configuration`);
}
this.apiKey = apiKey;
try {
if (isNullOrUndefined(region)) {
this.basePath = Configuration.US_REGION_BASE_PATH;
}
else {
switch (region) {
case 'EU': {
this.basePath = Configuration.EU_REGION_BASE_PATH;
break;
}
case 'CA': {
this.basePath = Configuration.CA_REGION_BASE_PATH;
break;
}
case 'US':
default: {
this.basePath = Configuration.US_REGION_BASE_PATH;
break;
}
}
}
}
catch (error) {
this.basePath = Configuration.US_REGION_BASE_PATH;
}
this.enableLogging = logging ?? stringEquals(process.env[Configuration.BOLDSIGN_LOGGING], 'TRUE');
}
static getInstance() {
if (!Configuration.instance) {
const apiKey = process.env[Configuration.BOLDSIGN_API_KEY];
const region = process.env[Configuration.BOLDSIGN_API_REGION];
Configuration.instance = new Configuration(apiKey, region);
}
return Configuration.instance;
}
getBasePath() {
return this.basePath;
}
getApiKey() {
return this.apiKey;
}
isLoggingEnabled() {
return this.enableLogging;
}
}
export default Configuration;