From 54f81e18f0dc147fe7b911c30f0a59e94e8c08f4 Mon Sep 17 00:00:00 2001 From: saidsurucu Date: Tue, 22 Jul 2025 12:10:10 +0300 Subject: [PATCH] Revert create_app to v0.1.6 - remove Redis session store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove Redis session store initialization from create_app() - Revert to simple token counting middleware only - Fix session management issue causing tools to appear then disappear - This matches the exact v0.1.6 implementation that was working 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- mcp_server_main.py | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/mcp_server_main.py b/mcp_server_main.py index 54edf20..3dd3a58 100644 --- a/mcp_server_main.py +++ b/mcp_server_main.py @@ -241,42 +241,18 @@ from fastmcp import FastMCP def create_app(auth=None): """Create FastMCP app with standard capabilities and optional auth.""" global app - - # Debug: Check tools count before auth setup - tools_count = len(app._tool_manager._tools) if hasattr(app, '_tool_manager') else 0 - logger.info(f"create_app() called - tools already registered: {tools_count}") - if auth: - # Set auth on existing app instead of creating new one app.auth = auth + app.name = "Yargı MCP Server" logger.info("MCP server created with Bearer authentication enabled") else: - logger.info("MCP server created with standard capabilities (FastMCP handles tools.listChanged automatically)") + app.name = "Yargı MCP Server" + logger.info("MCP server created with standard capabilities...") - # Add token counting middleware token_counter = TokenCountingMiddleware() app.add_middleware(token_counter) logger.info("Token counting middleware added to MCP server") - # Add Redis session persistence middleware for multi-machine deployment - try: - from redis_session_store import get_redis_store - redis_store = get_redis_store() - if redis_store: - # Configure FastMCP to use Redis for session storage - logger.info("Configuring FastMCP with Redis session storage for multi-machine deployment") - # Note: FastMCP session persistence would need to be implemented - # For now, we'll rely on load balancer sticky sessions - else: - logger.warning("Redis not available - MCP sessions will be in-memory (may cause connection drops with multiple machines)") - except Exception as e: - logger.warning(f"Failed to configure Redis session storage: {e}") - logger.warning("MCP sessions will be in-memory (may cause connection drops with multiple machines)") - - # Debug: Check tools count after setup - final_tools_count = len(app._tool_manager._tools) if hasattr(app, '_tool_manager') else 0 - logger.info(f"create_app() finished - final tools count: {final_tools_count}") - return app # --- Module Imports ---