Skip to main content
Glama
liueic

PubChem Chemical Safety MCP Server

by liueic
main.py1.33 kB
""" PubChem MCP Server 主应用 """ import logging import os from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from .api.routes import router # 配置日志 logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) logger = logging.getLogger(__name__) # 创建FastAPI应用 app = FastAPI( title="PubChem Chemical Safety MCP Server", description="基于 PubChem REST API 的化学安全信息 MCP 服务器", version="0.1.0", docs_url="/docs", redoc_url="/redoc" ) # 添加CORS中间件 app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # 注册路由 app.include_router(router) @app.on_event("startup") async def startup_event(): """应用启动事件""" logger.info("PubChem MCP Server starting up...") logger.info(f"Environment: {os.getenv('ENVIRONMENT', 'development')}") @app.on_event("shutdown") async def shutdown_event(): """应用关闭事件""" logger.info("PubChem MCP Server shutting down...") if __name__ == "__main__": import uvicorn uvicorn.run( "pubchem_mcp.main:app", host="0.0.0.0", port=8000, reload=True, log_level="info" )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/liueic/PubChem-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server