@@ -176,13 +176,15 @@ async def execute_tool(
176176 arguments : dict [str , Any ],
177177 * ,
178178 timeout : int | None = None ,
179+ extra_volumes : list [str ] | None = None ,
179180 ) -> dict [str , Any ]:
180181 """Execute a tool on a hub server.
181182
182183 :param server: Hub server to execute on.
183184 :param tool_name: Name of the tool to execute.
184185 :param arguments: Tool arguments.
185186 :param timeout: Execution timeout (uses default if None).
187+ :param extra_volumes: Additional Docker volume mounts to inject.
186188 :returns: Tool execution result.
187189 :raises HubClientError: If execution fails.
188190
@@ -199,7 +201,7 @@ async def execute_tool(
199201 )
200202
201203 try :
202- async with self ._connect (config ) as (reader , writer ):
204+ async with self ._connect (config , extra_volumes = extra_volumes ) as (reader , writer ):
203205 # Initialise MCP session (skip for persistent — already done)
204206 if not self ._persistent_sessions .get (config .name ):
205207 await self ._initialize_session (reader , writer , config .name )
@@ -248,6 +250,7 @@ async def execute_tool(
248250 async def _connect (
249251 self ,
250252 config : HubServerConfig ,
253+ extra_volumes : list [str ] | None = None ,
251254 ) -> AsyncGenerator [tuple [asyncio .StreamReader , asyncio .StreamWriter ], None ]:
252255 """Connect to an MCP server.
253256
@@ -256,6 +259,7 @@ async def _connect(
256259 ephemeral per-call connection logic.
257260
258261 :param config: Server configuration.
262+ :param extra_volumes: Additional Docker volume mounts to inject.
259263 :yields: Tuple of (reader, writer) for communication.
260264
261265 """
@@ -268,7 +272,7 @@ async def _connect(
268272
269273 # Ephemeral connection (original behaviour)
270274 if config .type == HubServerType .DOCKER :
271- async with self ._connect_docker (config ) as streams :
275+ async with self ._connect_docker (config , extra_volumes = extra_volumes ) as streams :
272276 yield streams
273277 elif config .type == HubServerType .COMMAND :
274278 async with self ._connect_command (config ) as streams :
@@ -284,10 +288,12 @@ async def _connect(
284288 async def _connect_docker (
285289 self ,
286290 config : HubServerConfig ,
291+ extra_volumes : list [str ] | None = None ,
287292 ) -> AsyncGenerator [tuple [asyncio .StreamReader , asyncio .StreamWriter ], None ]:
288293 """Connect to a Docker-based MCP server.
289294
290295 :param config: Server configuration with image name.
296+ :param extra_volumes: Additional volume mounts to inject (e.g. project assets).
291297 :yields: Tuple of (reader, writer) for stdio communication.
292298
293299 """
@@ -302,10 +308,14 @@ async def _connect_docker(
302308 for cap in config .capabilities :
303309 cmd .extend (["--cap-add" , cap ])
304310
305- # Add volumes
311+ # Add volumes from server config
306312 for volume in config .volumes :
307313 cmd .extend (["-v" , os .path .expanduser (volume )])
308314
315+ # Add extra volumes (e.g. project assets injected at runtime)
316+ for volume in (extra_volumes or []):
317+ cmd .extend (["-v" , os .path .expanduser (volume )])
318+
309319 # Add environment variables
310320 for key , value in config .environment .items ():
311321 cmd .extend (["-e" , f"{ key } ={ value } " ])
0 commit comments