Skip to content

fix(mcp): let getDocument read any accessible document - #1641

Merged
graphite-app[bot] merged 1 commit into
mainfrom
09-02-fix_mcp_let_getdocument_read_any_accessible_document
Sep 2, 2026
Merged

fix(mcp): let getDocument read any accessible document#1641
graphite-app[bot] merged 1 commit into
mainfrom
09-02-fix_mcp_let_getdocument_read_any_accessible_document

Conversation

@MaheshtheDev

Copy link
Copy Markdown
Member

getDocument filtered on the caller's active space, so an ID from listDocuments in any other space returned "Document not found". With activeSpace unset the fallback is sm_project_default, which broke most cross-space reads.

The API already scopes document reads to the caller's org, so the extra filter added no protection. Verified locally against the mono API: own-space and cross-space IDs now resolve, foreign-org IDs still 404.

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label Main to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@MaheshtheDev
MaheshtheDev marked this pull request as ready for review September 2, 2026 19:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T19:45:52.281303Z adbd4d9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown

Claude finished @MaheshtheDev's task in 1m 29s —— View job


PR Review Complete

  • Fetch PR diff and review changes
  • Verify security claim about org-level scoping
  • Submit review

Overview: Removes an overly restrictive space filter from getDocument that was preventing valid cross-space reads within the same org.

Analysis:

I verified the security claim by examining the code path:

  • getDocument in the MCP client (apps/mcp/src/server/client/index.ts:388-394) calls this.client.documents.get(id) through the Supermemory SDK
  • The SDK is initialized with the bearer token which enforces org-level scoping at the API layer
  • listDocuments allows querying documents from any space via the containerTag parameter, but the old getDocument code would reject those IDs if they weren't in the "active" space — a clear inconsistency

The removed filter was checking if document.containerTags included effectiveTag, throwing "Document not found" otherwise. This broke the expected workflow: list documents in space B → get document by ID → error (because active space might be A or default to sm_project_default).

The API-level org authorization remains intact (the author verified foreign-org IDs still 404), so this change removes unnecessary client-side filtering without weakening security.

Issues found: None — this is a clean bug fix.

Score: 10/10


@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 2, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp 4d8a4eb Sep 02 2026, 09:52 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 2, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
supermemory-app 4d8a4eb Commit Preview URL Sep 02 2026, 09:53 PM

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: adbd4d9e10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 31 to 32
const client = deps.getClient()
const document = await client.getDocument(args.documentId)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve scoped-space authorization for direct reads

For a restricted organization member or an OAuth connection granted only selected spaces, this unqualified direct lookup can return a same-organization document whose containerTags are outside the caller's grant when its ID is retained or otherwise known. The repository models these finer-grained boundaries in SessionInfo.scope.tags and SessionInfo.containerTags, while the stated upstream guarantee is only organization scoping; removing the sole tag check therefore exposes the document's full content rather than merely enabling reads from other authorized spaces. Replace the active-space-only check with validation that at least one document tag is among the spaces visible to this token.

Useful? React with 👍 / 👎.

@graphite-app

graphite-app Bot commented Sep 2, 2026

Copy link
Copy Markdown

Merge activity

getDocument filtered on the caller's active space, so an ID from listDocuments in any other space returned "Document not found". With activeSpace unset the fallback is sm_project_default, which broke most cross-space reads.

The API already scopes document reads to the caller's org, so the extra filter added no protection. Verified locally against the mono API: own-space and cross-space IDs now resolve, foreign-org IDs still 404.
@graphite-app
graphite-app Bot force-pushed the 09-02-fix_mcp_let_getdocument_read_any_accessible_document branch from adbd4d9 to 4d8a4eb Compare September 2, 2026 21:50
@graphite-app
graphite-app Bot merged commit 4d8a4eb into main Sep 2, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants