Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/servers/simple-streamablehttp/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
command: [
"uv",
"run",
"mcp-simple-streamablehttp",
"--port",
"8000",

@smurching smurching May 7, 2025

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.

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

"--log-level",
"DEBUG"
]
5 changes: 4 additions & 1 deletion examples/servers/simple-streamablehttp/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[tool.hatch.metadata]
allow-direct-references = true

[project]
name = "mcp-simple-streamablehttp"
version = "0.1.0"
Expand All @@ -7,7 +10,7 @@ requires-python = ">=3.10"
authors = [{ name = "Anthropic, PBC." }]
keywords = ["mcp", "llm", "automation", "web", "fetch", "http", "streamable"]
license = { text = "MIT" }
dependencies = ["anyio>=4.5", "click>=8.1.0", "httpx>=0.27", "mcp", "starlette", "uvicorn"]
dependencies = ["anyio>=4.5", "click>=8.1.0", "httpx>=0.27", "mcp @ git+https://github.com/modelcontextprotocol/python-sdk.git@main", "starlette", "uvicorn"]

[project.scripts]
mcp-simple-streamablehttp = "mcp_simple_streamablehttp.server:main"
Expand Down
1 change: 1 addition & 0 deletions examples/servers/simple-streamablehttp/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uv
2 changes: 1 addition & 1 deletion src/mcp/shared/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ async def send_request(
)

# request read timeout takes precedence over session read timeout
timeout = None
timeout = 10
if request_read_timeout_seconds is not None:
timeout = request_read_timeout_seconds.total_seconds()
elif self._session_read_timeout_seconds is not None:
Expand Down
21 changes: 13 additions & 8 deletions tests/shared/test_streamable_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,10 @@ def json_response_server(json_server_port: int) -> Generator[None, None, None]:
@pytest.fixture
def basic_server_url(basic_server_port: int) -> str:
"""Get the URL for the basic test server."""
return f"http://127.0.0.1:{basic_server_port}"
# TODO(smurching) update this to point to the Databricks apps URL
res = f"https://unity-catalog-mcp-1444828305810485.aws.databricksapps.com"
print("basic_server_url", res)
return res


@pytest.fixture
Expand Down Expand Up @@ -776,7 +779,8 @@ async def http_client(basic_server, basic_server_url):
@pytest.fixture
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"

@smurching smurching May 7, 2025

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.

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

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/

read_stream,
write_stream,
_,
Expand Down Expand Up @@ -823,14 +827,15 @@ async def test_streamablehttp_client_tool_invocation(initialized_client_session)
"""Test client tool invocation."""
# First list tools
tools = await initialized_client_session.list_tools()
assert len(tools.tools) == 3
assert tools.tools[0].name == "test_tool"
assert len(tools.tools) == 1
assert tools.tools[0].name == "start-notification-stream"

# Call the tool
result = await initialized_client_session.call_tool("test_tool", {})
assert len(result.content) == 1
assert result.content[0].type == "text"
assert result.content[0].text == "Called test_tool"
result = await initialized_client_session.call_tool("start-notification-stream", {"interval": 1.0, "count": 5, "caller": "test-caller"})
assert len(result.content) == 1, result.content

# assert result.content[0].type == "text"
# assert result.content[0].text == "Called test_tool"


@pytest.mark.anyio
Expand Down