X-Git-Url: https://apps.delaporte.us/gitweb/matrix-shop-bot.git/blobdiff_plain/efbf994b428f4b8c147b3751e898a7e85ca3c426..c459b163b40e843daf86a6257c0c28026c4c126b:/skill.py?ds=sidebyside diff --git a/skill.py b/skill.py index 53bdf9e..355b9b2 100644 --- a/skill.py +++ b/skill.py @@ -1,11 +1,32 @@ from fastmcp import FastMCP from matrix_shop_bot.db import Data +import os +import uvicorn +from starlette.middleware import Middleware +from starlette.middleware.cors import CORSMiddleware +import uvicorn + + +MY_IP=os.environ.get('MY_IP') mcp = FastMCP("Shop Bot") @mcp.tool -def add_item(name: str) -> 'list[str]': - return Data().add_item(name) +def add_item(name: str) -> str: + return '\n'.join(Data().add_item(name)) + +# Define custom middleware +custom_middleware = [ + Middleware(CORSMiddleware, allow_origins=["*"], + allow_methods=["*"], + allow_headers=["*"],), +] + +if __name__ == "__main__": + http_app = mcp.http_app(transport="streamable-http",path="/",middleware=custom_middleware) + uvicorn.run(http_app, host=MY_IP, port=9000) + + #@mcp.tool #def buy(items:str) -> 'list[str]': @@ -41,5 +62,5 @@ def add_item(name: str) -> 'list[str]': #def list_purchases(store: str) -> 'list[str]': # return Data().list_purchases(store) -if __name__ == "__main__": - mcp.run(transport="http", host="127.0.0.1", port=9000) +# if __name__ == "__main__": +# mcp.run(transport="http", host=MY_IP, port=9000)