mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
fix(mcp): return graph view message from fetch-graph-data
fetch-graph-data returned raw DocumentsApiResponse as structuredContent, which the widget cannot dispatch on, rendering "Received unrecognized response from server" despite the call succeeding. It now returns a proper graph ViewMessage so the widget renders the memory graph.
This commit is contained in:
parent
f7fc662f15
commit
b3567989f5
1 changed files with 17 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { registerAppTool } from "@modelcontextprotocol/ext-apps/server"
|
||||
import { z } from "zod"
|
||||
import { SUPERMEMORY_RESOURCE_URI } from "../../shared/types"
|
||||
import { SUPERMEMORY_RESOURCE_URI, type ViewMessage } from "../../shared/types"
|
||||
import type { ToolDeps } from "./types"
|
||||
|
||||
export function register(deps: ToolDeps) {
|
||||
|
|
@ -44,9 +44,23 @@ export function register(deps: ToolDeps) {
|
|||
args.limit,
|
||||
)
|
||||
|
||||
// structuredContent must be a ViewMessage — the widget dispatches on
|
||||
// `view` and renders anything else as an "unrecognized response" error.
|
||||
const sc: ViewMessage = {
|
||||
view: "graph",
|
||||
containerTag: effectiveTag,
|
||||
documents: data.documents,
|
||||
totalCount: data.pagination.totalItems,
|
||||
}
|
||||
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(data) }],
|
||||
structuredContent: data,
|
||||
content: [
|
||||
{
|
||||
type: "text" as const,
|
||||
text: `Fetched ${data.documents.length} documents (page ${data.pagination.currentPage} of ${data.pagination.totalPages}, ${data.pagination.totalItems} total)${effectiveTag ? `. Workspace: ${effectiveTag}` : ""}`,
|
||||
},
|
||||
],
|
||||
structuredContent: sc,
|
||||
}
|
||||
} catch (error) {
|
||||
return deps.errorResult(error)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue