From fab35915f00cc71f78e35b1697b98ed12b5b801d Mon Sep 17 00:00:00 2001 From: Ville Laitila Date: Wed, 22 Oct 2025 14:41:54 +0300 Subject: [PATCH] misc: small code cleaning and fixed old commands according to rename --- pyproject.toml | 2 +- src/server.py | 43 ++++++++++++++------------ tools/debugging/mcp_connection_test.py | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 928f0e6..75e4c9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ ] [project.scripts] -sgraph-mcp-server = "src.server_modular:main" +sgraph-mcp-server = "src.server:main" [build-system] requires = ["setuptools", "wheel"] diff --git a/src/server.py b/src/server.py index 55d602e..47c4c34 100644 --- a/src/server.py +++ b/src/server.py @@ -13,34 +13,39 @@ # Set up logging setup_logging() -# Create MCP server -mcp = FastMCP("SGraph") -mcp.settings.port = 8008 -# Initialize the components -print("šŸ”§ Initializing modular components...") - -# Import tool modules and register them with the MCP server -from src.tools import model_tools, search_tools, analysis_tools, navigation_tools - -# Register all tools with the MCP server -model_tools.register_tools(mcp) -search_tools.register_tools(mcp) -analysis_tools.register_tools(mcp) -navigation_tools.register_tools(mcp) - -print("āœ… All tool modules loaded successfully") +def create_server(): + """Create and configure the MCP server with all tools registered.""" + print("šŸ”§ Initializing modular components...") + + # Create MCP server + mcp = FastMCP("SGraph") + mcp.settings.port = 8008 + + # Import tool modules and register them with the MCP server + from src.tools import model_tools, search_tools, analysis_tools, navigation_tools + + # Register all tools with the MCP server + model_tools.register_tools(mcp) + search_tools.register_tools(mcp) + analysis_tools.register_tools(mcp) + navigation_tools.register_tools(mcp) + + print("āœ… All tool modules loaded successfully") + return mcp def main(): """Main entry point for the MCP server.""" print("šŸš€ Starting modular MCP server...") + + # Create server with all tools registered + mcp = create_server() + print(f"šŸ“Š Server will run on http://0.0.0.0:8008") print(f"šŸ› ļø Modular server initialized with all tools registered") - # Add initialization delay before starting - time.sleep(1.0) - + # Start the server - all initialization is complete at this point mcp.run(transport="sse") diff --git a/tools/debugging/mcp_connection_test.py b/tools/debugging/mcp_connection_test.py index c720a02..e1ef74e 100644 --- a/tools/debugging/mcp_connection_test.py +++ b/tools/debugging/mcp_connection_test.py @@ -185,7 +185,7 @@ async def run_connection_diagnostics(server_url: str = "http://localhost:8008/ss print("\nšŸ”§ TROUBLESHOOTING SUGGESTIONS:") if not diagnostics["server_port"]["status"]: - print("• Start the server: uv run src/server_modular.py") + print("• Start the server: uv run python -m src.server") if not diagnostics["nodejs_version"]["status"]: print("• Install Node.js v20+: https://nodejs.org/")