MCPcopy Create free account
hub / github.com/IBM/mcp-cli / run_command_sync

Function run_command_sync

src/mcp_cli/run_command.py:226–251  ·  view source on GitHub ↗

Synchronous convenience wrapper (used by `mcp-cli` entry-point and tests). Spins up its own event-loop when necessary.

(
    async_command: Callable[..., Any],
    config_file: str,
    servers: list[str],
    *,
    extra_params: dict[str, Any | None],
)

Source from the content-addressed store, hash-verified

224
225
226def run_command_sync(
227 async_command: Callable[..., Any],
228 config_file: str,
229 servers: list[str],
230 *,
231 extra_params: dict[str, Any | None],
232) -> Any:
233 """
234 Synchronous convenience wrapper (used by `mcp-cli` entry-point and tests).
235
236 Spins up its own event-loop when necessary.
237 """
238 try:
239 loop = asyncio.get_running_loop()
240 except RuntimeError:
241 loop = asyncio.new_event_loop()
242 asyncio.set_event_loop(loop)
243
244 return loop.run_until_complete(
245 run_command(
246 async_command,
247 config_file=config_file,
248 servers=servers,
249 extra_params=extra_params,
250 )
251 )
252
253
254# --------------------------------------------------------------------------- #

Callers 10

_interactive_commandFunction · 0.90
tools_commandFunction · 0.90
servers_commandFunction · 0.90
resources_commandFunction · 0.90
prompts_commandFunction · 0.90
cmd_commandFunction · 0.90
ping_commandFunction · 0.90

Calls 1

run_commandFunction · 0.70