Skip to content

POC: deploy a streamable HTTP server on Databricks apps and connect to it from the client#1

Open
smurching wants to merge 2 commits into
mainfrom
smurching/databricks-apps-poc
Open

POC: deploy a streamable HTTP server on Databricks apps and connect to it from the client#1
smurching wants to merge 2 commits into
mainfrom
smurching/databricks-apps-poc

Conversation

@smurching
Copy link
Copy Markdown
Owner

@smurching smurching commented May 7, 2025

In this POC, I'm trying out deploying the example MCP server from the MCP Python SDK repo as a Databricks app, and then connecting to it using the Python client. To run the POC:

  1. Deploy the app under examples/servers/simple-streamablehttp following the steps here (create app, sync code to workspace, deploy app)
  2. Generate a Databricks oauth token following these steps
  3. Update the server URL here to the URL of your Databricks app
  4. Run uv run pytest tests/shared/test_streamable_http.py to test connecting to the app etc

It's also possible now to write your own custom client code that resembles the code in uv run pytest tests/shared/test_streamable_http.py - just make sure you have mcp>=1.8.2 installed

…o it from the client

Signed-off-by: Sid Murching <sid.murching@databricks.com>
async def initialized_client_session(basic_server, basic_server_url):
"""Create initialized StreamableHTTP client session."""
async with streamablehttp_client(f"{basic_server_url}/mcp") as (
token = "TODO add token here"
Copy link
Copy Markdown
Owner Author

@smurching smurching May 7, 2025

Choose a reason for hiding this comment

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

I used code like this to get an oauth token, after doing databricks auth login --profile fieldeng-oauth:

from databricks import sdk

w = sdk.WorkspaceClient(profile="fieldeng-oauth")
headers = w.config.authenticate()
print(headers)

Using a PAT to talk to apps doesn't work

Signed-off-by: Sid Murching <sid.murching@databricks.com>
"run",
"mcp-simple-streamablehttp",
"--port",
"8000",
Copy link
Copy Markdown
Owner Author

@smurching smurching May 7, 2025

Choose a reason for hiding this comment

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

Using port 8000 since that's what apps exposes by default, though this is configurable via environment variable

"""Create initialized StreamableHTTP client session."""
async with streamablehttp_client(f"{basic_server_url}/mcp") as (
token = "TODO add token here"
async with streamablehttp_client(url=f"{basic_server_url}/mcp/", headers={'Authorization': f'Bearer {token}'}) as (
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Note: when running against the example server in the MCP repo, the client has to connect to /mcp/

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