Created
November 9, 2025 13:36
-
-
Save samirsaci/e6e2680efcaaed48209ffb36cb635970 to your computer and use it in GitHub Desktop.
MCP Server Supply Chain Optimisation - Tool Run Network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @mcp.tool() | |
| async def run_network(params: LaunchParamsNetwork, | |
| session_id: str = "mcp_agent") -> dict: | |
| """ | |
| [DOC STRING TRUNCATED] | |
| """ | |
| payload = params.model_dump(exclude_none=True) | |
| try: | |
| async with httpx.AsyncClient(timeout=httpx.Timeout(5, read=60)) as c: | |
| r = await c.post(LAUNCH, json=payload, headers={"session_id": session_id}) | |
| r.raise_for_status() | |
| logging.info(f"[NetworkMCP] Run successful with params: {payload}") | |
| data = r.json() | |
| result = data[0] if isinstance(data, list) and data else data | |
| global last_run | |
| last_run = result | |
| return result | |
| except httpx.HTTPError as e: | |
| code = getattr(e.response, "status_code", "unknown") | |
| logging.error(f"[NetworkMCP] API call failed: {e}") | |
| return {"error": f"{code} {e}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment