Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions apps/mcp/src/server/tools/fetch-graph-data.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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 = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

structuredContent now becomes a ViewMessage, but this drops the existing pagination object even though fetch-graph-data still accepts page/limit and apps/mcp/e2e/graph.test.ts still asserts res.structuredContent.pagination.limit === 5. This breaks the structured pagination contract for callers and will likely fail the graph E2E case when API_KEY is present. Please keep the graph ViewMessage shape for widget dispatch, but preserve pagination in structuredContent too, for example by extending the graph view message with pagination: data.pagination and updating the shared type.

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)
Expand Down
Loading