Skip to content

MCP Revamp (#1120) - #1380

Merged
Dhravya merged 1 commit into
mainfrom
graphite-base/1120
Jul 31, 2026
Merged

MCP Revamp (#1120)#1380
Dhravya merged 1 commit into
mainfrom
graphite-base/1120

Conversation

@Dhravya

@Dhravya Dhravya commented Jul 31, 2026

Copy link
Copy Markdown
Member

Note

High Risk
Breaking auth (API keys) and scoping (x-sm-project) plus a large MCP protocol/tool surface change on a production endpoint; migration keeps legacy DO class inert but clients and integrations must move to OAuth and new tool names.

Overview
Revamps the Supermemory MCP Worker around a stateless MCP SDK v2 runtime: OAuth JWT validation on every request (no sm_ API keys), per-request McpServer instances, and active space persisted in a SpaceState Durable Object instead of protocol-session DOs. Tooling shifts from memory/recall/listProjects to add_memory, search_memory, document APIs, listSpaces, plus interactive MCP App launchers (space picker, graph, guided save, upload) and app-only submit tools; resources move from supermemory://projects to supermemory://spaces with compact profile/context text.

Auth and scoping behavior changes: opaque API keys are rejected as invalid OAuth tokens; OAuth flows include the MCP resource parameter; connection-wide x-sm-project root scoping is removed—containerTag stays on tool schemas and active space is shared across sessions via set-active-tag. Docs and README drop API-key MCP setup in favor of OAuth-only; GitHub Claude workflows drop Supermemory MCP integration.

Tests and packaging: e2e suites run on stored OAuth refresh credentials, add widget/space-scope coverage, and replace API-key helpers; apps/mcp bumps MCP/React widget dependencies and adds unit tests for auth, formatting, analytics, and RBAC.

Reviewed by Cursor Bugbot for commit 089cdc7. Bugbot is set up for automated code reviews on this repo. Configure here.

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>
Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
@cloudflare-workers-and-pages

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 089cdc7 Jul 30 2026, 10:14 PM

@cloudflare-workers-and-pages

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 089cdc7 Commit Preview URL

Branch Preview URL
Jul 30 2026, 10:16 PM

@Dhravya
Dhravya merged commit 19e8f06 into main Jul 31, 2026
6 of 7 checks passed
@claude

claude Bot commented Jul 31, 2026

Copy link
Copy Markdown

Claude finished @Dhravya's task in 2m 36s —— View job


Code Review: MCP Revamp (#1120)

  • Fetch PR diff and existing review comments
  • Analyze authentication and authorization code
  • Review API client implementation
  • Check tool implementations for security issues
  • Review analytics and tracking code
  • Examine error handling patterns
  • Post review summary

Summary

Completed thorough security-focused code review of this major MCP server refactor. The PR migrates from Durable Objects to stateless MCP SDK v2, removes API key authentication (OAuth-only), and introduces a new React widget system.

Result: No blocking issues found. The code follows security best practices:

  • Proper JWT validation with issuer/audience checks
  • Space state isolation per organization+user
  • Input validation via Zod schemas throughout
  • Privacy-conscious analytics (no PII logged)
  • Sanitized error messages

Score: 9/10 — solid refactor ready to ship.

See the full review for detailed findings.

@mintlify

mintlify Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
supermemory 🟢 Ready View Preview Jul 31, 2026, 12:09 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 089cdc7. Configure here.

}
}

const searchResult = await client.search(args.query)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Default space scoping inconsistent

Medium Severity

When there is no durable active space and no containerTag argument, resolveContainerTag returns undefined and several tools do not apply the documented sm_project_default fallback the way profile/context resources do. search_memory then skips profile data and may query memories without a space filter, while memory-graph / fetch-graph-data can load documents across all spaces instead of the default space.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 089cdc7. Configure here.

page: 1,
limit: 10,
containerTag: "sm_project_default",
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

E2E lists wrong space tag

Low Severity

The document flow saves via guided-save / save-memory into the launcher’s writableTags[0] space, but the subsequent listMemories call hardcodes containerTag: "sm_project_default". When the writable tag is not the default project, the test no longer validates memories for the document that was just saved.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 089cdc7. Configure here.

@claude claude 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.

Code Review Summary

Overview: Major architectural overhaul of the MCP server — migrates from Durable Objects to stateless MCP SDK v2, removes API key authentication in favor of OAuth-only, and introduces a new React-based widget system.

Issues found: None — this looks good to ship.

Security Review

Authentication & Authorization:

  • JWT validation via JOSE library with proper issuer/audience verification (src/server/auth/index.ts:64-67)
  • Space state properly keyed by organizationId + userId preventing cross-tenant access (src/server/space.ts:6)
  • RBAC implementation correctly handles scoped sessions and permission levels (src/server/auth/rbac.ts)

Input Validation:

  • All tool inputs validated with Zod schemas
  • Container tags validated with length constraints (1-128 chars)
  • Memory content capped at 200k characters

Data Handling:

  • Analytics tracking is privacy-conscious — no PII or query content logged (verified via analytics.test.ts)
  • Error messages properly sanitized to avoid leaking internal details

CORS Configuration:

  • origin: "*" is intentionally permissive for MCP clients with specific hostname allowlist for MCP Apps

Architecture Notes

The refactor is well-structured:

  • Clear separation between server entry, tools, resources, and prompts
  • Consistent error handling via deps.errorResult()
  • Tool registration follows a clean pattern with proper typing
  • Analytics wrapper preserves tool behavior while adding tracking

Minor Observations (not blocking)

  1. The upload-file-submit.ts accepts base64 file data — the schema has no explicit max length on fileData, relying on downstream limits. Consider adding a schema constraint for defense-in-depth.

  2. The removal of API key authentication is a breaking change for existing integrations using sm_ keys. Docs are updated to reflect this.

Score: 9/10

Solid refactor with good security practices. The one point is for the minor file upload observation, though it's not a blocking issue since backend limits should catch oversized uploads.

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