check-status
Verify URL accessibility by performing HEAD requests to check if web resources are reachable and responsive.
Instructions
Check if a URL is accessible (HEAD request)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to check | |
| timeout | No | Request timeout in milliseconds |
Implementation Reference
- src/index.ts:381-431 (handler)The handler function that executes the check-status tool logic: sends a HEAD request to the URL and returns status information, headers, and availability.async function handleCheckStatus(args: CheckStatusArgs): Promise<z.infer<typeof CallToolResultSchema>> { try { const { url, timeout } = args; console.error(`Checking status of ${url}`); // Create request options const options: any = { method: "HEAD", }; if (timeout) { // @ts-ignore - undici specific options options.headersTimeout = timeout; } // Perform the request const response = await fetch(url, options); // Create a result object const result = { status: response.status, statusText: response.statusText, headers: Object.fromEntries(response.headers.entries()), url: response.url, isAvailable: response.ok, }; return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { console.error(`Error checking URL status:`, error); return { isError: true, content: [ { type: "text", text: `Error checking URL status: ${(error as Error).message}` } ] }; } } // Start the server using stdio transport
- src/index.ts:38-41 (schema)Zod schema used for input validation in the check-status handler.const CheckStatusArgsSchema = z.object({ url: z.string().url().describe("URL to check"), timeout: z.number().positive().optional().describe("Request timeout in milliseconds") });
- src/index.ts:120-131 (registration)Tool registration in the TOOLS array, defining name, description, and JSON input schema.{ name: "check-status", description: "Check if a URL is accessible (HEAD request)", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to check" }, timeout: { type: "number", description: "Request timeout in milliseconds" } }, required: ["url"] } }
- src/index.ts:46-46 (schema)TypeScript type definition for check-status arguments inferred from the Zod schema.type CheckStatusArgs = z.infer<typeof CheckStatusArgsSchema>;
- src/index.ts:163-164 (registration)Dispatch case in the CallToolRequestSchema handler that routes to the check-status handler.case "check-status": return handleCheckStatus(CheckStatusArgsSchema.parse(args));