list_notebooks
Retrieve a list of notebooks from a specified workspace directory in Databricks to manage and organize your data projects.
Instructions
List notebooks in a workspace directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- MCP tool handler for the 'list_notebooks' tool. Takes a path parameter, lists notebooks using the notebooks API module, and returns the result as JSON or error message.@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)Helper function that implements the core logic by calling the Databricks Workspace API endpoint /api/2.0/workspace/list to list notebooks or files at the given path.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})