@@ -65,17 +65,15 @@ def extract_imports(code: str) -> list[str]:
65
65
66
66
return list (imports )
67
67
except Exception as e :
68
- print (f"Error parsing imports: { e } " )
69
- return []
68
+ raise RuntimeError (f"Error parsing imports: { e } " ) from e
70
69
71
70
72
71
def install_dependencies (dependencies : list [str ]):
73
72
"""Install required dependencies using uv pip."""
74
73
try :
75
- print (f"Checking dependencies: { dependencies } " )
76
74
subprocess .run (["uv" , "pip" , "install" ] + dependencies , check = True )
77
75
except subprocess .CalledProcessError as e :
78
- print (f"Failed to install dependencies: { e } " )
76
+ raise RuntimeError (f"Failed to install dependencies: { e } " ) from e
79
77
80
78
81
79
async def get_custom_mcp_servers () -> list [StdioServerParameters ]:
@@ -103,9 +101,19 @@ async def get_custom_mcp_servers() -> list[StdioServerParameters]:
103
101
script_path = temp_file .name
104
102
105
103
# Extract dependencies from the code
106
- dependencies = extract_imports (params ["code" ])
107
- if dependencies :
108
- install_dependencies (dependencies )
104
+ try :
105
+ dependencies = extract_imports (params ["code" ])
106
+ if dependencies :
107
+ try :
108
+ install_dependencies (dependencies )
109
+ except Exception as e :
110
+ print (
111
+ f"Failed to install dependencies for server { code_uuid } : { e } "
112
+ )
113
+ continue
114
+ except Exception as e :
115
+ print (f"Failed to extract imports for server { code_uuid } : { e } " )
116
+ continue
109
117
110
118
params ["command" ] = "uv"
111
119
params ["args" ] = ["run" , script_path ] + params .get ("additionalArgs" , [])
0 commit comments