getIncidentSample
Fetch a specific sample from an AppSignal incident using the incident number and sample ID to analyze and troubleshoot monitoring issues.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| incidentNumber | Yes | ||
| sampleId | No |
Implementation Reference
- src/mcp/server.ts:144-172 (registration)Registration of the 'getIncidentSample' MCP tool, including input schema and thin wrapper handler that delegates to AppSignalClient.getIncidentSample and returns JSON.this.server.tool( 'getIncidentSample', { incidentNumber: z.number().int().positive(), sampleId: z.string().optional(), }, async ({ incidentNumber, sampleId }) => { try { const sample = await this.client.getIncidentSample(incidentNumber, sampleId); return { content: [{ type: 'text', text: JSON.stringify(sample, null, 2), }], }; } catch (error) { if (error instanceof Error) { return { content: [{ type: 'text', text: `Error fetching incident sample: ${error.message}`, }], isError: true, }; } throw error; } } );
- src/appsignal/client.ts:143-203 (handler)Primary handler logic in AppSignalClient that executes GraphQL query to retrieve the incident sample from AppSignal API.async getIncidentSample(incidentNumber: number, sampleId?: string): Promise<Sample> { const query = ` query IncidentSampleQuery($appId: String!, $incidentNumber: Int!, $sampleId: String) { app(id: $appId) { id incident(incidentNumber: $incidentNumber) { ... on ExceptionIncident { sample(id: $sampleId) { id appId time revision action namespace overview { key value } exception { name message backtrace { original line column path method url type code { line source } error { class message } } } } } } } } `; const result = await this.executeQuery<{ app: { id: string; incident: { sample: Sample; }; }; }>(query, { appId: this.appId, incidentNumber, sampleId, }); return result.app.incident.sample; }
- src/appsignal/client.ts:22-54 (schema)Zod schema defining the structure of Sample data used for typing the response from getIncidentSample.export const SampleSchema = z.object({ id: z.string(), appId: z.string(), time: z.string(), revision: z.string().optional(), action: z.string(), namespace: z.string(), overview: z.array(z.object({ key: z.string(), value: z.string(), })), exception: z.object({ name: z.string(), message: z.string(), backtrace: z.array(z.object({ original: z.string().optional(), line: z.number().optional(), column: z.number().optional(), path: z.string().optional(), method: z.string().optional(), url: z.string().optional(), type: z.string().optional(), code: z.object({ line: z.number().optional(), source: z.string().optional(), }).optional(), error: z.object({ class: z.string().optional(), message: z.string().optional(), }).optional(), })), }), });
- src/mcp/server.ts:146-149 (schema)Input schema (Zod) for the getIncidentSample MCP tool parameters: incidentNumber (required positive int) and optional sampleId.{ incidentNumber: z.number().int().positive(), sampleId: z.string().optional(), },