Commit graph

52 commits

Author SHA1 Message Date
Prasanna721
a99cf4f7e1 fix mcp graph and file uploads (#1397)
Fixes cross-host graph rendering and moves widget uploads off the JSON/base64 tool transport.

- render graph data from the launcher result without a second tool call
- stream multipart uploads through one-time, short-lived upload sessions
- remove temporary widget diagnostics and redundant unit tests

Tested with Biome, TypeScript, 17 unit tests, a Wrangler deployment dry-run, and live graph rendering in ChatGPT and Claude. Authenticated E2E setup is currently blocked by the saved OAuth refresh session returning `invalid_grant: session not found`.
2026-08-04 18:58:14 +00:00
Prasanna721
7e7e820489 fix mcp app contracts (#1394)
Fixes MCP app submission metadata and makes widget delivery consistent across hosts.

- content-hash widget resources and set the production widget domain
- add typed structured outputs to direct tools and scope default-space calls
- keep graph rendering compatible with both initial results and app-side loading

Tested with `bun run check-types` and `bun run test:unit` (42 tests).
2026-08-01 06:41:17 +00:00
Prasanna721
48fb1969f8 fix chatgpt memory graph rendering (#1393)
ChatGPT can omit nullable nested fields from structured tool results and does not reliably expose result metadata to MCP Apps. Keep graph data in `structuredContent`, tolerate missing document titles, and bundle React inside the widget so the graph renders consistently across hosts.

- use the deployable `app-v4` resource URI
- keep the graph response and widget schema aligned
- remove the `esm.sh` runtime dependency

Tested with typecheck, 42 unit tests, production widget build, 36 branch-local authenticated E2E tests, and a live ChatGPT graph render.
2026-07-31 21:20:15 +00:00
Prasanna721
9e194fbc50 fix MCP app result contracts (#1385)
Moves MCP App results onto explicit runtime schemas so hosts can distinguish model-visible output from widget-only graph data.

- advertises output schemas for structured tools
- validates API, session, and widget boundaries instead of asserting response types
- marks additive app writes as non-destructive and removes redundant widget typing

Verified with MCP typecheck, 42 unit tests, and the production widget build. Claude Desktop host validation is in progress against a temporary tunnel.
2026-07-31 18:23:29 +00:00
Dhravya Shah
a7161c7132
fix(mcp): add missing tool safety annotations (#1383) 2026-07-30 21:10:42 -07:00
Dhravya Shah
ff40a82d69
Add .well-known/openai-apps-challenge route to MCP server (#1382) 2026-07-30 21:06:14 -07:00
Prasanna
04e5b4dccf
fix clipped space picker (#1381) 2026-07-30 19:15:23 -07:00
Dhravya Shah
19e8f06cf1
MCP Revamp (#1120) (#1380)
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>
2026-07-30 17:08:51 -07:00
Prasanna721
95a34602b7 register SpaceState durable object (#1376)
Registers `SpaceState` before the stateless MCP starts routing requests through it. The class is intentionally unused here, so this changes no request behavior.

Rollout:
1. Apply this exact commit once with `wrangler deploy`, not `wrangler versions upload`.
2. Rerun the Workers check and merge this parent PR.
3. Land #1120, which adds the active-space methods and request routing.

Verified with the MCP widget build, isolated class typecheck, and Wrangler deploy/version dry runs.
2026-07-30 21:28:22 +00:00
MaheshtheDev
4aa044fe55 fix(mcp): respect readable scope for unscoped recall (#1357)
Unscoped recall forced sm_project_default even when the caller could only read another organization space, causing a misleading 403 while list and graph operations succeeded. Let the search API choose the caller's readable scope, skip profile enrichment when no concrete scope is selected, and retain upstream error details.

Validated with Biome, Vite production build, and Wrangler deploy dry-run.
2026-07-24 19:01:51 +00:00
Dhravya Shah
f882f1104d
docs: restructure documentation site and update integration UI (#1331)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-07-21 20:19:30 -07:00
Dhravya Shah
816b85d756
fix(mcp): annotate tool safety hints for ChatGPT (#1330) 2026-07-21 14:45:45 -07:00
Abhay Singh
9487a928f6
feat(mcp): add listMemories tool for enumerating stored memories (#1183) 2026-07-10 19:15:12 -07:00
Dhravya Shah
e706a13877
Merge timeout additions for supermemory-mcp (#1144)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Polylane Automation <automation@nominal.ai>
2026-06-29 12:28:14 -07:00
Dhravya Shah
886ee692f9
Add request timeouts to Supermemory MCP client calls (#1146)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-06-25 13:35:23 -07:00
MaheshtheDev
def847af5f Revert "fix(mcp): clarify memory graph pagination (#1032)" (#1133)
This reverts commit feca81f69e.
2026-06-17 17:16:22 +00:00
Rāna(Bass Ver.)
feca81f69e
fix(mcp): clarify memory graph pagination (#1032)
Co-authored-by: Vedant Mahajan <vedant.04.mahajan@gmail.com>
2026-06-17 18:38:19 +05:30
sreedharsreeram
0ae552037a feat(mcp): playground-style rich recall (formatMemories + profile) (#1101)
## What

Makes the MCP `recall` tool render memories the same way the console **playground** does — rich, scored, relation-aware output — instead of the old flat `### Memory N (NN% match)` list.

The playground pattern is: **profile + rich search → one shared `formatMemories` formatter → feed to the model.** This ports that into the standalone MCP server.

## Changes

- **`format.ts`** (new) — `formatMemories`, lifted verbatim from the playground. Pure, dependency-free. Renders similarity scores, `agg`/`chunk` markers, related-memory arrows (`←` parent, `→` child, `~` related), attached document summaries, and temporal context.
- **`client.ts`** — `SupermemoryClient.search()` now accepts the playground's retrieval knobs (`searchMode` / `rerank` / `rewriteQuery` / `include`) and **stops discarding** the rich response fields (`context`, `documents`, `metadata`, `isAggregated`) during normalization, so the formatter has data to render.
- **`server.ts` (`handleRecall`)** — retrieves memories via `client.search()` with `include: { documents, relatedMemories }`, prepends the user's profile (stable + recent facts) when `includeProfile` is set, and renders memories through `formatMemories`. Output capped at `MAX_RECALL_CHARS`.

## How it maps to the playground

| | Playground | MCP (this PR) |
|---|---|---|
| Profile | injected into its own system prompt (`<user_profile>`) | prepended to `recall` output / exposed via `context` prompt |
| Search | hook pre-fetch **or** tool | `recall` tool (model-triggered) |
| Formatting | `formatMemories` → system prompt | `formatMemories` → `recall` tool result |

## Testing

Verified end-to-end against a local API + local MCP, driven through a real MCP client (and Claude Desktop). `recall` now returns scored memory blocks with `Source:`/`Document:` lines and the legend header. Existing e2e assertions remain compatible (they match `## User Profile` / `## Relevant Memories`, both still emitted).

## Notes

- One deliberate gap vs the playground: `aggregate` — the public SDK's `search.memories` doesn't expose it, so no `agg` synthesis blocks. Relation arrows render only when memories actually have linked parent/child versions.
- Possible follow-up: expose the `include` / `rerank` knobs as `recall` tool params so callers can toggle relations/documents per call.
- Pre-existing `tsc` errors in `server.ts` (dual `@modelcontextprotocol/sdk` install) and `mcp-app.ts` (DOM `lib`) are unrelated to this change — confirmed by an unchanged baseline.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---
**Session Details**
- Session: [View Session](https://supermemory.us1.vorflux.com/agent-sessions/c616fc88-a725-4961-9011-712bce740601)
- Requested by: Sreeram Sreedhar (sreeram@supermemory.com)
- Address comments on this PR. Add `(aside)` to your comment to have me ignore it.
2026-06-12 21:53:58 +00:00
MaheshtheDev
9808441f6b test(mcp): add deployed-server e2e suite (#1057)
End-to-end tests that drive the deployed Supermemory MCP over streamable HTTP (no mocks):

- discovery: handshake + tool/resource/prompt listing
- identity: whoAmI, listProjects
- memory: save -> recall round-trip, profile variants, forget, container scoping
- graph/resources/prompts: memory-graph, fetch-graph-data, profile/projects, context
- oauth: protected-resource discovery chain, dynamic client registration,
token-endpoint negatives, and a real refresh -> access token round-trip
- auth: GET / info, 401 on missing/invalid token
- root-scope: x-sm-project scoping behavior

Tests skip without SUPERMEMORY_API_KEY (OAuth tier-D skips without its token env vars) so CI is safe without secrets. Adds vitest + a test:e2e script and documents running + the OAuth flow in apps/mcp/README.md.
2026-06-07 04:30:17 +00:00
Dhravya Shah
b6a9b1ea7b
Update chat empty state and Auto space mode (#954) 2026-05-16 23:55:34 -07:00
MaheshtheDev
ee7951f6ba fix(mcp): align oauth protected-resource metadata with MCP 2025-06-18 spec (#945)
## Summary

Fixes MCP OAuth discovery so the client-server handshake actually validates against the **MCP 2025-06-18 authorization spec** (which adopts RFC 9728 Protected Resource Metadata + RFC 8707 Resource Indicators).

Previously, a client connecting to `https://mcp.dev.supermemory.ai/mcp` would receive `resource: "https://mcp.supermemory.ai"` (bare host, prod fallback) and reject the connection:

> Protected resource https://mcp.supermemory.ai does not match expected https://mcp.dev.supermemory.ai/mcp (or origin)

## Changes

- **`resource` now includes the `/mcp` endpoint path** — the spec wants the canonical MCP server URI, and the bundled `@modelcontextprotocol/sdk` reference implementation emits the same shape (`new URL(rsPath, base).href`). Bare-host worked with lenient clients that fell back to origin-matching; strict clients rejected it.
- **Path-suffixed metadata route** added at `/.well-known/oauth-protected-resource/mcp` alongside the bare path. The SDK's `metadataHandler` mounts under the resource path, so this matches what spec-strict clients probe first.
- **`WWW-Authenticate`'s `resource_metadata` URL** points to the canonical full URL (`https://host/.well-known/oauth-protected-resource/mcp`).
- **Centralized base-URL derivation** in a new `mcpBaseUrl()` helper, with priority:
  1. `MCP_URL` env var — set by portless dev script so dev requests resolve to the tunneled host, not whatever the local proxy sticks in `Host`
  2. `x-forwarded-host` / `host` request headers
  3. `https://mcp.supermemory.ai` last-resort fallback (only hit when the worker can't see the inbound host at all)

## Production impact

`MCP_URL` is dev-only (not in `wrangler.jsonc` vars), so prod falls through to the `Host` header → `https://mcp.supermemory.ai/mcp`. The wire change in prod is that `resource` now ends with `/mcp` instead of being bare — spec-correct, what strict clients require, and tolerated by lenient ones.

## Contributor DX

Added `apps/mcp/.dev.vars.example` documenting `API_URL`, `MCP_URL`, and `POSTHOG_API_KEY` for contributors running plain `wrangler dev` without portless.

## Test plan

- [x] `curl https://mcp.dev.supermemory.ai/.well-known/oauth-protected-resource` returns `resource: https://mcp.dev.supermemory.ai/mcp`
- [x] `curl https://mcp.dev.supermemory.ai/.well-known/oauth-protected-resource/mcp` returns the same payload
- [x] 401 from `/mcp` carries `WWW-Authenticate: Bearer resource_metadata="…/oauth-protected-resource/mcp"`
- [x] MCP client (vscode extension) connects successfully — previously failed with the resource-mismatch error
- [ ] Verify in prod that bare-host clients continue to work after deploy
2026-05-15 23:56:25 +00:00
Dhravya Shah
19d51e4b2a use portless 2026-05-06 22:42:34 -07:00
MaheshtheDev
8a6b50332b fix: projects endpoint trigger with TTL (#870) 2026-04-21 18:02:52 +00:00
MaheshtheDev
7b65e9a1db fix: reverted for auth issue (#860) 2026-04-16 23:35:19 +00:00
MaheshtheDev
cfcfaaac0f fix: another resource url issue (#859) 2026-04-16 23:27:38 +00:00
Mahesh Sanikommu
c59457d8b3
fix: trying resource metadata failure for mcp auth (#858) 2026-04-16 16:01:29 -07:00
Evandro Camargo
5b57f4ddf3
fix(mcp): register handler on bare /mcp path to match MCP transport spec (#733) 2026-04-11 16:57:26 -07:00
Prasanna
a91136dad8
MCP connector fix (#849)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-10 21:20:41 -07:00
MaheshtheDev
8f1e8afaf9 fix: trying mcp auth with resource (#840) 2026-04-09 08:21:06 +00:00
Prasanna721
543c45a626 fix(mcp): fix broken memory graph and improve UI design (#837)
## Summary
- Fixed memory graph stuck on "Loading graph data..." caused by field name mismatch after package rewrite (`memoryEntries` vs `memories`, `type` vs `documentType`)
- Improved MCP app UI to match console-v2 design: golden derives edges (#FBBF24), edge glow pass, node hover effects, dot mode at low zoom, vertical controls with keyboard shortcuts, expandable legend
- Synced local `memory-graph` edgeDerives constant with published npm version

## Test plan
- [ ] Run `cd apps/mcp && bun run dev`, connect via Claude Desktop
- [ ] Verify graph renders with golden derives edges and blue dashed extends edges
- [ ] Verify node hover/selection glow effects
- [ ] Verify Fit (Z), Center (C), zoom (+/-) keyboard shortcuts
- [ ] Verify legend expands/collapses
2026-04-08 21:21:10 +00:00
MaheshtheDev
ca3d5d4921 docs: hermes agent instructions (#833) 2026-04-07 22:00:58 +00:00
vorflux[bot]
851b8cfe86
Rewrite @supermemory/memory-graph with perf optimizations + consolidate consumers (#809)
Co-authored-by: Vorflux AI <noreply@vorflux.com>
2026-03-28 19:06:27 -07:00
Mahesh Sanikommu
962fb85cd3
feat: empty state action for new spaces (#780)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-15 11:02:14 -07:00
sohamd22
07875ad1a1 update forget implementation in mcp (#773)
### TL;DR

Enhanced the `forgetMemory` method to try exact content matching first, then fall back to semantic search with a high similarity threshold for more precise memory deletion.

### What changed?

The `forgetMemory` method now uses a two-step approach: first attempting exact content matching via the API, and if that fails with a 404, falling back to semantic search with a similarity threshold of 0.85. The search method also accepts an optional threshold parameter. Error messages now distinguish between exact matches and semantic matches, including similarity scores in the response.

### How to test?

1. Call `forgetMemory` with the exact content of an existing memory to verify direct deletion
2. Call `forgetMemory` with similar but not identical content to test the semantic search fallback
3. Call `forgetMemory` with completely unrelated content to verify the "no matching memory found" response
4. Verify that success messages indicate whether deletion used exact matching or semantic matching with similarity scores

### Why make this change?

This approach provides more precise memory deletion by prioritizing exact matches while still offering a fallback for similar content. The high similarity threshold (0.85) ensures that only very similar memories are deleted when exact matches aren't found, reducing the risk of accidentally deleting unrelated memories.
2026-03-09 18:59:08 +00:00
Dhravya Shah
80a75f73ba fix: forget api 2026-03-05 10:11:34 -08:00
Prasanna721
2bbc7fc7a5 feat(mcp): add interactive memory graph MCP App visualization (#763)
### feat(mcp): add memory graph visualization MCP App

#### Summary
  - Add interactive force-directed graph visualization as an MCP App using `force-graph` + `d3-force-3d`
  - Register `memory-graph` and `fetch-graph-data` tools with MCP Apps SDK UI resources
  - Add graph API client methods (`getGraphBounds`, `getGraphViewport`) to `SupermemoryClient`
  - Set up Vite + `vite-plugin-singlefile` build pipeline to produce a self-contained HTML bundle
  - Support light/dark theme, zoom controls, node popups, and legend

  #### Files changed
  - `apps/mcp/src/server.ts` — register app tools + HTML resource
  - `apps/mcp/src/client.ts` — add graph API types and methods
  - `apps/mcp/src/ui/mcp-app.ts` — force-graph visualization app
  - `apps/mcp/src/ui/global.css`, `mcp-app.css` — styling
  - `apps/mcp/mcp-app.html` — entry HTML for Vite
  - `apps/mcp/vite.config.ts` — Vite single-file build config
  - `apps/mcp/package.json` — add UI deps and build scripts
  - `apps/mcp/wrangler.jsonc` — add HTML text import rule
2026-03-05 16:28:34 +00:00
Dhravya Shah
0c46362505 fix: properly attribute revenue with posthog 2026-02-25 18:28:13 -08:00
Prasanna721
c82dcdc30a fix(mcp): hide containerTag from tool schemas when x-sm-project header is set (#749)
### fix(mcp): prevent LLM from overriding x-sm-project container tag

- When `x-sm-project` header is configured, the `containerTag` field is now
    excluded from memory/recall/context tool schemas
 - This prevents LLMs from overriding the configured project by picking a
    different containerTag from the available projects list
  - When no header is set, behavior is unchanged — containerTag remains visible
    in schemas for manual project selection via listProjects
2026-02-20 04:34:57 +00:00
Dhravya Shah
7030c8bdb0 fix: effective tag 2026-02-19 20:12:19 -08:00
Coldaine
1328c2ac3a
fix(mcp): change memories.delete to documents.delete for forget action (#737) 2026-02-16 14:32:04 -07:00
Muhammed Hunaid Topiwala
3069bd61e6
fix(mcp): include r.memory in getProfile fallback chain (#697) 2026-01-23 12:44:52 -08:00
MaheshtheDev
1423bd7004 feat: mobile responsive, lint formats, toast, render issue fix (#688)
- Mobile responsive
- new toast design
- web document render issue fix
- posthog analytics
- ui improvements
2026-01-21 03:11:53 +00:00
Dhravya Shah
87b361c26b
docs changes (#678)
Some checks failed
Publish AI SDK / publish (push) Has been cancelled
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 16:55:32 -08:00
MaheshtheDev
acdb422635 add (mcp): projects aware tool on every init (#676) 2026-01-17 00:57:48 +00:00
Dhravya
e94134cd26 fix: oauth discovery not working with some clients (#666)
### TL;DR

TESTING REMAINING. This is my hypothesis. @MaheshtheDev please carry on from here or we can test in prod.

Added a proxy endpoint for OAuth authorization server metadata to support non-compliant MCP clients.

### What changed?

Added a new endpoint `/.well-known/oauth-authorization-server` to the MCP server that proxies requests to the main API. This endpoint fetches the authorization server metadata from the API and returns it to clients.

### How to test?

1. Make a GET request to `/.well-known/oauth-authorization-server` on the MCP server
2. Verify that it returns the same metadata as the main API's `/.well-known/oauth-authorization-server` endpoint
3. Test with a client that expects to find the authorization server metadata on the MCP domain

### Why make this change?

Some MCP clients don't correctly follow the OAuth specification. Instead of using the `authorization_servers` array provided in the protected resource metadata, they look for the authorization server metadata directly on the MCP server domain. This proxy endpoint ensures compatibility with these non-compliant clients without requiring them to be updated.
2026-01-12 23:38:30 +00:00
Dhravya Shah
f7c442e0dc chore: wrangler jsonc update 2026-01-02 13:28:25 -08:00
Dhravya Shah
d3bb0a8855 fix: added one more file 2026-01-02 13:01:26 -08:00
Dhravya Shah
e37c84e51f fix: mcp initializes in durable object 2026-01-02 12:59:33 -08:00
MaheshtheDev
cda6e1a93a chore: update readme and gitignore (#640) 2025-12-31 02:41:35 +00:00
Mahesh Sanikommu
7d0fa7d033
fix: prompt injection with mcp (#638) 2025-12-30 14:22:35 -08:00