Host a custom MCP server
Host custom or third-party MCP servers as Databricks apps. Custom MCP servers are useful if you already have an MCP server you want to deploy or if you want to run a third-party MCP server as a source of tools.
Access to custom MCP servers is controlled through Databricks Apps permissions. To monitor custom MCP activity alongside your other MCP servers and LLM endpoints, use Unity AI Gateway.
To use a hosted custom MCP server in agent code, see Use custom MCP servers in agents.
Requirements
- An MCP server hosted as a Databricks app must implement an HTTP-compatible transport, such as the streamable HTTP transport.
Create or deploy a custom MCP server
Choose the option that matches your starting point:
Start from a template: create a new MCP server from the built-in Hello World template
Create a custom MCP server from the Apps template
Use the built-in Hello World MCP Server template to create and deploy an MCP server with example tools already included:
-
In the sidebar, click Compute.
-
Click the Apps tab.
-
Click Create app.
-
Under the Agents category, select the MCP Server - Hello World template.
-
Enter an app name starting with
mcp-(for example,mcp-hello-world).noteThe app name must start with
mcp-to be recognized as an MCP server in the AI Playground. -
Click Create app.
Databricks deploys the app with example code that you can customize.
The template includes two example tools to get you started:
health(): A diagnostic tool that confirms the server is operational and returns status information.get_current_user(): A tool that retrieves the current user's information using the Databricks SDK, demonstrating how to integrate workspace authentication.
Add a custom tool
To add your own tool, open the app source code and define a new function using the @mcp.tool() decorator. For example, the following tool converts a string to uppercase:
@mcp.tool()
def uppercase(text: str) -> str:
"""Convert a string to uppercase."""
return text.upper()
Each tool must include a docstring. AI agents use the docstring to understand when to call the tool. After adding a tool, redeploy the app to make it available.
See Create an app from a template for more details on working with app templates, or see the template source code on GitHub.
Deploy an existing server: host an MCP server you already have as a Databricks App
Host an existing MCP server as a Databricks App
To host an existing Python MCP server as a Databricks app, follow these steps:
Set up your environment
Before deploying your MCP server, authenticate to your workspace using OAuth.
-
Run the following in a local terminal:
Bashdatabricks auth login --host https://<your-workspace-hostname>
Set up the MCP server
Use uv for dependency management and unified tooling when deploying your MCP server.
-
Add a
requirements.txtto the MCP server's root directory and includeuvas a dependency.uvhandles installing additional dependencies defined in your project configuration.Txtuv -
Create a
pyproject.tomlfile that defines a script entry point for your server.Example
pyproject.toml:Toml[project.scripts]
custom-server = "server.main:main"In this example:
custom-serveris the script name you use withuv runserver.main:mainspecifies the module path (server/main.py) and function (main) to execute
-
Add an
app.yamlfile specifying the CLI command to run the MCP server usinguv run.By default, Databricks apps listen on port 8000. If the server listens on a different port, set it using an environment variable override in the
app.yamlfile.Example
app.yaml:YAMLcommand: [
'uv',
'run',
'custom-server', # This must match a script defined in pyproject.toml
]
When you run uv run custom-server, uv looks up the script definition, finds the module path, and calls the main() function.
Deploy the MCP server as a Databricks app
-
Create a Databricks app to host the MCP server:
Bashdatabricks apps create mcp-my-servernotePrefix your app name with
mcp-to clearly identify it as an MCP server. This naming convention helps with discoverability and organization in your workspace. -
Upload the source code to Databricks and deploy the app by running the following commands from the directory containing your
app.yamlfile:BashDATABRICKS_USERNAME=$(databricks current-user me | jq -r .userName)
databricks sync . "/Users/$DATABRICKS_USERNAME/mcp-my-server"
databricks apps deploy mcp-my-server --source-code-path "/Workspace/Users/$DATABRICKS_USERNAME/mcp-my-server"
Find your deployed app URL
After deployment, you can find your app URL in the Databricks UI. The MCP server endpoint is available at https://<app-url>/mcp.
Next steps
- Use custom MCP servers in agents — connect to the hosted server from notebooks, local environments, and agent code.
- Connect clients to Databricks MCPs — wire up Claude, Cursor, MCP Inspector, and other external clients.