Skip to main content
Glama

MCP Database Server

by JuanYin1
MIT License
3,221
1
  • Apple
  • Linux
formatUtils.ts1.58 kB
/** * Convert data to CSV format * @param data Array of objects to convert to CSV * @returns CSV formatted string */ export function convertToCSV(data: any[]): string { if (data.length === 0) return ''; // Get headers const headers = Object.keys(data[0]); // Create CSV header row let csv = headers.join(',') + '\n'; // Add data rows data.forEach(row => { const values = headers.map(header => { const val = row[header]; // Handle strings with commas, quotes, etc. if (typeof val === 'string') { return `"${val.replace(/"/g, '""')}"`; } // Use empty string for null/undefined return val === null || val === undefined ? '' : val; }); csv += values.join(',') + '\n'; }); return csv; } /** * Format error response * @param error Error object or message * @returns Formatted error response object */ export function formatErrorResponse(error: Error | string): { content: Array<{type: string, text: string}>, isError: boolean } { const message = error instanceof Error ? error.message : error; return { content: [{ type: "text", text: JSON.stringify({ error: message }, null, 2) }], isError: true }; } /** * Format success response * @param data Data to format * @returns Formatted success response object */ export function formatSuccessResponse(data: any): { content: Array<{type: string, text: string}>, isError: boolean } { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], isError: false }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JuanYin1/mcp-database-server-with-database'

If you have feedback or need assistance with the MCP directory API, please join our Discord server