Skip to main content
Glama

surreal-mcp

relate

Create graph relationships between records in SurrealDB to model connections like follows, likes, or purchases with optional relationship data.

Instructions

Create a graph relation (edge) between two records in SurrealDB.

This tool creates relationships in SurrealDB's graph structure, allowing you to:

  • Connect records with named relationships

  • Store data on the relationship itself

  • Build complex graph queries later

  • Model many-to-many relationships efficiently

Args: from_thing: The source record ID in format "table:id" (e.g., "user:john") relation_name: The name of the relation/edge table (e.g., "likes", "follows", "purchased") to_thing: The destination record ID in format "table:id" (e.g., "product:laptop-123") data: Optional dictionary containing data to store on the relation itself. Examples: - {"rating": 5, "review": "Great product!"} - {"quantity": 2, "price": 99.99} - {"since": "2024-01-01", "type": "friend"}

Returns: A dictionary containing: - success: Boolean indicating if relation was created successfully - data: The created relation record(s) - relation_id: The ID of the created relation - error: Error message if creation failed (only present on failure)

Examples: >>> await relate("user:john", "likes", "product:laptop-123", {"rating": 5}) { "success": true, "data": [{"id": "likes:xyz", "in": "user:john", "out": "product:laptop-123", "rating": 5}], "relation_id": "likes:xyz" }

>>> await relate("user:alice", "follows", "user:bob") { "success": true, "data": [{"id": "follows:abc", "in": "user:alice", "out": "user:bob"}], "relation_id": "follows:abc" }

Note: You can query these relations later using graph syntax: SELECT * FROM user:john->likes->product SELECT * FROM user:alice->follows->user

Input Schema

NameRequiredDescriptionDefault
dataNo
from_thingYes
relation_nameYes
to_thingYes

Input Schema (JSON Schema)

{ "properties": { "data": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Data" }, "from_thing": { "title": "From Thing", "type": "string" }, "relation_name": { "title": "Relation Name", "type": "string" }, "to_thing": { "title": "To Thing", "type": "string" } }, "required": [ "from_thing", "relation_name", "to_thing" ], "type": "object" }

Other Tools from surreal-mcp

Related Tools

    MCP directory API

    We provide all the information about MCP servers via our MCP API.

    curl -X GET 'https://glama.ai/api/mcp/v1/servers/lfnovo/surreal-mcp'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server