Skip to main content
Glama
nebula-contrib

NebulaGraph MCP Server

execute_query

Run queries on NebulaGraph database to retrieve graph data and insights from specified spaces.

Instructions

Execute a query Args: query: The query to execute space: The space to use Returns: The results of the query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
spaceYes

Implementation Reference

  • The 'execute_query' tool handler function. Decorated with @mcp.tool(), it connects to NebulaGraph, switches to the specified space, executes the provided query, formats and returns the results or error message.
    @mcp.tool()
    def execute_query(query: str, space: str) -> str:
        """Execute a query
        Args:
            query: The query to execute
            space: The space to use
        Returns:
            The results of the query
        """
        pool = get_connection_pool()
        session = pool.get_session(
            os.getenv("NEBULA_USER", "root"), os.getenv("NEBULA_PASSWORD", "nebula")
        )
    
        try:
            session.execute(f"USE {space}")
            result = session.execute(query)
            if result.is_succeeded():
                # Format the query results
                if result.row_size() > 0:
                    columns = result.keys()
                    output = "Results:\n"
                    output += " | ".join(columns) + "\n"
                    output += "-" * (len(" | ".join(columns))) + "\n"
    
                    # Iterate through all rows
                    for i in range(result.row_size()):
                        row = result.row_values(i)
                        output += " | ".join(str(val) for val in row) + "\n"
                    return output
                return "Query executed successfully (no results)"
            else:
                return f"Query failed: {result.error_msg()}"
        finally:
            session.release()
  • The @mcp.tool() decorator registers the 'execute_query' function as an MCP tool.
    @mcp.tool()
  • Function signature and docstring define the input schema (query: str, space: str) and output (str) for the tool, used by MCP for validation.
    def execute_query(query: str, space: str) -> str:
        """Execute a query
        Args:
            query: The query to execute
            space: The space to use
        Returns:
            The results of the query
        """
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 executing a query and returning results but lacks details on permissions, rate limits, side effects, or error handling. This is inadequate for a mutation tool with zero annotation coverage.

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

Conciseness4/5

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

The description is brief and structured with sections for Args and Returns, making it easy to scan. However, it's under-specified rather than concise, as key details are missing, but the format is efficient.

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 no annotations, no output schema, and low schema coverage, the description is incomplete. It fails to explain query types, space context, result format, or error scenarios, leaving significant gaps for a tool with 2 required parameters.

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 'query' and 'space' but provides minimal semantics beyond their names (e.g., no format, examples, or constraints). This adds little value over the bare schema.

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

Purpose3/5

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

The description states the tool 'Execute a query' which provides a basic verb+resource combination, but it's vague about what type of query (e.g., database, graph, search) and doesn't distinguish from siblings like 'find_neighbors' or 'get_space_schema'. It's not tautological but lacks specificity.

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?

No guidance is provided on when to use this tool versus alternatives like 'find_neighbors' or 'list_spaces'. The description only lists arguments and returns, offering no context or exclusions for usage.

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