Skip to content

[recipes] Add OB-Graph knowledge graph layer#158

Merged
justfinethanku merged 2 commits into
mainfrom
claude/add-ob-graph-extension-JcPLh
Apr 13, 2026
Merged

[recipes] Add OB-Graph knowledge graph layer#158
justfinethanku merged 2 commits into
mainfrom
claude/add-ob-graph-extension-JcPLh

Conversation

@justfinethanku
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a new recipes/ob-graph recipe that brings graph database functionality to Open Brain using PostgreSQL nodes + edges
  • Includes graph_nodes and graph_edges tables with RLS, indexes, and recursive CTE functions for traversal and shortest-path queries
  • Deploys as a Supabase Edge Function MCP server with 10 tools: create/update/delete nodes and edges, search, get neighbors, traverse, and find paths

What's Included

File Purpose
schema.sql Tables, indexes, RLS policies, traverse_graph() and find_shortest_path() functions, GRANT statements
index.ts MCP server (Hono + StreamableHTTPTransport) with 10 graph tools
deno.json Deno import map matching existing extension patterns
metadata.json Recipe metadata conforming to .github/metadata.schema.json
README.md Setup guide with credential tracker, step badges, tool reference, troubleshooting
.env.example Environment variable template

Design Decisions

  • PostgreSQL recursive CTEs instead of a separate graph database — stays within Supabase free tier, no extra services
  • Nodes + edges model with typed relationships and JSONB properties for flexibility
  • Optional thought_id FK on nodes lets users link graph entities back to existing thoughts without modifying the core thoughts table
  • Cycle prevention built into traversal via path array tracking
  • Unique edge constraint prevents duplicate relationships of the same type between the same node pair

Test plan

  • Run schema.sql in Supabase SQL Editor — verify tables and functions appear
  • Deploy Edge Function via supabase functions deploy ob-graph-mcp --no-verify-jwt
  • Create nodes and edges via MCP tools
  • Test traverse_graph with multi-hop depth
  • Test find_path between two connected nodes
  • Verify RLS prevents cross-user data access
  • Validate metadata.json against .github/metadata.schema.json

https://claude.ai/code/session_015Z8wCeokTMTdrVMthqzGKJ

Adds graph database functionality for Open Brain using PostgreSQL nodes + edges
with recursive CTE traversal. Includes schema, MCP server with 10 tools, and
setup documentation.

https://claude.ai/code/session_015Z8wCeokTMTdrVMthqzGKJ
@github-actions github-actions Bot added the recipe Contribution: step-by-step recipe label Apr 5, 2026
@justfinethanku
Copy link
Copy Markdown
Collaborator Author

Thanks for the contribution here. There’s a lot to like in this one, and we’ll merge it as soon as these smaller fixes are in:

  • add ✅ Done when checkpoints to Steps 2 and 3 in the README
  • make the deployment flow explicit about generating and setting MCP_ACCESS_KEY and DEFAULT_USER_ID
  • make find_shortest_path() return rows in explicit path order so the output is deterministic

If you want, enable maintainer edits and we can help patch the final details.

@justfinethanku justfinethanku merged commit 84e7f62 into main Apr 13, 2026
1 of 2 checks passed
@justfinethanku justfinethanku deleted the claude/add-ob-graph-extension-JcPLh branch April 13, 2026 02:13
corruptmemory pushed a commit to corruptmemory/OB1 that referenced this pull request Apr 15, 2026
* [recipes] Add OB-Graph knowledge graph layer

Adds graph database functionality for Open Brain using PostgreSQL nodes + edges
with recursive CTE traversal. Includes schema, MCP server with 10 tools, and
setup documentation.

https://claude.ai/code/session_015Z8wCeokTMTdrVMthqzGKJ

* [recipes] Clarify OB-Graph deployment setup

---------

Co-authored-by: Claude <noreply@anthropic.com>
gleesonb pushed a commit to gleesonb/OB1 that referenced this pull request May 12, 2026
* [recipes] Add OB-Graph knowledge graph layer

Adds graph database functionality for Open Brain using PostgreSQL nodes + edges
with recursive CTE traversal. Includes schema, MCP server with 10 tools, and
setup documentation.

https://claude.ai/code/session_015Z8wCeokTMTdrVMthqzGKJ

* [recipes] Clarify OB-Graph deployment setup

---------

Co-authored-by: Claude <noreply@anthropic.com>
@mikedavis949-code
Copy link
Copy Markdown

Hey @justfinethanku,

I implemented the OB-Graph recipe and ran into high Supabase Edge Function invocation usage — the ob-graph-mcp function was quickly exceeding the free tier quota (I hit 847k/500k in a couple weeks).

Root cause: The McpServer + all 10 tool registrations were being recreated on every request (including the frequent GET discovery/polling requests from Claude Desktop).

Fix: I moved the server initialization and tool registration to module scope (outside the request handler), similar to how open-brain-mcp is structured.

ob-graph-index.ts.txt

I'm new to github, so appoligies if I'm sticking this feedback in the wrong place.
Thanks for the great recipe — the graph tools are really powerful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Contribution: step-by-step recipe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants