check-status
Verify URL accessibility by sending a HEAD request to check its status. Configure timeout settings to manage response delays and ensure the URL is reachable.
Instructions
Check if a URL is accessible (HEAD request)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeout | No | Request timeout in milliseconds | |
| url | Yes | URL to check |
Implementation Reference
- src/index.ts:381-429 (handler)Main handler function that executes a HEAD request to check URL accessibility, returning status, headers, final URL, and availability status.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}` } ] }; } }
- src/index.ts:38-41 (schema)Zod schema for input validation of check-status tool arguments.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 for listTools handler, 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:163-164 (registration)Registration of check-status handler in the tools/call request switch statement.case "check-status": return handleCheckStatus(CheckStatusArgsSchema.parse(args));
- src/index.ts:46-46 (schema)TypeScript type definition inferred from the Zod schema for check-status arguments.type CheckStatusArgs = z.infer<typeof CheckStatusArgsSchema>;