Skip to main content
Glama
nebula-contrib

NebulaGraph MCP Server

find_neighbors

Query connected vertices in a NebulaGraph database to analyze relationships and explore graph structures by specifying a starting vertex and traversal depth.

Instructions

Find the neighbors of the specified vertex Args: vertex: The vertex ID to query space: The space to use depth: The depth of the query, default is 1 Returns: The neighbors of the specified vertex

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vertexYes
spaceYes
depthNo

Implementation Reference

  • The handler function for the 'find_neighbors' MCP tool, decorated with @mcp.tool() for registration. It receives parameters and delegates to the helper resource function.
    @mcp.tool()
    def find_neighbors(vertex: str, space: str, depth: int = 1) -> str:
        """Find the neighbors of the specified vertex
        Args:
            vertex: The vertex ID to query
            space: The space to use
            depth: The depth of the query, default is 1
        Returns:
            The neighbors of the specified vertex
        """
        return get_neighbors_resource(space, vertex, depth)
  • Core helper function implementing the neighbor query logic using NebulaGraph nGQL MATCH query to find vertices and edges connected to the given vertex up to specified depth.
    @mcp.resource("neighbors://space/{space}/vertex/{vertex}/depth/{depth}")
    def get_neighbors_resource(space: str, vertex: str, depth: int) -> str:
        """Get the neighbors of the specified vertex
        Args:
            space: The space to use
            vertex: The vertex ID to query
            depth: The depth of the query
        Returns:
            The neighbors of the specified vertex
        """
        pool = get_connection_pool()
        session = pool.get_session(
            os.getenv("NEBULA_USER", "root"), os.getenv("NEBULA_PASSWORD", "nebula")
        )
    
        try:
            session.execute(f"USE {space}")
    
            query = f"""
            MATCH (u)-[e*1..{depth}]-(v)
            WHERE id(u) == "{vertex}"
            RETURN DISTINCT v, e
            """
    
            result = session.execute(query)
            if result.is_succeeded():
                if result.row_size() > 0:
                    output = f"Vertex {vertex} neighbors (depth {depth}):\n\n"
                    for i in range(result.row_size()):
                        row = result.row_values(i)
                        neighbor_vertex = row[0]
                        edges = row[1]
                        output += (
                            f"Neighbor Vertex:\n{neighbor_vertex}\nEdges:\n{edges}\n\n"
                        )
                    return output
                return f"No neighbors found for vertex {vertex}"
            else:
                return f"Query failed: {result.error_msg()}"
        finally:
            session.release()
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 mentions that the tool returns neighbors, but does not describe traits like whether it's read-only, if it has side effects, performance characteristics, error handling, or rate limits. For a query tool with zero annotation coverage, this is a significant gap, though it doesn't contradict any annotations.

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

Conciseness3/5

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

The description is structured with sections for 'Args' and 'Returns', which is helpful, but it includes redundant information (e.g., repeating 'The neighbors of the specified vertex' in the Returns section). It is front-loaded with the core purpose, but some sentences could be more efficient (e.g., the Returns section adds little beyond the initial statement). Overall, it's adequately concise but not optimally streamlined.

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, no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It covers the basic purpose and parameter meanings but lacks crucial context: it doesn't explain what a 'neighbor' entails (e.g., direct connections, types of relationships), the structure of the return value, error conditions, or how it integrates with sibling tools. For a graph query tool, this leaves significant gaps for an AI agent.

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

Parameters3/5

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

Schema description coverage is 0%, so the schema provides no parameter descriptions. The description adds basic semantics: it explains that 'vertex' is the 'vertex ID to query', 'space' is 'The space to use', and 'depth' is 'The depth of the query, default is 1'. This compensates partially by clarifying what each parameter represents, but it lacks details like format, constraints, or examples (e.g., what a 'space' is or valid 'depth' ranges).

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 tool's purpose: 'Find the neighbors of the specified vertex' with a specific verb ('Find') and resource ('neighbors of the specified vertex'). It distinguishes from siblings like 'find_path' (which finds paths) and 'execute_query' (which executes queries), though it doesn't explicitly mention these distinctions. The purpose is not tautological (it explains what 'find_neighbors' means) and is not misleading.

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 does not mention sibling tools like 'find_path' (for finding paths between vertices) or 'execute_query' (for general queries), nor does it specify contexts or exclusions. Usage is implied only by the tool's name and purpose, with no explicit instructions.

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/nebula-contrib/nebulagraph-mcp-server'

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