Spaces:
Sleeping
Sleeping
| """ | |
| AlphaGenome MCP Service - Hugging Face Spaces App | |
| """ | |
| import os | |
| import sys | |
| from fastapi import FastAPI | |
| from fastapi.responses import JSONResponse | |
| import uvicorn | |
| # Add the source directory to Python path | |
| source_path = os.path.join(os.path.dirname(__file__), "alphagenome", "source") | |
| sys.path.insert(0, source_path) | |
| # Add mcp_plugin to path | |
| mcp_plugin_path = os.path.join(os.path.dirname(__file__), "alphagenome", "mcp_output", "mcp_plugin") | |
| sys.path.insert(0, mcp_plugin_path) | |
| app = FastAPI( | |
| title="AlphaGenome MCP Service", | |
| description="AlphaGenome AI model for genomic data interpretation", | |
| version="1.0.0" | |
| ) | |
| def root(): | |
| """Root endpoint with service information""" | |
| api_key_configured = os.environ.get("ALPHAGENOME_API_KEY", "not_set") != "your_api_key_here" | |
| return { | |
| "service": "AlphaGenome MCP Service", | |
| "description": "AI model for predicting genetic variant effects", | |
| "version": "1.0.0", | |
| "api_key_configured": api_key_configured, | |
| "tools": [ | |
| "predict_sequence", | |
| "predict_interval", | |
| "predict_variant", | |
| "score_variant", | |
| "score_variants", | |
| "score_variant_effect", | |
| "visualize_variant_effects", | |
| "score_variant_batch", | |
| "visualize_tf_binding", | |
| "plot_predictions" | |
| ], | |
| "environment_variables": { | |
| "ALPHAGENOME_API_KEY": "Set your AlphaGenome API key here" | |
| } | |
| } | |
| def health_check(): | |
| """Health check endpoint""" | |
| return {"status": "healthy", "service": "AlphaGenome MCP"} | |
| def list_tools(): | |
| """List available MCP tools""" | |
| try: | |
| # Import from the correct path | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "alphagenome", "mcp_output", "mcp_plugin")) | |
| from mcp_service import create_app | |
| mcp_app = create_app() | |
| tools = [] | |
| for tool_name, tool_func in mcp_app.tools.items(): | |
| tools.append({ | |
| "name": tool_name, | |
| "description": tool_func.__doc__ or "No description available" | |
| }) | |
| return {"tools": tools} | |
| except Exception as e: | |
| return {"error": f"Failed to load tools: {str(e)}"} | |
| if __name__ == "__main__": | |
| port = int(os.environ.get("PORT", 7860)) | |
| uvicorn.run(app, host="0.0.0.0", port=port) | |