]>
apps.delaporte.us Git - matrix-shop-bot.git/blob - skill.py
bc99032ddda8b11ba82f00f903429e52c5c5f4f5
1 from fastmcp
import FastMCP
2 from matrix_shop_bot
.db
import Data
7 from starlette
.middleware
import Middleware
8 from starlette
.middleware
.cors
import CORSMiddleware
11 from starlette
.applications
import Starlette
12 from starlette
.routing
import Mount
15 MY_IP
=os
.environ
.get('MY_IP')
16 mcp
= FastMCP("Shop Bot")
19 def add_item(name
: str) -> str:
20 return '\n'.join(Data().add_item(name
))
23 # Configure CORS for browser-based clients
27 allow_origins
=["*"], # Allow all origins; use specific origins for security
28 allow_methods
=["GET", "POST", "DELETE", "OPTIONS"],
30 "mcp-protocol-version",
35 expose_headers
=["mcp-session-id"],
39 # if __name__ == "__main__":
44 #def buy(items:str) -> 'list[str]':
45 # return Data().purchase_items(items)
48 #def list_bought(store:str) -> 'list[str]':
49 # return Data().list_purchases(store)
52 #def clear(store_name: str, clear_all:bool=False) -> 'list[str]':
53 # return Data().clear_list(store_name, clear_all)
57 #def shop_at(store_name:str) -> 'list[str]':
58 # '''Select store to shop at'''
59 # return Data().get_shopping_list(store_name)
63 #def list() -> 'list[str]':
64 # '''Use previous store'''
65 # return Data().get_last_shopping_list()
69 #def list_stores() -> 'list[str]':
70 # return Data().get_stores()
74 #def list_purchases(store: str) -> 'list[str]':
75 # return Data().list_purchases(store)
77 if __name__
== "__main__":
81 # stateless_http=True,
86 mcp_app
= mcp
.http_app(
88 # middleware=middleware
91 # Create a Starlette app and mount the MCP server
94 Mount("/mcp-server", app
=mcp_app
),
95 # Add other routes as needed
97 lifespan
=mcp_app
.lifespan
,
100 # http_app = mcp.http_app(transport="streamable-http",path="/",middleware=custom_middleware)
101 http_app
= mcp
.http_app(transport
="streamable-http",path
="/",middleware
=middleware
)
102 # http_app = mcp.http_app(transport="streamable-http",path="/")
103 uvicorn
.run(http_app
, host
=MY_IP
, port
=9000)