query_traces
Search recent traces from AgentGuard-instrumented agents using filters for service name, time range, and pagination.
Instructions
Search recent traces from your AgentGuard-instrumented agents. Filter by service name, time range, or paginate through results.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max traces to return (default 20, max 500) | |
| offset | No | Offset for pagination | |
| service | No | Filter by service name | |
| since | No | ISO timestamp — only traces after this time | |
| until | No | ISO timestamp — only traces before this time |
Implementation Reference
- mcp-server/src/tools.ts:31-40 (handler)The handler function for the 'query_traces' tool. Calls client.getTraces() with optional filter parameters and returns the JSON-stringified result.
handler: async (client, args) => { const result = await client.getTraces({ limit: args.limit ? String(args.limit) : "20", offset: args.offset ? String(args.offset) : undefined, service: args.service as string | undefined, since: args.since as string | undefined, until: args.until as string | undefined, }); return JSON.stringify(result, null, 2); }, - mcp-server/src/tools.ts:21-30 (schema)Input schema for the 'query_traces' tool, defining optional parameters: limit, offset, service, since, until.
inputSchema: { type: "object", properties: { limit: { type: "number", description: "Max traces to return (default 20, max 500)" }, offset: { type: "number", description: "Offset for pagination" }, service: { type: "string", description: "Filter by service name" }, since: { type: "string", description: "ISO timestamp — only traces after this time" }, until: { type: "string", description: "ISO timestamp — only traces before this time" }, }, }, - mcp-server/src/tools.ts:16-41 (registration)Registration of 'query_traces' as a ToolDefinition in the tools array, with name and description.
{ name: "query_traces", description: "Search recent traces from your AgentGuard-instrumented agents. " + "Filter by service name, time range, or paginate through results.", inputSchema: { type: "object", properties: { limit: { type: "number", description: "Max traces to return (default 20, max 500)" }, offset: { type: "number", description: "Offset for pagination" }, service: { type: "string", description: "Filter by service name" }, since: { type: "string", description: "ISO timestamp — only traces after this time" }, until: { type: "string", description: "ISO timestamp — only traces before this time" }, }, }, handler: async (client, args) => { const result = await client.getTraces({ limit: args.limit ? String(args.limit) : "20", offset: args.offset ? String(args.offset) : undefined, service: args.service as string | undefined, since: args.since as string | undefined, until: args.until as string | undefined, }); return JSON.stringify(result, null, 2); }, }, - mcp-server/src/client.ts:39-47 (helper)The getTraces helper method on AgentGuardClient that makes the HTTP GET request to /api/v1/traces with optional query params.
async getTraces(opts?: { limit?: string; offset?: string; service?: string; since?: string; until?: string; }) { return this.fetch<{ traces: unknown[] }>("/api/v1/traces", opts); }