Skip to content

Commit eedb157

Browse files
authored
feat(slimrpc,slima2a,slim-mcp): Upgrade to v0.7.1 slim_bindings (#839)
1 parent 5707157 commit eedb157

File tree

31 files changed

+1087
-1093
lines changed

31 files changed

+1087
-1093
lines changed

data-plane/python/integrations/slim-mcp/pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "slim-mcp"
66
description = "Model Context Protocol with SLIM as transport"
77
readme = "README.md"
88
version = "0.1.7"
9-
requires-python = ">=3.10, <4.0"
9+
requires-python = ">=3.11, <4.0"
1010
license = "Apache-2.0"
1111
classifiers = [
1212
"Development Status :: 3 - Alpha",
@@ -22,7 +22,7 @@ classifiers = [
2222
"Programming Language :: Python :: 3.13",
2323
]
2424

25-
dependencies = ["slim-bindings>=0.5.0", "mcp==1.6.0", "anyio>=4.5"]
25+
dependencies = ["slim-bindings>=0.7.1", "mcp==1.6.0", "anyio>=4.5"]
2626

2727
# [tool.uv.sources]
2828
# slim-bindings = { path = "../../bindings" }
@@ -66,10 +66,10 @@ packages = ["slim_mcp"]
6666
mcp-server-time = "slim_mcp.examples.mcp_server_time:main"
6767
llamaindex-time-agent = "slim_mcp.examples.llamaindex_time_agent:main"
6868

69-
[[tool.mypy.overrides]]
70-
module = ["slim_bindings.*"]
71-
ignore_missing_imports = true
72-
7369
[[tool.mypy.overrides]]
7470
module = ["llama_index.*"]
7571
follow_untyped_imports = true
72+
73+
[[tool.mypy.overrides]]
74+
module = ["slim_bindings.*"]
75+
ignore_missing_imports = true

data-plane/python/integrations/slim-mcp/slim_mcp/client.py

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SLIMClient(SLIMBase):
3030

3131
def __init__(
3232
self,
33-
config: dict[str, Any],
33+
slim_client_configs: list[dict[str, Any]],
3434
local_organization: str,
3535
local_namespace: str,
3636
local_agent: str,
@@ -59,7 +59,7 @@ def __init__(
5959
"""
6060

6161
super().__init__(
62-
config,
62+
slim_client_configs,
6363
local_organization,
6464
local_namespace,
6565
local_agent,
@@ -70,60 +70,30 @@ def __init__(
7070
message_retries=message_retries,
7171
)
7272

73-
async def _send_message(
74-
self,
75-
session: slim_bindings.PySessionInfo,
76-
message: bytes,
77-
) -> None:
78-
"""Send a message to the remote slim instance.
79-
80-
Args:
81-
session: Session information for the message
82-
message: Message to send in bytes format
83-
84-
Raises:
85-
RuntimeError: If SLIM is not connected or if sending fails
86-
"""
87-
if not self.is_connected():
88-
raise RuntimeError("SLIM is not connected. Please use the with statement.")
89-
90-
try:
91-
logger.debug(
92-
"Sending message to remote slim instance",
93-
extra={
94-
"remote_svc": str(self.remote_svc_name),
95-
},
96-
)
97-
# Send message to SLIM instance
98-
await self.slim.publish(
99-
session,
100-
message,
101-
self.remote_svc_name,
102-
)
103-
logger.debug("Message sent successfully")
104-
except Exception as e:
105-
logger.error("Failed to send message", exc_info=True)
106-
raise RuntimeError(f"Failed to send message: {str(e)}") from e
107-
10873
@asynccontextmanager
10974
async def to_mcp_session(self, *args, **kwargs):
11075
"""Create a new MCP session.
11176
11277
Returns:
113-
slim_bindings.PySessionInfo: The new MCP session
78+
slim_bindings.Session: The new MCP session
11479
"""
11580
# create session
116-
session = await self.slim.create_session(
117-
slim_bindings.PySessionConfiguration.FireAndForget(
118-
timeout=self.message_timeout,
81+
session, ack = await self.slim.create_session(
82+
destination=self.remote_svc_name,
83+
session_config=slim_bindings.SessionConfiguration.PointToPoint(
11984
max_retries=self.message_retries,
120-
sticky=True,
121-
)
85+
timeout=self.message_timeout,
86+
),
12287
)
88+
await ack
12389

12490
# create streams
125-
async with self.new_streams(session) as (read_stream, write_stream):
126-
async with ClientSession(
127-
read_stream, write_stream, *args, **kwargs
128-
) as mcp_session:
129-
yield mcp_session
91+
try:
92+
async with self.new_streams(session) as (read_stream, write_stream):
93+
async with ClientSession(
94+
read_stream, write_stream, *args, **kwargs
95+
) as mcp_session:
96+
yield mcp_session
97+
finally:
98+
ack = await self.slim.delete_session(session)
99+
await ack

0 commit comments

Comments
 (0)