Files
RRRosmontis 34089d0042 Initial import of Shirobana bot backend
Include utility modules, shared channels, prompts, read-only skills, wardrobe memory and regression tests. Externalize legacy credentials and exclude private runtime state.
2026-11-11 00:25:30 +08:00

27 lines
957 B
Python

"""Single Windows service for the existing mail website, MCP and remote COM API."""
import os
import uvicorn
from starlette.middleware.wsgi import WSGIMiddleware
import mailWeb
import mail_mcp
import admin_com
admin_com.install(mailWeb.app)
web = WSGIMiddleware(mailWeb.app)
mcp = mail_mcp.BearerKeyMiddleware(mail_mcp.mcp.http_app(
path='/mcp/', stateless_http=True,
allowed_hosts=['api.rrrosmontis.icu', '127.0.0.1', 'localhost']))
async def application(scope, receive, send):
# Lifespan goes to FastMCP, so its session manager starts and stops normally.
if scope['type'] == 'http' and scope.get('path', '').startswith('/v1/mail/api/'):
await web(scope, receive, send)
else:
await mcp(scope, receive, send)
if __name__ == '__main__':
uvicorn.run(application, host='127.0.0.1', port=int(os.environ.get('MAIL_PORT', '12005')),
log_level='warning', access_log=False, timeout_graceful_shutdown=20)