Revert create_app to v0.1.6 - remove Redis session store
- 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 <noreply@anthropic.com>
This commit is contained in:
+3
-27
@@ -241,42 +241,18 @@ from fastmcp import FastMCP
|
|||||||
def create_app(auth=None):
|
def create_app(auth=None):
|
||||||
"""Create FastMCP app with standard capabilities and optional auth."""
|
"""Create FastMCP app with standard capabilities and optional auth."""
|
||||||
global app
|
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:
|
if auth:
|
||||||
# Set auth on existing app instead of creating new one
|
|
||||||
app.auth = auth
|
app.auth = auth
|
||||||
|
app.name = "Yargı MCP Server"
|
||||||
logger.info("MCP server created with Bearer authentication enabled")
|
logger.info("MCP server created with Bearer authentication enabled")
|
||||||
else:
|
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()
|
token_counter = TokenCountingMiddleware()
|
||||||
app.add_middleware(token_counter)
|
app.add_middleware(token_counter)
|
||||||
logger.info("Token counting middleware added to MCP server")
|
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
|
return app
|
||||||
|
|
||||||
# --- Module Imports ---
|
# --- Module Imports ---
|
||||||
|
|||||||
Reference in New Issue
Block a user