Skip to main content

Grounding API (MCP Integration)

Read-only endpoints for AI agents connecting via the Model Context Protocol. These endpoints let external agents discover, explore, and query the knowledge graph without mutating it.

Base URL: /api/v1/graph/grounding

All grounding endpoints are read-only (GET).

See Graph Operations for maintenance endpoints (cleanup, canvas, snapshots).

Related pages

Search Nodes

GET /api/v1/graph/grounding/nodes

Search and list nodes in the knowledge graph. This is the primary entry point for knowledge discovery by AI agents.

Query Parameters

ParameterTypeRequiredDefaultDescription
qstringNoSearch query (filters by label or property values)
template_idstringNoFilter nodes by template/entity type
pageintNo11-based page number
page_sizeintNosettings defaultItems per page (capped to server max)
Text search

The q parameter performs a case-insensitive match against node labels and all property values. Combine with template_id for targeted searches.

q is applied in Python after the SQL page is fetched, so pagination.total reflects the SQL-filtered count (template_id only). Iterate pages until has_next is false to discover every match.

Example Requests

Search for nodes by text:

curl -X GET "http://localhost:8080/api/v1/graph/grounding/nodes?q=Einstein"

Filter by template type with pagination:

curl -X GET "http://localhost:8080/api/v1/graph/grounding/nodes?template_id=person&page=1&page_size=50"

Response — 200 OK

{
"data": [
{
"id": "node-abc-123",
"template_id": "person",
"label": "Albert Einstein",
"properties": {
"birth_year": 1879,
"field": "Physics"
},
"position": {"x": 100.0, "y": 200.0},
"source_id": "src-001",
"embedding": null,
"created_at": "2026-03-01T10:00:00",
"updated_at": "2026-03-01T10:00:00"
}
],
"pagination": {
"total": 1,
"page": 1,
"page_size": 50,
"total_pages": 1,
"has_next": false,
"has_prev": false
}
}

Node Fields

FieldTypeDescription
idstringUnique node identifier
labelstringHuman-readable label/title
template_idstringTemplate type this node follows
propertiesobjectKey-value property map
positionobject or nullGraph canvas position (x, y)
source_idstring or nullSource document this node was extracted from
embeddinglist[float] or nullVector embedding for similarity search
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp

Pagination Fields

FieldTypeDescription
totalintTotal number of matching nodes (SQL-filtered)
pageintCurrent page (1-based)
page_sizeintItems per page
total_pagesintTotal page count
has_nextboolWhether another page is available
has_prevboolWhether a previous page is available

Get Node with Edges

GET /api/v1/graph/grounding/nodes/{node_id}

Returns a single node with all its connected edges (both incoming and outgoing). Provides full local graph context for reasoning about a specific entity.

Path Parameters

ParameterTypeRequiredDescription
node_idstringYesNode ID to retrieve

Example Request

curl -X GET http://localhost:8080/api/v1/graph/grounding/nodes/node-abc-123

Response — 200 OK

{
"node": {
"id": "node-abc-123",
"template_id": "person",
"label": "Albert Einstein",
"properties": {
"birth_year": 1879,
"field": "Physics"
},
"position": null,
"source_id": "src-001",
"embedding": null,
"created_at": "2026-03-01T10:00:00",
"updated_at": "2026-03-01T10:00:00"
},
"outgoing_edges": [
{
"id": "edge-xyz-789",
"template_id": "rel-worked-on",
"source_node_id": "node-abc-123",
"target_node_id": "node-def-456",
"label": "worked on",
"properties": {
"year": 1905
},
"created_at": "2026-03-01T10:30:00",
"updated_at": "2026-03-01T10:30:00"
}
],
"incoming_edges": [
{
"id": "edge-uvw-321",
"template_id": "rel-mentored-by",
"source_node_id": "node-ghi-654",
"target_node_id": "node-abc-123",
"label": "mentored by",
"properties": {},
"created_at": "2026-03-01T11:00:00",
"updated_at": "2026-03-01T11:00:00"
}
],
"total_outgoing": 1,
"total_incoming": 1
}

Response Fields

FieldTypeDescription
nodeNodeFull node object (see Node Fields above)
outgoing_edgeslist[Edge]Edges where this node is the source
incoming_edgeslist[Edge]Edges where this node is the target
total_outgoingintCount of outgoing edges
total_incomingintCount of incoming edges

