Skip to main content
Glama
getrupt

Ashra Structured Data Extractor MCP

by getrupt
utils.ts1.15 kB
import { getUserAgent } from "universal-user-agent"; import { createAshraError } from "./errors.js"; const USER_AGENT = `modelcontextprotocol/servers/ashra/v1 ${getUserAgent()}`; type RequestOptions = { method?: string; body?: unknown; headers?: Record<string, string>; } async function parseResponseBody(response: Response): Promise<unknown> { const contentType = response.headers.get("content-type"); if (contentType?.includes("application/json")) { return response.json(); } return response.text(); } export async function ashraRequest( url: string, options: RequestOptions = {} ): Promise<unknown> { const headers: Record<string, string> = { "Accept": "application/vnd.ashra.v1+json", "Content-Type": "application/json", "User-Agent": USER_AGENT, ...options.headers, }; const response = await fetch(url, { method: options.method || "GET", headers, body: options.body ? JSON.stringify(options.body) : undefined, }); const responseBody = await parseResponseBody(response); if (!response.ok) { throw createAshraError(response.status, responseBody); } return responseBody; }

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/getrupt/ashra-mcp'

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