Skip to main content
Glama
vjsr007
by vjsr007

graph-neighbors

Find connected nodes in a knowledge graph by specifying a node ID or label, exploring relationships up to a defined depth and limit. Supports semantic analysis and concept mapping.

Instructions

Get neighbors of a node (by id or label/type) up to a depth and limit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
depthNo
limitNo
nodeYes

Implementation Reference

  • Handler for the 'graph-neighbors' MCP tool. Parses input using GraphNeighborsSchema and calls the graph store's neighbors method to retrieve neighboring nodes.
    case 'graph-neighbors': {
      const parsed = GraphNeighborsSchema.parse(args);
      const nodes = graph.neighbors(parsed.node as any, parsed.depth, parsed.limit);
      return { content: [{ type: 'text', text: JSON.stringify(nodes) }] };
  • Zod schema defining the input structure for the graph-neighbors tool, including node identifier, optional depth and limit parameters.
    export const GraphNeighborsSchema = z.object({
      node: z.union([
        z.number().int().positive(),
        z.object({ label: z.string(), type: z.string().optional() }),
      ]),
      depth: z.number().int().positive().max(6).optional().default(1),
      limit: z.number().int().positive().max(200).optional().default(50),
    });
    export type GraphNeighborsInput = z.infer<typeof GraphNeighborsSchema>;
  • src/mcp.ts:170-173 (registration)
    MCP tool registration in the tools array, defining name, description, and basic input schema for 'graph-neighbors'.
      name: 'graph-neighbors',
      description: 'Get neighbors of a node (by id or label/type) up to a depth and limit.',
      inputSchema: { type: 'object', properties: { node: { anyOf: [{ type: 'number' }, { type: 'object', properties: { label: { type: 'string' }, type: { type: 'string' } }, required: ['label'] }] }, depth: { type: 'number' }, limit: { type: 'number' } }, required: ['node'] },
    },
  • Core implementation of the neighbors traversal algorithm in SqliteGraphStore using BFS to collect neighboring nodes up to specified depth and limit.
    neighbors(node: number | { label: string; type?: string }, depth = 1, limit = 50): GraphNode[] {
      const startId = this.resolveNodeId(node);
      if (!startId) return [];
      const collected: number[] = [];
      this.bfsTraverse(startId, depth, (dst) => {
        collected.push(dst);
        return collected.length < limit;
      });
      return this.nodesByIds(collected);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions depth and limit parameters but doesn't explain key behaviors like whether this is a read-only operation, what happens if the node doesn't exist, if results are paginated, or the format of returned neighbors. For a graph query tool, this is a significant gap in transparency.

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 that front-loads the core purpose ('Get neighbors of a node') and includes key parameter context. Every word earns its place, with no redundancy or fluff, making it highly concise and well-structured for quick comprehension.

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 complexity of a graph traversal tool with 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks details on behavior, error handling, return format, and practical usage, which are essential for an agent to invoke this tool correctly in a graph context.

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 lists parameters (node, depth, limit) but adds minimal semantics: 'by id or label/type' hints at node options, and 'up to a depth and limit' suggests constraints. However, it doesn't explain what 'neighbors' means in this context, how depth works (e.g., breadth-first), or units for limit, leaving parameters poorly understood.

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 action ('Get neighbors') and resource ('of a node'), specifying it operates on a graph node. It distinguishes from siblings like graph-path or graph-stats by focusing on neighbor retrieval rather than pathfinding or statistics. However, it doesn't explicitly differentiate from all siblings (e.g., graph-node-upsert), keeping it at 4 instead of 5.

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 prerequisites, such as needing an existing node, or compare to other graph tools like graph-path for different traversal needs. This lack of context leaves the agent without usage direction.

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