Jake Shore f3c4cd817b Add all MCP servers + factory infra to MCPEngine — 2026-02-06
=== NEW SERVERS ADDED (7) ===
- servers/closebot — 119 tools, 14 modules, 4,656 lines TS (Stage 7)
- servers/google-console — Google Search Console MCP (Stage 7)
- servers/meta-ads — Meta/Facebook Ads MCP (Stage 8)
- servers/twilio — Twilio communications MCP (Stage 8)
- servers/competitor-research — Competitive intel MCP (Stage 6)
- servers/n8n-apps — n8n workflow MCP apps (Stage 6)
- servers/reonomy — Commercial real estate MCP (Stage 1)

=== FACTORY INFRASTRUCTURE ADDED ===
- infra/factory-tools — mcp-jest, mcp-validator, mcp-add, MCP Inspector
  - 60 test configs, 702 auto-generated test cases
  - All 30 servers score 100/100 protocol compliance
- infra/command-center — Pipeline state, operator playbook, dashboard config
- infra/factory-reviews — Automated eval reports

=== DOCS ADDED ===
- docs/MCP-FACTORY.md — Factory overview
- docs/reports/ — 5 pipeline evaluation reports
- docs/research/ — Browser MCP research

=== RULES ESTABLISHED ===
- CONTRIBUTING.md — All MCP work MUST go in this repo
- README.md — Full inventory of 37 servers + infra docs
- .gitignore — Updated for Python venvs

TOTAL: 37 MCP servers + full factory pipeline in one repo.
This is now the single source of truth for all MCP work.
2026-02-06 06:32:29 -05:00

88 lines
2.6 KiB
TypeScript

/**
* Smart Twilio SDK wrapper with retry, rate limiting, and error normalization.
*/
import Twilio from 'twilio';
import type { TwilioCredentials } from './auth.js';
export class TwilioClient {
private client: ReturnType<typeof Twilio>;
private credentials: TwilioCredentials;
constructor(credentials: TwilioCredentials) {
this.credentials = credentials;
this.client = Twilio(credentials.apiKey, credentials.apiSecret, {
accountSid: credentials.accountSid,
});
}
/** Get the raw Twilio client for direct SDK access */
get raw() {
return this.client;
}
get accountSid() {
return this.credentials.accountSid;
}
/**
* Execute a Twilio API call with retry logic and error normalization.
*/
async execute<T>(
operation: (client: ReturnType<typeof Twilio>) => Promise<T>,
options: { retries?: number; retryDelay?: number } = {}
): Promise<T> {
const { retries = 2, retryDelay = 1000 } = options;
let lastError: Error | undefined;
for (let attempt = 0; attempt <= retries; attempt++) {
try {
return await operation(this.client);
} catch (err: any) {
lastError = err;
// Don't retry on auth errors or client errors
if (err.status && err.status >= 400 && err.status < 500 && err.status !== 429) {
throw this.normalizeError(err);
}
// Rate limited — wait and retry
if (err.status === 429 && attempt < retries) {
const delay = retryDelay * Math.pow(2, attempt);
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
// Server error — retry
if (err.status && err.status >= 500 && attempt < retries) {
await new Promise(resolve => setTimeout(resolve, retryDelay));
continue;
}
throw this.normalizeError(err);
}
}
throw this.normalizeError(lastError!);
}
private normalizeError(err: any): Error {
if (err.code && err.message) {
return new Error(`Twilio Error ${err.code}: ${err.message}${err.moreInfo ? ` (${err.moreInfo})` : ''}`);
}
return err instanceof Error ? err : new Error(String(err));
}
/**
* Validate that credentials work by fetching account info.
*/
async validateCredentials(): Promise<{ valid: boolean; accountName?: string; error?: string }> {
try {
const account = await this.client.api.accounts(this.credentials.accountSid).fetch();
return { valid: true, accountName: account.friendlyName };
} catch (err: any) {
return { valid: false, error: this.normalizeError(err).message };
}
}
}