Skip to content

Conversation

@sunishsheth2009
Copy link
Contributor

What changes are proposed in this pull request?

Adding headers to HttpRequestResponse when making http_request

Why?
Basically we need the response headers that is used in the MCP spec: https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#session-management
Specially Mcp-Session-Id header.

How is this tested?

%pip install git+https://github.com/sunishsheth2009/databricks-sdk-py@sunish-add-headers
import requests
import uuid
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import ExternalFunctionRequestHttpMethod

# Step 1: Initialize session
init_payload = {
    "jsonrpc": "2.0",
    "id": "init-1",
    "method": "initialize",
    "params": {}
}

init_response = WorkspaceClient().serving_endpoints.http_request(
  conn="github-u2m-managed-connection",
  method=ExternalFunctionRequestHttpMethod.POST,
  path="/mcp",
  json=init_payload,
)

session_id = init_response.headers["mcp-session-id"]
if not session_id:
    print("No session ID returned by server.")

print(f"✅ Got MCP Session ID: {session_id}")


Output:
✅ Got MCP Session ID: 53220122-015c-4e2b-9edb-47580cefffd0

@sunishsheth2009 sunishsheth2009 changed the title Adding headers to HttpRequestResponse when making http_request [ML-55696] Adding headers to HttpRequestResponse when making http_request Jul 17, 2025
@renaudhartert-db renaudhartert-db changed the title [ML-55696] Adding headers to HttpRequestResponse when making http_request Add headers to HttpRequestResponse in OpenAI client. Jul 17, 2025
Comment on lines +97 to +110
res = self._api.do(
"POST",
"/api/2.0/external-function",
body={
"connection_name": conn,
"method": method.value,
"path": path,
"headers": js.dumps(headers) if headers is not None else None,
"json": js.dumps(json) if json is not None else None,
"params": js.dumps(params) if params is not None else None,
},
headers={"Accept": "text/plain", "Content-Type": "application/json"},
raw=True,
response_headers=headers_to_capture,
Copy link
Contributor

Choose a reason for hiding this comment

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

@hectorcast-db, can you think of something better given the current libraries? Not using the underlying API method is really not ideal but I can't think of a better alternative with the code that we have right now.

auto-merge was automatically disabled July 21, 2025 16:07

Head branch was pushed to by a user without write access

@github-actions
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1006
  • Commit SHA: b7c44e34003fa5690d6b1d493e542ee257c8ec33

Checks will be approved automatically on success.

@renaudhartert-db renaudhartert-db added this pull request to the merge queue Jul 21, 2025
Merged via the queue into databricks:main with commit 0ec0dcb Jul 21, 2025
17 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.

2 participants