Commit 0ec0dcb
authored
Add headers to HttpRequestResponse in OpenAI client. (#1006)
## 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
```1 parent 436a999 commit 0ec0dcb
2 files changed
+29
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
98 | 111 | | |
99 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
100 | 116 | | |
101 | 117 | | |
102 | 118 | | |
| |||
109 | 125 | | |
110 | 126 | | |
111 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
112 | 133 | | |
0 commit comments