Skip to content

Commit 3f651fb

Browse files
committed
Refactor zenml_server.py for improved compatibility and logging
- Ensure setuptools is imported first to provide distutils compatibility. - Removed the `num_steps` parameter from the `list_pipeline_runs` function to simplify the API. - Updated logging messages for clarity when starting the MCP server and handling errors.
1 parent f46f3bf commit 3f651fb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

server/zenml_server.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44
# "httpx",
55
# "mcp[cli]",
66
# "zenml",
7+
# "setuptools",
78
# ]
89
# ///
10+
11+
# Ensure setuptools is imported first to provide distutils compatibility
12+
try:
13+
import setuptools # noqa
14+
except ImportError:
15+
pass
16+
917
import functools
1018
import json
1119
import logging
@@ -723,7 +731,6 @@ def list_pipeline_runs(
723731
status: str = None,
724732
start_time: str = None,
725733
end_time: str = None,
726-
num_steps: int = None,
727734
stack: str = None,
728735
stack_component: str = None,
729736
) -> str:
@@ -743,7 +750,6 @@ def list_pipeline_runs(
743750
status: The status of the pipeline runs
744751
start_time: The start time of the pipeline runs
745752
end_time: The end time of the pipeline runs
746-
num_steps: The number of steps in the pipeline runs
747753
stack: The stack of the pipeline runs
748754
stack_component: The stack component of the pipeline runs
749755
"""
@@ -761,7 +767,6 @@ def list_pipeline_runs(
761767
status=status,
762768
start_time=start_time,
763769
end_time=end_time,
764-
num_steps=num_steps,
765770
stack=stack,
766771
stack_component=stack_component,
767772
)
@@ -1118,8 +1123,6 @@ def most_recent_runs(run_count: int = 10) -> str:
11181123

11191124
if __name__ == "__main__":
11201125
try:
1121-
logger.info("Starting MCP server with stdio transport...")
11221126
mcp.run(transport="stdio")
11231127
except Exception as e:
1124-
logger.error(f"Error running server: {str(e)}")
1125-
raise
1128+
logger.error(f"Error running MCP server: {e}")

0 commit comments

Comments
 (0)