Skip to main content
Glama

BYOKG

Shortest paths between two nodes

find_shortest_paths
Read-onlyIdempotent

Find 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

NameRequiredDescriptionDefault
limitNoShortest paths returned.
max_hopsNoLongest path searched.
data_modeNoEdge model to read; AUTO resolves the room's single mode.AUTO
directionNoHow a directed edge is walked from the source.OUTGOING
max_pathsNoDeprecated since contract revision 4.9.0: pass limit instead (one name for every answer's size); still accepted.
source_refNoStart node by reference, as get_node's ref.
target_refNoEnd node by reference, as get_node's ref.
namespace_idNoRoom name; omitted: the default room.
relation_typesNoOnly these relation types, at every hop.
source_node_idNoStart node's node_id, or pass source_ref.
target_node_idNoEnd node's node_id, or pass target_ref.

Output Schema

NameRequiredDescriptionDefault
hopsYesThe length of the shortest paths found, null when none was found.
nodesYesThe nodes on the paths returned and the two ends.
pathsYes
statsYes
completeYes
max_hopsYes
warningsNoAdded 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_modeYes
directionYes
read_onlyYes
generationYes
paths_foundYesEvery shortest path found (within PATHS_SCAN), of which paths holds at most max_paths.
namespace_idYes
explored_nodesYesThe nodes the two sides reached while searching.
source_node_idYes
target_node_idYes
truncation_reasonsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Far beyond the annotations, it discloses the bidirectional hop-bounded search and its stopping rule, how budgets truncate results (truncation_reasons values), and the crucial distinction that hops:null with complete:true means no path exists while truncated results never imply disconnectedness. It also flags that results are graph evidence, not asserted relations. It loses a point only because this behavioral detail is buried in a densely packed block rather than surfaced where a scanning agent would catch it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The content is valuable but delivered as one sprawling block with no headings, and the same point is made twice ("An indirect A->B->C path is not an asserted A->C relation" and later "An indirect path is graph evidence, never an asserted relation between its ends"). The trailing contract-revision history ("Added in contract revision 4.6.0...") and the meta note about which revision is current do not help an agent decide or invoke, so they do not earn their space.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given an 11-parameter tool with an output schema and read-only annotations, the description covers selection, invocation constraints, failure modes, truncation semantics, and the epistemic status of returned paths. Nothing an agent needs in order to call it correctly or interpret results is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 100%, so the baseline is 3, and the description earns more by explaining cross-parameter rules the schema cannot express: source_ref/source_node_id are mutually exclusive, limit and the deprecated max_paths conflict with SCHEMA_VALIDATION_FAILED, relation_types applies at every hop, direction reports stored orientation regardless of walk direction, and AUTO fails with DATA_MODE_SELECTOR_REQUIRED when ambiguous. It goes further by defining how a ref resolves and which errors fire on ambiguity or missing nodes.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence names a specific verb and resource (find every shortest path between two nodes) and ties it to the user intent it serves. It explicitly separates itself from the sibling query_graph_paths ("For the paths that lead from one node, use query_graph_paths"), so an agent can route correctly without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description states when to use it (the user asks how two things are connected), names the alternative for the single-source case, and gives the invocation constraint that exactly one end form is required per end with INVALID_PATH_SELECTION otherwise. It even supplies a concrete example call, leaving little to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources