Skip to content

Add manage_workspace MCP tool for runtime workspace switching#204

Merged
calreynolds merged 2 commits intomainfrom
workspace-switching
Mar 4, 2026
Merged

Add manage_workspace MCP tool for runtime workspace switching#204
calreynolds merged 2 commits intomainfrom
workspace-switching

Conversation

@jacksandom
Copy link
Collaborator

Summary

  • Adds manage_workspace MCP tool with status, list, switch, and login actions for runtime workspace switching without restarting the MCP server
  • Extends auth.py with session-scoped workspace state (set_active_workspace / get_active_workspace) that overrides get_workspace_client() for all subsequent tool calls
  • Rewrites databricks-config skill to route workspace queries through the MCP tool via ToolSearch, solving discoverability with defer_loading: true

Resolves #123

Details

  • Switch validates credentials before committing, rolls back on failure
  • Detects expired tokens and returns structured response with login instructions
  • Login delegates to databricks auth login CLI for OAuth browser flow with stdin=DEVNULL and 120s timeout
  • Username cache invalidated on workspace switch to prevent stale identity
  • Session-scoped: resets on MCP server restart

Test plan

  • auth unit tests (databricks-tools-core/tests/unit/test_auth.py)
  • workspace tool tests (databricks-mcp-server/tests/test_workspace.py)
  • E2E: "what workspace am I on?" uses MCP tool, not Bash
  • E2E: "list my workspaces" returns formatted profile table
  • E2E: "switch to [profile]" switches and confirms
  • E2E: subsequent tool calls (e.g. list_warehouses) target the new workspace

@calreynolds calreynolds self-requested a review March 4, 2026 14:15
Copy link
Collaborator

@calreynolds calreynolds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful 👍

@calreynolds calreynolds merged commit 9f82702 into main Mar 4, 2026
2 checks passed
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.

Enable Natural Language Workspace Switching for AI Dev Kit Skills & MCP Tools

2 participants