Skip to main content
Glama

Exa MCP Server

by joerup
formatters.ts4.26 kB
/** * Formatters for Exa search results */ /** * Format search results for display */ export function formatSearchResults(results: any[]): string { if (!results || results.length === 0) { return 'No results found.'; } return results.map((result, index) => { const parts = [`${index + 1}. **${result.title}**`]; if (result.url) { parts.push(` URL: ${result.url}`); } if (result.publishedDate) { parts.push(` Published: ${result.publishedDate}`); } if (result.author) { parts.push(` Author: ${result.author}`); } if (result.score) { parts.push(` Relevance: ${(result.score * 100).toFixed(1)}%`); } if (result.summary) { parts.push(` Summary: ${result.summary}`); } if (result.highlights && result.highlights.length > 0) { parts.push(' Highlights:'); result.highlights.forEach((h: string) => parts.push(` - ${h}`)); } if (result.text) { const preview = result.text.substring(0, 200).trim(); parts.push(` Preview: ${preview}${result.text.length > 200 ? '...' : ''}`); } return parts.join('\n'); }).join('\n\n'); } /** * Format company research results */ export function formatCompanyResults(results: any): string { const sections = []; if (results.overview) { sections.push('## Company Overview\n' + formatSearchResults(results.overview)); } if (results.news) { sections.push('## Recent News\n' + formatSearchResults(results.news)); } if (results.competitors) { sections.push('## Competitors\n' + formatSearchResults(results.competitors)); } if (results.reviews) { sections.push('## Reviews & Feedback\n' + formatSearchResults(results.reviews)); } return sections.join('\n\n---\n\n'); } /** * Format LinkedIn search results */ export function formatLinkedInResults(results: any): string { const sections = []; if (results.people) { sections.push('## LinkedIn Profiles\n' + formatSearchResults(results.people)); } if (results.companies) { sections.push('## LinkedIn Companies\n' + formatSearchResults(results.companies)); } return sections.join('\n\n---\n\n'); } /** * Format deep research results */ export function formatDeepResearchResults(results: any): string { if (!results) { return 'No results available yet.'; } const sections = [`# Research Summary\n${results.summary}\n`]; if (results.sections) { results.sections.forEach((section: any) => { sections.push(`## ${section.title}`); sections.push(`Query: "${section.query}"`); sections.push(formatSearchResults(section.results)); }); } return sections.join('\n\n'); } /** * Format crawling results */ export function formatCrawlResults(results: any[]): string { if (!results || results.length === 0) { return 'No content extracted.'; } return results.map((result, index) => { const parts = [`${index + 1}. **${result.title || result.url}**`]; if (result.url) { parts.push(` URL: ${result.url}`); } if (result.summary) { parts.push(` Summary: ${result.summary}`); } if (result.highlights && result.highlights.length > 0) { parts.push(' Key Points:'); result.highlights.forEach((h: string) => parts.push(` - ${h}`)); } if (result.text) { const preview = result.text.substring(0, 500).trim(); parts.push(` Content: ${preview}${result.text.length > 500 ? '...' : ''}`); } return parts.join('\n'); }).join('\n\n'); } /** * Format error messages */ export function formatError(error: any): string { if (error.code) { return `Error [${error.code}]: ${error.message}`; } return `Error: ${error.message || 'An unexpected error occurred'}`; }

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/joerup/exa-mcp'

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