graphlife Docs graphlife.app

MCP tools

4. Quickstart

Both paths below perform the same read (search for a name) and the same write (add a person who works at a company) against the server.

4.1 Prerequisite: a credential#

Create a live key as shown in section 3.2 and export it. The write below needs a key whose scope includes add_to_graph and that may create nodes (section 2.2); the key in the section 3.2 example qualifies.

export GL=https://graphlife.example.com
export KEY=glk_your_key

If the key reaches more than one graph, add "graph": "<graph id>" to the arguments of every call below.

4.2 Path A: connect an MCP-capable assistant#

Add a remote (HTTP) MCP server to the assistant, with the endpoint URL and the key as a bearer header. The exact configuration syntax depends on the assistant; a typical entry looks like this:

{
  "mcpServers": {
    "graphlife": {
      "type": "http",
      "url": "https://graphlife.example.com/v1/live/mcp",
      "headers": { "Authorization": "Bearer glk_your_key" }
    }
  }
}

An assistant that requires OAuth instead of a static header needs only the URL https://graphlife.example.com/v1/live/mcp. It discovers the authorization server from the endpoint's 401 response, registers itself, and opens the sign-in and consent pages in a browser.

To see exactly what the assistant will send, the same calls by hand:

# Handshake
curl -s $GL/v1/live/mcp -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize",
       "params":{"protocolVersion":"2025-06-18","capabilities":{},
                 "clientInfo":{"name":"example","version":"1.0"}}}'

# Which tools does this key have?
curl -s $GL/v1/live/mcp -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

# Read
curl -s $GL/v1/live/mcp -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call",
       "params":{"name":"search","arguments":{"query":"Acme","limit":5}}}'

# Write
curl -s $GL/v1/live/mcp -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":4,"method":"tools/call",
       "params":{"name":"add_to_graph","arguments":{
         "entities":[{"local_id":"p","kind":"person","label":"Dana Rossi"},
                     {"local_id":"o","kind":"org","label":"Acme Ltd"}],
         "relations":[{"subject_local_id":"p","predicate":"worked_at","object_local_id":"o"}],
         "sourceText":"Dana Rossi works at Acme Ltd."}}}'

The read answers:

{"jsonrpc":"2.0","id":3,"result":{"resultType":"complete",
  "content":[{"type":"text","text":"[{\"id\":\"…\",\"kind\":\"…\",\"label\":\"Acme Ltd\"}]"}],
  "isError":false}}

4.3 Path B: the same read and write over plain HTTP#

POST /v1/live takes {"tool": "<name>", "args": {…}} with the same tool names and arguments as section 3.5.

# Read
curl -s $GL/v1/live -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"tool":"search","args":{"query":"Acme","limit":5}}'
{"result":[{"id":"…","kind":"…","label":"Acme Ltd"}]}
# Write
curl -s $GL/v1/live -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"tool":"add_to_graph","args":{
        "entities":[{"local_id":"p","kind":"person","label":"Dana Rossi"},
                    {"local_id":"o","kind":"org","label":"Acme Ltd"}],
        "relations":[{"subject_local_id":"p","predicate":"worked_at","object_local_id":"o"}],
        "sourceText":"Dana Rossi works at Acme Ltd."}}'

An illustrative response (the counts depend on what the graph already holds):

{"result":{"nodesCreated":1,"nodesMerged":1,"edgesCreated":1,"candidatesQueued":0,
           "complete":true,"nodesRequested":2,"relationsRequested":1,
           "sourceId":"…","nodeIds":["…","…"],"resolved":{"p":"…","o":"…"}},
 "revision":18}

Differences from the MCP door:

Aspect POST /v1/live POST /v1/live/mcp
Success body {"result": <value>, "revision": <n>}; revision is present after a write that changed the graph JSON-RPC result whose content[0].text is the JSON-encoded value; no revision
Failure HTTP status with {"error":{"code":"<code>"}} HTTP 200, isError: true, a sentence in text
A node lookup that finds nothing {"result": null} with status 200 isError: true
Tool list GET/v1/live/tools, filtered to the credential tools/list, filtered to the credential

The revision returned by /v1/live is the value to pass as baseRevision on a later update_node or set_groups. Read calls do not return a revision; a refused edit returns the current one in its edit_conflict error.