Skip to main content
Glama
fetch.ts1.43 kB
import { getFromCache, decodeContentHandle } from "../lib/cache.js"; interface FetchFullContentParams { contentHandle: string; outputFormat?: "markdown" | "text" | "html"; } interface FetchResult { url: string; title: string; markdown?: string; text?: string; html?: string; contentLength?: number; cached?: boolean; error?: string; } export async function fetchFullContent( params: FetchFullContentParams ): Promise<FetchResult> { const { contentHandle, outputFormat = "markdown" } = params; const url = decodeContentHandle(contentHandle); if (!url) { return { url: "", title: "", error: "Invalid contentHandle format. Ensure it was generated by rag() tool.", }; } const cached = getFromCache(url); if (!cached) { return { url, title: "", error: `Content not found in cache. Cache TTL is 1 hour. Please run rag() again to re-fetch and cache the content.`, }; } const result: FetchResult = { url: cached.url, title: cached.title, cached: true, contentLength: outputFormat === "markdown" ? cached.markdown.length : cached.content.length, }; if (outputFormat === "markdown") { result.markdown = cached.markdown; } else if (outputFormat === "text") { result.text = cached.content; } else if (outputFormat === "html") { result.html = cached.content; } return result; }

Implementation Reference

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/alucardeht/isis-mcp'

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