Skip to content

Commit a8b6f5e

Browse files
add tool
1 parent c559887 commit a8b6f5e

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/tools/memory.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,35 @@ export const exploreMemorySnapshot = defineTool({
5656
response.setHeapSnapshotStats(stats, staticData);
5757
},
5858
});
59+
60+
export const getMemorySnapshotDetails = defineTool({
61+
name: 'get_memory_snapshot_details',
62+
description:
63+
'Loads a memory heapsnapshot and returns all available information including statistics, static data, and aggregated node information. Supports pagination for aggregates.',
64+
annotations: {
65+
category: ToolCategory.MEMORY,
66+
readOnlyHint: true,
67+
conditions: ['experimentalMemory'],
68+
},
69+
schema: {
70+
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
71+
pageIdx: zod
72+
.number()
73+
.optional()
74+
.describe('The page index for pagination of aggregates.'),
75+
pageSize: zod
76+
.number()
77+
.optional()
78+
.describe('The page size for pagination of aggregates.'),
79+
},
80+
handler: async (request, response, context) => {
81+
const aggregates = await context.getHeapSnapshotAggregates(
82+
request.params.filePath,
83+
);
84+
85+
response.setHeapSnapshotAggregates(aggregates, {
86+
pageIdx: request.params.pageIdx,
87+
pageSize: request.params.pageSize,
88+
});
89+
},
90+
});

0 commit comments

Comments
 (0)