Shortest paths between two nodes
find_shortest_pathsFind every shortest path between two nodes when the user asks how two things are connected. Input: both ends, each as a node_id (source_node_id, target_node_id) or as a reference as get_node takes it (source_ref, target_ref); namespace_id, max_hops, limit. Returns hops, the length found, and paths, every shortest path up to limit ordered by edge ids (paths_found counts them all). Each step is an EXISTING edge with its stable id, stored orientation, relation type and evidence references (fetch accepts the ids). An indirect A->B->C path is not an asserted A->C relation; label any such hypothesis NOT_CONFIRMED and cite the observed path. complete false with truncation_reasons means a budget ended the search, never that no connection exists; hops null with complete true means the data holds no path. No model, embedding, Graphiti or write call. The search runs from both ends by hops (the source side walks direction, the target side its reverse) within budgets of nodes, edge records and time and stops at the first depth the two sides meet, so a connection four or five hops away costs a few hundred nodes rather than a quarter of the room. An indirect path is graph evidence, never an asserted relation between its ends. truncation_reasons names a budget that ended the search (NODE_BUDGET, EDGE_WORK, DEADLINE, MAX_HOPS when the two sides do not meet within max_hops) or cut the answer (MAX_PATHS, when the list was cut; PATHS_SCAN). Warnings say when an end has no edges the way it is walked (ISOLATED_NODE, NO_OUTGOING_EDGES, NO_INCOMING_EDGES). For a curated relation a step carries its curation. relation_types restricts every hop. direction takes the values of query_graph_paths; each relationship reports its stored orientation whichever way it was walked. data_mode: one physical edge model per request; AUTO resolves the room's single data mode and fails with DATA_MODE_SELECTOR_REQUIRED when ambiguous. For the paths that lead from one node, use query_graph_paths. One of the two forms is required at each end, not both; the two ends are different nodes (INVALID_PATH_SELECTION otherwise). A reference resolves as get_node resolves ref (its external id as the bundle states it, such as GO:0008150, one of its alt_ids, its IRI, a name a property of exactly one node states, or a node_id), with NODE_REF_AMBIGUOUS and its candidates when several nodes match and GRAPH_NODE_NOT_FOUND when none does; the response's source_node_id and target_node_id are the nodes it resolved to. A node_id from another room is GRAPH_NODE_NOT_FOUND with a message saying so: a node_id belongs to one room, as search, get_node, neighbors or paths hand it out, never a physical graph key. limit is the name every tool uses for the size of its answer (max_paths is its deprecated alias; passing both is SCHEMA_VALIDATION_FAILED). Example: {"source_ref": "GO:0005739", "target_ref": "GO:0005737", "namespace_id": "obo-go"}. Added in contract revision 4.6.0. Since contract revision 4.9.0 either end may be given by reference (source_ref, target_ref), and limit is the name of max_paths (which stays as a deprecated alias). The contract revision in force is the one every response repeats in _meta.contract_revision and server_info reports; a revision note (Added in, Since) says when a field or a tool appeared, never which revision is current.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "find_shortest_paths"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Shortest paths returned. | |
| max_hops | No | Longest path searched. | |
| data_mode | No | Edge model to read; AUTO resolves the room's single mode. | AUTO |
| direction | No | How a directed edge is walked from the source. | OUTGOING |
| max_paths | No | Deprecated since contract revision 4.9.0: pass limit instead (one name for every answer's size); still accepted. | |
| source_ref | No | Start node by reference, as get_node's ref. | |
| target_ref | No | End node by reference, as get_node's ref. | |
| namespace_id | No | Room name; omitted: the default room. | |
| relation_types | No | Only these relation types, at every hop. | |
| source_node_id | No | Start node's node_id, or pass source_ref. | |
| target_node_id | No | End node's node_id, or pass target_ref. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hops | Yes | The length of the shortest paths found, null when none was found. | |
| nodes | Yes | The nodes on the paths returned and the two ends. | |
| paths | Yes | ||
| stats | Yes | ||
| complete | Yes | ||
| max_hops | Yes | ||
| warnings | No | Added in contract revision 4.1.0. Set when no path exists because an end node has no edge (ISOLATED_NODE) or only edges the other way round (NO_OUTGOING_EDGES for the source, NO_INCOMING_EDGES for the target); empty otherwise. | |
| data_mode | Yes | ||
| direction | Yes | ||
| read_only | Yes | ||
| generation | Yes | ||
| paths_found | Yes | Every shortest path found (within PATHS_SCAN), of which paths holds at most max_paths. | |
| namespace_id | Yes | ||
| explored_nodes | Yes | The nodes the two sides reached while searching. | |
| source_node_id | Yes | ||
| target_node_id | Yes | ||
| truncation_reasons | Yes |