Skip to main content
Glama
vjsr007
by vjsr007

graph-path

Identify paths between nodes in a graph by specifying start and end points using IDs or labels. Supports exploration of relationships with customizable depth for efficient analysis.

Instructions

Find a path of nodes from A to B (by id or label/type).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromYes
maxDepthNo
toYes

Implementation Reference

  • MCP tool handler for 'graph-path': parses arguments using GraphPathSchema, invokes graph.path() method, and returns JSON serialized path nodes.
    case 'graph-path': {
      const parsed = GraphPathSchema.parse(args);
      const nodes = graph.path(parsed.from as any, parsed.to as any, parsed.maxDepth);
      return { content: [{ type: 'text', text: JSON.stringify(nodes) }] };
    }
  • Zod schema definition GraphPathSchema used for input validation of the graph-path tool, supporting node IDs or label/type objects for 'from' and 'to', with optional maxDepth.
    export const GraphPathSchema = z.object({
      from: z.union([
        z.number().int().positive(),
        z.object({ label: z.string(), type: z.string().optional() }),
      ]),
      to: z.union([
        z.number().int().positive(),
        z.object({ label: z.string(), type: z.string().optional() }),
      ]),
      maxDepth: z.number().int().positive().max(10).optional().default(4),
    });
    export type GraphPathInput = z.infer<typeof GraphPathSchema>;
  • src/mcp.ts:175-178 (registration)
    Tool registration object added to the MCP tools array, defining name, description, and inputSchema for graph-path.
      name: 'graph-path',
      description: 'Find a path of nodes from A to B (by id or label/type).',
      inputSchema: { type: 'object', properties: { from: { anyOf: [{ type: 'number' }, { type: 'object', properties: { label: { type: 'string' }, type: { type: 'string' } }, required: ['label'] }] }, to: { anyOf: [{ type: 'number' }, { type: 'object', properties: { label: { type: 'string' }, type: { type: 'string' } }, required: ['label'] }] }, maxDepth: { type: 'number' } }, required: ['from', 'to'] },
    },
  • Core path-finding implementation in SqliteGraphStore using BFS (via bfsPath helper), resolving node IDs, querying DB for path nodes, and mapping to GraphNode objects.
    path(from: number | { label: string; type?: string }, to: number | { label: string; type?: string }, maxDepth = 4): GraphNode[] {
      const fromId = this.resolveNodeId(from);
      const toId = this.resolveNodeId(to);
      if (!fromId || !toId) return [];
      const ids = this.bfsPath(fromId, toId, maxDepth);
      if (!ids.length) return [];
      const rows = this.db.prepare(`SELECT id,label,type,props FROM graph_nodes WHERE id IN (${ids.map(() => '?').join(',')})`).all(...ids) as any[];
      const byId = new Map(rows.map((r) => [r.id, r] as const));
      return ids.map((id) => this.mapRow(byId.get(id)!));
    }
  • IGraphStore interface definition for the path method, which the tool handler invokes.
    path(from: number | { label: string; type?: string }, to: number | { label: string; type?: string }, maxDepth?: number): GraphNode[];
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action 'Find a path' but doesn't describe what happens if no path exists, whether the operation is read-only or has side effects, performance characteristics, or output format. For a tool with 3 parameters and no annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero wasted words. It front-loads the core purpose ('Find a path of nodes from A to B') and adds necessary detail ('by id or label/type') in a parenthetical. This is appropriately sized for the tool's complexity.

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

Completeness2/5

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

Given the tool has 3 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It covers the basic purpose but lacks details on parameter usage, behavioral traits, and return values. For a path-finding operation in a graph context, more context is needed to use it effectively.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions that 'from' and 'to' can be specified 'by id or label/type', which adds some meaning beyond the schema's structural definition. However, it doesn't explain 'maxDepth' at all, and the coverage gap for all 3 parameters is only partially addressed, leaving key semantics unclear.

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

Purpose4/5

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

The description clearly states the verb 'Find' and resource 'path of nodes from A to B', making the purpose understandable. It distinguishes from some siblings like 'graph-neighbors' (which finds neighbors rather than paths) and 'graph-node-upsert' (which modifies nodes). However, it doesn't explicitly differentiate from all graph-related tools like 'graph-stats' or non-graph tools.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when path-finding is appropriate compared to other graph operations like 'graph-neighbors' or 'graph-stats', nor does it specify prerequisites or exclusions. The agent must infer usage from the purpose alone.

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

Install Server

Other Tools

Latest Blog Posts

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/vjsr007/mcp-index-notes'

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