Skip to main content
Glama

authenticate

Authenticate with Databricks via OAuth to enable interaction with Databricks-hosted tools through Claude. Opens browser for authorization.

Instructions

Authenticate with Databricks using OAuth U2M flow.
Opens a browser for authorization.
Uses DATABRICKS_HOST and DATABRICKS_APP_URL from app.yaml or environment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool()-decorated 'authenticate' function implements the tool logic: reads config, starts OAuth flow using start_oauth_flow, creates DatabricksMCPProxy, connects and discovers tools, sets authenticated state, and returns list of available tools.
    @mcp.tool()
    def authenticate() -> str:
        """
        Authenticate with Databricks using OAuth U2M flow.
        Opens a browser for authorization.
        Uses DATABRICKS_HOST and DATABRICKS_APP_URL from app.yaml or environment.
        """
        try:
            host = state.host or os.environ.get("DATABRICKS_HOST")
            app_url = state.app_url or os.environ.get("DATABRICKS_APP_URL")
            scopes = state.scopes or os.environ.get("DATABRICKS_SCOPES", DEFAULT_SCOPES)
            
            if not host:
                return "Error: DATABRICKS_HOST not configured. Set it in app.yaml or environment."
            if not app_url:
                return "Error: DATABRICKS_APP_URL not configured. Set it in app.yaml or environment."
            
            print(f"Starting OAuth flow for {host}...", file=sys.stderr)
            access_token = start_oauth_flow(host, scopes)
            
            state.proxy = DatabricksMCPProxy(host, app_url, access_token)
            state.proxy.connect()
            state.proxy.discover_tools()
            state.authenticated = True
            
            tool_names = [t.name for t in state.proxy.tools]
            return f"Authenticated successfully!\n\nAvailable tools ({len(tool_names)}):\n" + "\n".join(f"  - {name}" for name in tool_names)
        
        except Exception as e:
            state.authenticated = False
            return f"Authentication failed: {e}"
  • The 'start_oauth_flow' function performs the core OAuth U2M flow: generates PKCE, opens browser to auth URL, handles callback with local HTTP server, exchanges code for access token.
    def start_oauth_flow(host: str, scopes: str = DEFAULT_SCOPES, redirect_uri: str = DEFAULT_REDIRECT_URI) -> str:
        """
        Start OAuth U2M flow and return access token.
        Opens browser for user authorization.
        """
        host = host.rstrip("/")
        state = secrets.token_urlsafe(32)
        code_verifier, code_challenge = generate_pkce_pair()
    
        auth_params = {
            "client_id": CLIENT_ID,
            "redirect_uri": redirect_uri,
            "response_type": "code",
            "state": state,
            "code_challenge": code_challenge,
            "code_challenge_method": "S256",
            "scope": scopes,
        }
        auth_url = f"{host}/oidc/v1/authorize?{urlencode(auth_params)}"
    
        # Reset state
        OAuthCallbackHandler.authorization_code = None
        OAuthCallbackHandler.state_value = None
    
        # Start callback server
        redirect_port = int(urlparse(redirect_uri).port or 8020)
        server = HTTPServer(("localhost", redirect_port), OAuthCallbackHandler)
        server.timeout = 300
    
        # Open browser
        print(f"Opening browser for authorization...", file=sys.stderr)
        webbrowser.open(auth_url)
    
        # Wait for callback
        print(f"Waiting for authorization callback on {redirect_uri}...", file=sys.stderr)
        server.handle_request()
    
        if OAuthCallbackHandler.state_value != state:
            raise ValueError("State mismatch! Possible CSRF attack.")
        if not OAuthCallbackHandler.authorization_code:
            raise ValueError("No authorization code received.")
    
        # Exchange code for token
        print("Exchanging code for token...", file=sys.stderr)
        token_response = requests.post(
            f"{host}/oidc/v1/token",
            data={
                "client_id": CLIENT_ID,
                "grant_type": "authorization_code",
                "scope": scopes,
                "redirect_uri": redirect_uri,
                "code_verifier": code_verifier,
                "code": OAuthCallbackHandler.authorization_code,
            }
        )
        if token_response.status_code != 200:
            raise ValueError(f"Token exchange failed: {token_response.text}")
    
        print("Token obtained successfully!", file=sys.stderr)
        return token_response.json()["access_token"]
  • FastMCP server instance creation where tools are registered via decorators.
    mcp = FastMCP("databricks-mcp-proxy")
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the OAuth flow type, browser interaction, and environment variable usage. However, it misses details like error handling, timeout behavior, or what happens post-authentication (e.g., token storage). It doesn't contradict annotations, as none exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured: three short sentences that are front-loaded with the core purpose, followed by implementation details. Every sentence adds value without redundancy, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (authentication with OAuth), no annotations, and an output schema present, the description is reasonably complete. It covers the method, user interaction, and configuration sources. However, it could benefit from mentioning the output (e.g., token or session) or prerequisites, but the output schema mitigates some of this gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately adds context about environment variables (DATABRICKS_HOST, DATABRICKS_APP_URL) that aren't in the schema, providing useful operational semantics beyond the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Authenticate with Databricks using OAuth U2M flow.' It specifies the action (authenticate), target system (Databricks), and method (OAuth U2M flow). However, it doesn't explicitly differentiate from sibling tools like 'call_databricks_tool' or 'list_databricks_tools' in terms of authentication vs. subsequent operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning it 'Opens a browser for authorization' and uses environment variables, suggesting it's for initial setup. However, it lacks explicit guidance on when to use this vs. alternatives (e.g., whether it's required before calling sibling tools) or any exclusions, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/smaheshwari-ux/databricks-mcp-proxy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server