get_tech_trust_run_detail
Retrieve historical Tech & Trust data for a specific run. Compare competitor-by-competitor metrics to investigate changes between monitoring cycles or audit past results.
Instructions
Get full competitor-by-competitor Tech & Trust data for a specific historical run. Returns the same data structure as get_tech_trust_dashboard but for a past point in time. Use this to investigate what changed between runs or to audit a specific monitoring cycle. Requires runId from get_tech_trust_history. Read-only. Returns JSON object.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID (from list_projects) | |
| runId | Yes | Run ID (from get_tech_trust_history) |
Implementation Reference
- src/tools.ts:114-123 (schema)Schema and path definition for the 'get_tech_trust_run_detail' tool. Defines parameters (projectId, runId) and the API path used to retrieve historical Tech & Trust run data.
{ name: "get_tech_trust_run_detail", description: "Get full competitor-by-competitor Tech & Trust data for a specific historical run. Returns the same data structure as get_tech_trust_dashboard but for a past point in time. Use this to investigate what changed between runs or to audit a specific monitoring cycle. Requires runId from get_tech_trust_history. Read-only. Returns JSON object.", parameters: z.object({ projectId: objectId("Project ID (from list_projects)"), runId: objectId("Run ID (from get_tech_trust_history)"), }), path: (a) => `/v1/projects/${a.projectId}/tech-trust/history/${a.runId}`, }, - src/index.ts:16-25 (registration)Generic tool registration loop that registers all tools (including get_tech_trust_run_detail) from the tools array onto the MCP server, dynamically building path and query params.
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/index.ts:17-24 (handler)Generic handler function that executes the tool logic by calling the API with the constructed path and query parameters; this is the same handler used by all tools including get_tech_trust_run_detail.
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)API client helper (apiGet) that performs the actual HTTP GET request to the CompetLab API. Called by the generic handler to fetch data for all tools including get_tech_trust_run_detail.
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, }; } }