Skip to main content
Glama

fetchUrlContent

Retrieves and parses content from a specified URL to extract text, enabling access to web-based information for knowledge management and analysis purposes.

Instructions

Fetches the content of a URL. Particularly useful for fetching parsed text file URLs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNo
tenantIdNo
urlYes

Implementation Reference

  • The handler function for the fetchUrlContent tool. It uses wretch to fetch content from the provided URL, applying optional Bearer token authentication and tenant ID header.
    async (params: FetchUrlContentParams) => { return safeApiCall(async () => { const { url, apiKey, tenantId } = params try { // Create a wretch client with authentication if provided let client = wretch(url) if (apiKey) { client = client.auth(`Bearer ${apiKey}`) } if (tenantId) { client = client.headers({ 'X-Tenant-ID': tenantId, }) } // Fetch the content from the URL const content = await client.get().text() return { content } } catch (error: any) { throw new Error(`Error fetching URL content: ${error.message}`) } }) },
  • Zod schema defining the input parameters for the fetchUrlContent tool: url (required string URL), optional apiKey and tenantId.
    export const FetchUrlContentSchema = z.object({ url: z.string().url(), // Authentication might be needed for some SourceSync URLs apiKey: apiKeySchema, tenantId: tenantIdSchema, }) export type FetchUrlContentParams = z.infer<typeof FetchUrlContentSchema>
  • src/index.ts:736-765 (registration)
    MCP server registration of the fetchUrlContent tool, including name, description, input schema, and handler function.
    'fetchUrlContent', 'Fetches the content of a URL. Particularly useful for fetching parsed text file URLs.', FetchUrlContentSchema.shape, async (params: FetchUrlContentParams) => { return safeApiCall(async () => { const { url, apiKey, tenantId } = params try { // Create a wretch client with authentication if provided let client = wretch(url) if (apiKey) { client = client.auth(`Bearer ${apiKey}`) } if (tenantId) { client = client.headers({ 'X-Tenant-ID': tenantId, }) } // Fetch the content from the URL const content = await client.get().text() return { content } } catch (error: any) { throw new Error(`Error fetching URL content: ${error.message}`) } }) }, )

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/pbteja1998/sourcesyncai-mcp'

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