list_spaces
Retrieve all available graph database spaces to explore data structures and relationships within NebulaGraph.
Instructions
List all available spaces Returns: The available spaces
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function for the 'list_spaces' tool, decorated with @mcp.tool() for registration in the MCP server. It connects to NebulaGraph, executes 'SHOW SPACES' query, and formats the list of available spaces as output.@mcp.tool() def list_spaces() -> str: """List all available spaces Returns: The available spaces """ pool = get_connection_pool() session = pool.get_session( os.getenv("NEBULA_USER", "root"), os.getenv("NEBULA_PASSWORD", "nebula") ) try: result = session.execute("SHOW SPACES") if result.is_succeeded(): spaces = result.column_values("Name") return "Available spaces:\n" + "\n".join(f"- {space}" for space in spaces) return f"Failed to list spaces: {result.error_msg()}" finally: session.release()