vs_monitors_check_now
Immediately trigger a monitor check and receive the fresh result, complementing the scheduled cadence.
Instructions
Trigger an immediate check for a monitor (in addition to its scheduled cadence). Returns the freshly-collected check result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Monitor id. |
Implementation Reference
- src/tools.ts:255-257 (handler)The handler function that triggers an immediate check for a monitor by sending a POST request to /api/monitors/{id}/check
handler: async (args, client) => client.request('POST', `/api/monitors/${encodeURIComponent(requireString(args, 'id'))}/check`), }, - src/tools.ts:246-253 (schema)Input schema for vs_monitors_check_now: requires a string 'id' parameter
inputSchema: { type: 'object', properties: { id: { ...STR, description: 'Monitor id.' }, }, required: ['id'], additionalProperties: false, }, - src/tools.ts:242-257 (registration)Tool registration entry in the TOOLS array with name, description, schema, auth requirement, and handler
{ name: 'vs_monitors_check_now', description: 'Trigger an immediate check for a monitor (in addition to its scheduled cadence). Returns the freshly-collected check result.', inputSchema: { type: 'object', properties: { id: { ...STR, description: 'Monitor id.' }, }, required: ['id'], additionalProperties: false, }, requiresAuth: true, handler: async (args, client) => client.request('POST', `/api/monitors/${encodeURIComponent(requireString(args, 'id'))}/check`), }, - src/tools.ts:42-46 (helper)Helper function that validates and extracts a required string argument from the input args
function requireString(args: Record<string, unknown>, key: string): string { const v = pickString(args, key); if (!v) throw new Error(`Argument "${key}" (string) is required.`); return v; } - src/api-client.ts:51-105 (helper)Core HTTP client request method used by the handler to POST to the API endpoint
async request<T = unknown>( method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, options: { query?: Record<string, string | number | boolean | undefined>; body?: unknown; auth?: boolean } = {}, ): Promise<T> { const auth = options.auth ?? true; if (auth && !this.hasApiKey()) { throw new VsApiError( 'Visual Sentinel API key required. Set VS_API_KEY (https://visualsentinel.com/settings/api-keys).', 401, null, ); } const url = new URL(path.startsWith('/') ? path : `/${path}`, this.baseUrl); if (options.query) { for (const [k, v] of Object.entries(options.query)) { if (v !== undefined && v !== null) url.searchParams.set(k, String(v)); } } const headers: Record<string, string> = { Accept: 'application/json', 'User-Agent': this.userAgent, }; if (auth && this.apiKey) headers['X-API-Key'] = this.apiKey; if (options.body !== undefined) headers['Content-Type'] = 'application/json'; const res = await fetch(url, { method, headers, body: options.body !== undefined ? JSON.stringify(options.body) : undefined, }); const text = await res.text(); let parsed: unknown = null; if (text.length > 0) { try { parsed = JSON.parse(text); } catch { parsed = text; } } if (!res.ok) { throw new VsApiError( `Visual Sentinel API ${method} ${path} returned ${res.status}`, res.status, parsed, ); } return parsed as T; } }