Skip to content

Add workspace object tools (list, read, create notebooks and directories)#418

Open
jralfonsog wants to merge 4 commits intodatabricks-solutions:mainfrom
jralfonsog:feat/workspace-notebook-crud
Open

Add workspace object tools (list, read, create notebooks and directories)#418
jralfonsog wants to merge 4 commits intodatabricks-solutions:mainfrom
jralfonsog:feat/workspace-notebook-crud

Conversation

@jralfonsog
Copy link
Copy Markdown

Summary

  • List workspace directory: Browse workspace paths — returns object type, language, size, and timestamps for each item
  • Get workspace object status: Retrieve metadata for a single notebook, file, or directory
  • Read notebook: Export notebook content in SOURCE (decoded text), JUPYTER, HTML, DBC, or RAW formats
  • Create notebook: Create or overwrite notebooks from inline source code (Python, SQL, Scala, R)
  • Create workspace directory: Create directories with automatic parent creation (idempotent)

Architecture

Layer File Description
Core library databricks_tools_core/file/workspace_objects.py 5 functions returning serializable dicts with error handling
MCP tools databricks_mcp_server/tools/workspace_objects.py Thin wrappers with @mcp.tool decorators and user-facing docstrings
Unit tests tests/unit/test_workspace_objects.py 25 tests covering happy paths, error handling, format validation

Builds on the existing file/ module (which already has upload/delete) by adding browse and read capabilities that were previously missing.

Test plan

  • 25 unit tests pass (pytest tests/unit/test_workspace_objects.py -v)
  • Ruff lint and format pass
  • Integration tested against live workspace:
    • list_workspace_directory("/Users") returns 5,765 objects
    • create_workspace_directory + create_notebook + read_notebook + get_workspace_object_status round-trip verified
    • Not-found error handling returns structured error dict
    • Overwrite mode works correctly
    • Test resources cleaned up

This pull request was AI-assisted by Isaac.

Add 5 new functions to browse and manage workspace objects:
- list_workspace_directory: list files/folders in a workspace path
- get_workspace_object_status: get metadata for a single object
- read_notebook: export/read notebook content in various formats
- create_notebook: create notebooks from inline content
- create_workspace_directory: create directories (with parents)

Co-authored-by: Isaac
Wrap the 5 core workspace object functions as MCP tools:
- list_workspace_directory (timeout=30)
- get_workspace_object_status (timeout=30)
- read_notebook (timeout=30)
- create_notebook (timeout=60)
- create_workspace_directory (timeout=30)

Co-authored-by: Isaac
Cover all 5 functions: list_workspace_directory, get_workspace_object_status,
read_notebook, create_notebook, create_workspace_directory. Tests include
happy paths, error handling, format validation, and case insensitivity.

Co-authored-by: Isaac
- Docstrings: opening """ on its own line
- MCP module header: add tool listing
- Serialization: use getattr() for defensive SDK object access
- Returns sections: bullet list format for dict keys

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant