list_projects
Retrieve a list of all projects in your organization, including status, competitor count, and last monitored timestamp. Use this to obtain projectId values needed for other tools.
Instructions
List all projects in your organization with status, competitor count, and last monitored timestamp. Start here — call this first to discover available projectId values required by all other tools. Read-only. Returns JSON array of projects.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:30-36 (registration)Registration of the 'list_projects' tool as a ToolDef entry in the tools array. It has no parameters, an empty zod object schema, and maps to GET /v1/projects.
{ name: "list_projects", description: "List all projects in your organization with status, competitor count, and last monitored timestamp. Start here — call this first to discover available projectId values required by all other tools. Read-only. Returns JSON array of projects.", parameters: z.object({}), path: () => "/v1/projects", }, - src/tools.ts:28-36 (schema)The 'list_projects' tool definition including its empty parameters schema (z.object({})).
export const tools: ToolDef[] = [ // ── Projects ────────────────────────────────────────────── { name: "list_projects", description: "List all projects in your organization with status, competitor count, and last monitored timestamp. Start here — call this first to discover available projectId values required by all other tools. Read-only. Returns JSON array of projects.", parameters: z.object({}), path: () => "/v1/projects", }, - src/index.ts:16-25 (handler)Generic handler loop that registers and executes all tools (including list_projects) on the MCP server. The handler calls tool.path(args) to get the API endpoint, builds query params, and calls apiGet.
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:3-58 (helper)The apiGet helper function that makes HTTP GET requests to the CompetLab API with the CL-API-Key header. Used by all tool handlers to fetch data.
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, }; } }