Skip to main content
Glama
site-export.js1.34 kB
import { presearchService } from "../services/presearchService.js"; import { contentFetcher } from "../services/contentFetcher.js"; export const siteExportTool = { name: "presearch_site_export", description: "Advanced tool to search, scrape, and format content from a specific site or topic for export.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query" }, format: { type: "string", enum: ["json", "markdown"], default: "markdown", }, }, required: ["query"], }, execute: async (args) => { // 1. Search const searchResults = await presearchService.search(args.query, { limit: 5, }); // 2. Scrape const urls = searchResults.results.map((r) => r.url); const contents = await Promise.all( urls.map((url) => contentFetcher.fetchContent(url)), ); // 3. Format let output; if (args.format === "json") { output = JSON.stringify(contents, null, 2); } else { output = contents .map( (c) => `# ${c.title}\nSource: ${c.url}\n\n${c.content?.substring(0, 1000)}...\n\n---\n`, ) .join("\n"); } return { content: [ { type: "text", text: output, }, ], }; }, };

Latest Blog Posts

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/NosytLabs/presearch-search-api-mcp'

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