markdown
Convert web page URLs into clean, structured markdown format for content extraction and documentation purposes.
Instructions
Convert a URL to clean markdown. Costs 2 credits.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to convert to markdown |
Implementation Reference
- src/index.ts:129-129 (handler)The handler function for the markdown tool - takes a URL parameter and calls the API POST /markdown endpoint, wrapping the result with jsonResult
async ({ url }) => jsonResult(await apiPost("/markdown", { url })) - src/index.ts:125-130 (registration)Registration of the markdown tool with the MCP server using server.tool() - defines name, description, schema, and handler
server.tool( "markdown", "Convert a URL to clean markdown. Costs 2 credits.", { url: z.string().describe("URL to convert to markdown") }, async ({ url }) => jsonResult(await apiPost("/markdown", { url })) ); - src/index.ts:128-128 (schema)Input schema definition for markdown tool - requires a url parameter as a string with description
{ url: z.string().describe("URL to convert to markdown") }, - src/index.ts:41-59 (helper)Helper function apiPost that makes POST requests to the SearchClaw API - handles headers, JSON body, timeout, and error responses
async function apiPost(path: string, body: Record<string, unknown>) { const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), 30000); try { const response = await fetch(`${API_BASE}${path}`, { method: "POST", headers: { ...headers, "Content-Type": "application/json" }, body: JSON.stringify(body), signal: controller.signal, }); if (!response.ok) { const text = await response.text(); throw new Error(`SearchClaw API error ${response.status}: ${text}`); } return response.json(); } finally { clearTimeout(timeout); } } - src/index.ts:61-63 (helper)Helper function jsonResult that formats API responses into MCP content format - converts data to JSON string with formatting
function jsonResult(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; }