Errors

StatusDescription
404Node not found

List Edges

GET /api/v1/graph/grounding/edges

Search and list edges (relationships) in the knowledge graph. Useful for understanding connection patterns and graph structure.

Query Parameters

ParameterTypeRequiredDefaultDescription
source_node_idstringNoFilter edges by source node ID
target_node_idstringNoFilter edges by target node ID
pageintNo11-based page number
page_sizeintNosettings defaultItems per page (capped to server max)

Example Requests

Get all edges from a specific node:

curl -X GET "http://localhost:8080/api/v1/graph/grounding/edges?source_node_id=node-abc-123"

Find a specific connection between two nodes:

curl -X GET "http://localhost:8080/api/v1/graph/grounding/edges?source_node_id=node-abc-123&target_node_id=node-def-456"

Paginate through all edges:

curl -X GET "http://localhost:8080/api/v1/graph/grounding/edges?page=3&page_size=50"

Response — 200 OK

{
"data": [
{
"id": "edge-xyz-789",
"template_id": "rel-worked-on",
"source_node_id": "node-abc-123",
"target_node_id": "node-def-456",
"label": "worked on",
"properties": {"year": 1905},
"created_at": "2026-03-01T10:30:00",
"updated_at": "2026-03-01T10:30:00"
}
],
"pagination": {
"total": 1,
"page": 1,
"page_size": 50,
"total_pages": 1,
"has_next": false,
"has_prev": false
}
}

Response Fields

FieldTypeDescription
datalist[Edge]Array of edge objects
paginationobjectPagination envelope (see below)

Pagination Fields

FieldTypeDescription
totalintTotal number of matching edges
pageintCurrent page (1-based)
page_sizeintItems per page
total_pagesintTotal page count
has_nextboolWhether another page is available
has_prevboolWhether a previous page is available

Edge Fields

FieldTypeDescription
idstringUnique edge identifier
template_idstringRelationship type template ID
source_node_idstringSource node ID (from)
target_node_idstringTarget node ID (to)
labelstringHuman-readable relationship label
propertiesobjectKey-value relationship properties
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp

Get Node Neighbors

GET /api/v1/graph/grounding/nodes/{node_id}/neighbors

Returns nodes connected to the specified node via edges. Enables graph traversal, path finding, and relationship discovery by following edges in a chosen direction.

Path Parameters

ParameterTypeRequiredDescription
node_idstringYesNode ID to find neighbors for

Query Parameters

ParameterTypeRequiredDefaultDescription
directionstringNobothEdge direction to follow: outgoing, incoming, or both
limitintNo100Maximum neighbors to return (min 1, capped to server max)
Direction semantics
  • outgoing -- follow edges where this node is the source (what this node relates to)
  • incoming -- follow edges where this node is the target (what relates to this node)
  • both -- follow edges in both directions

Example Requests

Get all neighbors:

curl -X GET http://localhost:8080/api/v1/graph/grounding/nodes/node-abc-123/neighbors

Get only outgoing neighbors with a limit:

curl -X GET "http://localhost:8080/api/v1/graph/grounding/nodes/node-abc-123/neighbors?direction=outgoing&limit=10"

Response — 200 OK

{
"node_id": "node-abc-123",
"neighbors": [
{
"node": {
"id": "node-def-456",
"template_id": "concept",
"label": "Theory of Relativity",
"properties": {
"year": 1905
},
"position": null,
"source_id": "src-001",
"embedding": null,
"created_at": "2026-03-01T10:00:00",
"updated_at": "2026-03-01T10:00:00"
},
"relationship_type": "worked on",
"edge_id": "edge-xyz-789",
"direction": "outgoing",
"edge_properties": {
"year": 1905
}
}
],
"total": 1,
"direction": "both"
}

Response Fields

FieldTypeDescription
node_idstringThe source node ID that was queried
neighborslist[NeighborNode]Connected nodes with relationship context
totalintTotal number of neighbors returned
directionstringDirection filter that was applied

NeighborNode Fields

FieldTypeDescription
nodeNodeFull neighbor node object (see Node Fields)
relationship_typestringEdge label describing the relationship
edge_idstringID of the connecting edge
directionstringoutgoing or incoming relative to the queried node
edge_propertiesobjectKey-value properties on the connecting edge

Errors

StatusDescription
404Node not found
400Invalid direction parameter (must be outgoing, incoming, or both)