get_competitor
Access competitor details including monitored homepage and pricing URLs. Get specific metadata beyond basic list. Requires projectId and competitorId. Returns JSON object.
Instructions
Get competitor details including monitored pages (homepage URL, pricing page URL) and configuration. Use this when you need specific competitor metadata beyond what list_competitors provides — for example, to find which URLs are being tracked. Requires competitorId from list_competitors. Read-only. Returns JSON object.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID (from list_projects) | |
| competitorId | Yes | Competitor ID (from list_competitors) |
Implementation Reference
- src/tools.ts:57-66 (registration)Tool registration entry for 'get_competitor' in the tools array. Defines name, description, Zod schema (projectId, competitorId), and path template (/v1/projects/{projectId}/competitors/{competitorId}).
{ name: "get_competitor", description: "Get competitor details including monitored pages (homepage URL, pricing page URL) and configuration. Use this when you need specific competitor metadata beyond what list_competitors provides — for example, to find which URLs are being tracked. Requires competitorId from list_competitors. Read-only. Returns JSON object.", parameters: z.object({ projectId: objectId("Project ID (from list_projects)"), competitorId: objectId("Competitor ID (from list_competitors)"), }), path: (a) => `/v1/projects/${a.projectId}/competitors/${a.competitorId}`, }, - src/index.ts:16-25 (handler)Generic handler that iterates all tool definitions (including get_competitor) and calls the CompetLab API via apiGet using the tool's path and query parameters.
for (const tool of tools) { server.tool(tool.name, tool.description, tool.parameters.shape, async (args: Record<string, any>) => { const path = tool.path(args); const query: Record<string, any> = {}; for (const key of tool.queryParams ?? []) { if (args[key] !== undefined) query[key] = args[key]; } return apiGet(path, Object.keys(query).length ? query : undefined); }); } - src/api-client.ts:1-58 (helper)The apiGet helper function that makes authenticated HTTP GET requests to the CompetLab API (https://api.competlab.com) for all tools including get_competitor.
const API_BASE = "https://api.competlab.com"; export async function apiGet( path: string, query?: Record<string, string | number>, ): Promise<{ content: Array<{ type: "text"; text: string }>; isError?: true }> { const apiKey = process.env.COMPETLAB_API_KEY; if (!apiKey) { return { content: [ { type: "text", text: JSON.stringify({ error: "api_key_missing", message: "COMPETLAB_API_KEY environment variable is not set", }), }, ], isError: true, }; } const url = new URL(`${API_BASE}${path}`); if (query) { for (const [k, v] of Object.entries(query)) { if (v !== undefined) url.searchParams.set(k, String(v)); } } try { const res = await fetch(url, { headers: { "CL-API-Key": apiKey }, }); const body = await res.text(); if (!res.ok) { return { content: [{ type: "text", text: body }], isError: true }; } return { content: [{ type: "text", text: body }] }; } catch (err) { return { content: [ { type: "text", text: JSON.stringify({ error: "api_unreachable", message: err instanceof Error ? err.message : "Failed to reach CompetLab API", status: 503, }), }, ], isError: true, }; } }