mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Co-authored-by: Prasanna <106952318+Prasanna721@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: ved015 <vedant.04.mahajan@gmail.com> Co-authored-by: ved015 <ved015@users.noreply.github.com> Co-authored-by: Ishaan Gupta <ishaankone@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { z } from "zod"
|
|
import { appToolMeta } from "../app-metadata"
|
|
import { optionalContainerTagSchema } from "../container-tag"
|
|
import { READ_ONLY_TOOL_ANNOTATIONS } from "./annotations"
|
|
import type { ToolDeps } from "./types"
|
|
|
|
export function register(deps: ToolDeps) {
|
|
deps.server.registerTool(
|
|
"fetch-graph-data",
|
|
{
|
|
description: "Fetch documents with memories for graph display",
|
|
inputSchema: z.object({
|
|
containerTag: optionalContainerTagSchema,
|
|
page: z.number().optional().default(1),
|
|
limit: z.number().optional().default(200),
|
|
}),
|
|
annotations: READ_ONLY_TOOL_ANNOTATIONS,
|
|
_meta: appToolMeta(["app"]),
|
|
},
|
|
async (args) => {
|
|
try {
|
|
const effectiveTag = await deps.resolveContainerTag(args.containerTag)
|
|
const client = deps.getClient(effectiveTag)
|
|
const containerTags = effectiveTag ? [effectiveTag] : undefined
|
|
const data = await client.getDocuments(
|
|
containerTags,
|
|
args.page,
|
|
args.limit,
|
|
)
|
|
|
|
return {
|
|
content: [{ type: "text" as const, text: JSON.stringify(data) }],
|
|
structuredContent: data,
|
|
}
|
|
} catch (error) {
|
|
return deps.errorResult(error)
|
|
}
|
|
},
|
|
)
|
|
}
|