list_notebooks
Retrieve a list of notebooks within a specified workspace directory on Databricks MCP Server for efficient workspace navigation and management.
Instructions
List notebooks in a workspace directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- MCP tool handler for 'list_notebooks' that delegates to the notebooks API and serializes the result to JSON string.@mcp.tool() async def list_notebooks(path: str) -> str: """List notebooks in a workspace directory""" logger.info(f"Listing notebooks in: {path}") try: result = await notebooks.list_notebooks(path) return json.dumps(result) except Exception as e: logger.error(f"Error listing notebooks: {str(e)}") return json.dumps({"error": str(e)})
- src/api/notebooks.py:93-107 (helper)Core helper function implementing the Databricks workspace/list API call to list notebooks/directories.async def list_notebooks(path: str) -> Dict[str, Any]: """ List notebooks in a workspace directory. Args: path: The path to list Returns: Response containing the directory listing Raises: DatabricksAPIError: If the API request fails """ logger.info(f"Listing notebooks in path: {path}") return make_api_request("GET", "/api/2.0/workspace/list", params={"path": path})
- src/server/simple_databricks_mcp_server.py:253-262 (registration)Registration of the 'list_notebooks' tool via @mcp.tool() decorator in the FastMCP server.@mcp.tool() async def list_notebooks(path: str) -> str: """List notebooks in a workspace directory""" logger.info(f"Listing notebooks in: {path}") try: result = await notebooks.list_notebooks(path) return json.dumps(result) except Exception as e: logger.error(f"Error listing notebooks: {str(e)}") return json.dumps({"error": str(e)})