-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathagent-last-used.ts
More file actions
46 lines (42 loc) · 1.26 KB
/
agent-last-used.ts
File metadata and controls
46 lines (42 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* MONITORING_AGENT_LAST_USED Tool
*
* Returns the last time each agent (Virtual MCP) was used,
* based on monitoring logs. Useful for identifying stale agents.
*/
import { requireOrganization } from "@/core/mesh-context";
import { defineTool } from "../../core/define-tool";
import { z } from "zod";
export const MONITORING_AGENT_LAST_USED = defineTool({
name: "MONITORING_AGENT_LAST_USED",
description:
"Get the last usage timestamp for each agent (Virtual MCP), derived from monitoring logs",
annotations: {
title: "Get Agent Last Used",
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
inputSchema: z.object({
virtualMcpIds: z
.array(z.string())
.max(500)
.describe("List of Virtual MCP (Agent) IDs to check"),
}),
outputSchema: z.object({
lastUsed: z
.record(z.string(), z.string())
.describe(
"Map of virtualMcpId to last used ISO 8601 timestamp. Missing keys mean the agent was never used.",
),
}),
handler: async (input, ctx) => {
const org = requireOrganization(ctx);
const lastUsed = await ctx.storage.monitoring.getLastUsedByVirtualMcpIds(
org.id,
input.virtualMcpIds,
);
return { lastUsed };
},
});