Skip to content

Commit b41b807

Browse files
authored
feat: upgrade to MCP 1.10.1 with streamable HTTP transport (#41)
* feat: upgrade to MCP 1.10.1 with streamable HTTP transport - Upgrade from MCP 1.9.4 to 1.10.1 - Add streamablehttp_client support - Run uv sync --upgrade for dependency updates - Update README.md * Bump version to 0.14.0
1 parent 8b23279 commit b41b807

File tree

6 files changed

+362
-172
lines changed

6 files changed

+362
-172
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<img src="https://raw.githubusercontent.com/jonigl/mcp-client-for-ollama/v0.13.0/misc/ollmcp-demo.gif" alt="MCP Client for Ollama Demo">
2121
</p>
2222
<p align="center">
23-
<a href="https://asciinema.org/a/jxc6N8oKZAWrzH8aK867zhXdO" target="_blank">🎥 View this demo as an asciinema recording</a>
23+
<a href="https://asciinema.org/a/jxc6N8oKZAWrzH8aK867zhXdO" target="_blank">🎥 Watch this demo as an Asciinema recording</a>
2424
</p>
2525

2626
## Table of Contents
@@ -398,7 +398,7 @@ The configuration saves:
398398

399399
## Server Configuration Format
400400

401-
The JSON configuration file supports STDIO, SSE, and Streamable HTTP server types:
401+
The JSON configuration file supports STDIO, SSE, and Streamable HTTP server types (MCP 1.10.1):
402402

403403
```json
404404
{
@@ -432,7 +432,7 @@ The JSON configuration file supports STDIO, SSE, and Streamable HTTP server type
432432
}
433433
```
434434
> [!NOTE]
435-
> If you specify a URL without a type, the client will default to using Streamable HTTP transport.
435+
> **MCP 1.10.1 Transport Support**: The client now supports the latest Streamable HTTP transport with improved performance and reliability. If you specify a URL without a type, the client will default to using Streamable HTTP transport.
436436
437437
## Compatible Models
438438

@@ -470,11 +470,13 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
470470

471471
## Acknowledgments
472472

473-
- [Model Context Protocol](https://modelcontextprotocol.io/) for the specification and examples
474473
- [Ollama](https://ollama.com/) for the local LLM runtime
474+
- [Model Context Protocol](https://modelcontextprotocol.io/) for the specification and examples
475475
- [Rich](https://rich.readthedocs.io/) for the terminal user interface
476476
- [Typer](https://typer.tiangolo.com/) for the modern CLI experience
477+
- [Prompt Toolkit](https://python-prompt-toolkit.readthedocs.io/) for the interactive command line interface
477478
- [UV](https://www.uvicorn.org/) for the lightning-fast Python package manager and virtual environment management
479+
- [Asciinema](https://asciinema.org/) for the demo recording
478480

479481
---
480482

cli-package/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ollmcp"
3-
version = "0.13.0"
3+
version = "0.14.0"
44
description = "CLI for MCP Client for Ollama - An easy-to-use command for interacting with Ollama through MCP"
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -9,7 +9,7 @@ authors = [
99
{name = "Jonathan Löwenstern"}
1010
]
1111
dependencies = [
12-
"mcp-client-for-ollama==0.13.0"
12+
"mcp-client-for-ollama==0.14.0"
1313
]
1414

1515
[project.scripts]

mcp_client_for_ollama/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""MCP Client for Ollama package."""
22

3-
__version__ = "0.13.0"
3+
__version__ = "0.14.0"

mcp_client_for_ollama/server/connector.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
initialization, and communication.
55
"""
66

7-
import os
8-
import shutil
97
import os
108
import shutil
119
from contextlib import AsyncExitStack
@@ -15,6 +13,7 @@
1513
from mcp import ClientSession, Tool
1614
from mcp.client.stdio import stdio_client, StdioServerParameters
1715
from mcp.client.sse import sse_client
16+
from mcp.client.streamable_http import streamablehttp_client
1817

1918
from .discovery import process_server_paths, parse_server_configs, auto_discover_servers
2019

@@ -38,6 +37,7 @@ def __init__(self, exit_stack: AsyncExitStack, console: Optional[Console] = None
3837
self.sessions = {} # Dict to store multiple sessions
3938
self.available_tools = [] # List to store all available tools
4039
self.enabled_tools = {} # Dict to store tool enabled status
40+
self.session_ids = {} # Dict to store session IDs for HTTP connections
4141

4242
async def connect_to_servers(self, server_paths=None, config_path=None, auto_discovery=False) -> Tuple[dict, list, dict]:
4343
"""Connect to one or more MCP servers
@@ -137,13 +137,17 @@ async def _connect_to_server(self, server: Dict[str, Any]) -> bool:
137137

138138
headers = self._get_headers_from_server(server)
139139

140-
# In MCP 1.9.0, use SSE client for HTTP connections as well
141-
# since the dedicated HTTP client is no longer available
142-
self.console.print(f"[yellow]Note: Using SSE client for HTTP connection to {server_name}[/yellow]")
143-
transport = await self.exit_stack.enter_async_context(sse_client(url, headers=headers))
144-
read_stream, write_stream = transport
140+
# Use the streamablehttp_client for Streamable HTTP connections
141+
transport = await self.exit_stack.enter_async_context(
142+
streamablehttp_client(url, headers=headers)
143+
)
144+
read_stream, write_stream, session_info = transport
145145
session = await self.exit_stack.enter_async_context(ClientSession(read_stream, write_stream))
146146

147+
# Store session ID if provided
148+
if hasattr(session_info, 'session_id') and session_info.session_id:
149+
self.session_ids[server_name] = session_info.session_id
150+
147151
elif server_type == "script":
148152
# Connect to script-based server using STDIO
149153
server_params = self._create_script_params(server)
@@ -383,17 +387,23 @@ def _get_headers_from_server(self, server: Dict[str, Any]) -> Dict[str, str]:
383387
if not headers and "config" in server:
384388
headers = server["config"].get("headers", {})
385389

390+
# Always add MCP Protocol Version header for HTTP connections
391+
server_type = server.get("type", "script")
392+
if server_type in ["sse", "streamable_http"]:
393+
headers["MCP-Protocol-Version"] = "2025-06-18"
394+
386395
return headers
387396

388397
async def disconnect_all_servers(self):
389398
"""Disconnect from all servers and reset state"""
390-
# Close all existing connections
399+
# Close all existing connections via exit stack
391400
await self.exit_stack.aclose()
392401

393402
# Create a new exit stack for future connections
394403
self.exit_stack = AsyncExitStack()
395404

396405
# Clear all state
397-
self.sessions = {}
398-
self.available_tools = []
399-
self.enabled_tools = {}
406+
self.sessions.clear()
407+
self.available_tools.clear()
408+
self.enabled_tools.clear()
409+
self.session_ids.clear()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mcp-client-for-ollama"
3-
version = "0.13.0"
3+
version = "0.14.0"
44
description = "MCP Client for Ollama - A client for connecting to Model Context Protocol servers using Ollama"
55
readme = "README.md"
66
requires-python = ">=3.10"

0 commit comments

Comments
 (0)