list_watches
List active webhook watches associated with your TensorFeed token. Identify which event listeners are currently configured for real-time AI industry alerts.
Instructions
List the active webhook watches owned by the configured TensorFeed token. Free, requires TENSORFEED_TOKEN.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp-server/src/index.ts:775-806 (handler)The list_watches tool handler: fetches watches from /premium/watches endpoint, formats them into a readable text output, or returns 'No active watches.' if count is 0.
server.tool( 'list_watches', 'List the active webhook watches owned by the configured TensorFeed token. Free, requires TENSORFEED_TOKEN.', {}, async () => { const data = (await fetchJSON('/premium/watches', { auth: true })) as { count: number; watches: { id: string; spec: { type: string; model?: string; field?: string; op?: string; threshold?: number; provider?: string; value?: string }; callback_url: string; fire_count: number; fire_cap: number; expires_at: string; status: string; }[]; }; if (data.count === 0) { return { content: [{ type: 'text' as const, text: 'No active watches.' }] }; } const rows = data.watches .map(w => { const desc = w.spec.type === 'price' ? `${w.spec.model} ${w.spec.field} ${w.spec.op}${w.spec.threshold !== undefined ? ' ' + w.spec.threshold : ''}` : `${w.spec.provider} ${w.spec.op}${w.spec.value ? ' ' + w.spec.value : ''}`; return ` ${w.id} (${w.status}) [${w.spec.type}] ${desc}\n -> ${w.callback_url}\n fired ${w.fire_count}/${w.fire_cap}, expires ${w.expires_at}`; }) .join('\n\n'); return { content: [{ type: 'text' as const, text: `${data.count} active watches:\n\n${rows}` }] }; }, ); - mcp-server/src/index.ts:775-806 (registration)The tool is registered via server.tool('list_watches', ...) on the McpServer instance. Registration includes the tool name, description, empty schema (no parameters), and the handler function.
server.tool( 'list_watches', 'List the active webhook watches owned by the configured TensorFeed token. Free, requires TENSORFEED_TOKEN.', {}, async () => { const data = (await fetchJSON('/premium/watches', { auth: true })) as { count: number; watches: { id: string; spec: { type: string; model?: string; field?: string; op?: string; threshold?: number; provider?: string; value?: string }; callback_url: string; fire_count: number; fire_cap: number; expires_at: string; status: string; }[]; }; if (data.count === 0) { return { content: [{ type: 'text' as const, text: 'No active watches.' }] }; } const rows = data.watches .map(w => { const desc = w.spec.type === 'price' ? `${w.spec.model} ${w.spec.field} ${w.spec.op}${w.spec.threshold !== undefined ? ' ' + w.spec.threshold : ''}` : `${w.spec.provider} ${w.spec.op}${w.spec.value ? ' ' + w.spec.value : ''}`; return ` ${w.id} (${w.status}) [${w.spec.type}] ${desc}\n -> ${w.callback_url}\n fired ${w.fire_count}/${w.fire_cap}, expires ${w.expires_at}`; }) .join('\n\n'); return { content: [{ type: 'text' as const, text: `${data.count} active watches:\n\n${rows}` }] }; }, ); - mcp-server/src/index.ts:778-778 (schema)The schema for list_watches is an empty object {}, meaning the tool takes no input parameters.
{}, - mcp-server/src/index.ts:19-59 (helper)The fetchJSON helper function is used by the list_watches handler to make authenticated API calls to the TensorFeed API.
async function fetchJSON(path: string, opts: FetchOptions = {}): Promise<unknown> { const headers: Record<string, string> = { 'User-Agent': `TensorFeed-MCP/${SDK_VERSION}`, }; if (opts.body !== undefined) headers['Content-Type'] = 'application/json'; if (opts.auth) { const token = process.env.TENSORFEED_TOKEN; if (!token) { throw new Error( 'TENSORFEED_TOKEN env var is not set. Premium MCP tools require a bearer token. ' + 'Buy credits at https://tensorfeed.ai/developers/agent-payments and pass the returned tf_live_... token via the TENSORFEED_TOKEN env var in your MCP client config.', ); } headers['Authorization'] = `Bearer ${token}`; } const res = await fetch(`${API_BASE}${path}`, { method: opts.method ?? 'GET', headers, ...(opts.body !== undefined ? { body: JSON.stringify(opts.body) } : {}), }); if (!res.ok) { let errPayload: unknown; try { errPayload = await res.json(); } catch { errPayload = await res.text().catch(() => ''); } if (res.status === 402) { throw new Error( `Payment required (402). Your token may be out of credits. Top up at https://tensorfeed.ai/developers/agent-payments. Detail: ${JSON.stringify(errPayload)}`, ); } if (res.status === 401) { throw new Error( `Token rejected (401). Check that TENSORFEED_TOKEN is set to a valid tf_live_... token. Detail: ${JSON.stringify(errPayload)}`, ); } throw new Error(`API error ${res.status}: ${JSON.stringify(errPayload)}`); } return res.json(); }