]> apps.delaporte.us Git - matrix-shop-bot.git/commitdiff
WIP - convert to MCP skill
authorEdward Delaporte <edward@delaporte.us>
Sun, 26 Jul 2026 23:37:08 +0000 (18:37 -0500)
committerEdward Delaporte <edward@delaporte.us>
Sun, 26 Jul 2026 23:37:08 +0000 (18:37 -0500)
Makefile
mcp.py [new file with mode: 0644]
pyproject.toml

index 4760758ac92d09d42f9346d506fb6ce7e37c0f99..c8e3458f3d9964cae348cd12885ee7894460d361 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,10 @@ MODULE=matrix_shop_bot
        python -m venv .venv
        .venv/bin/pip install .
 
+.venv-llm:
+       python -m venv .venv
+       .venv/bin/pip install -e ".[llm]"
+
 serve: .venv
        .venv/bin/python app.py
 
diff --git a/mcp.py b/mcp.py
new file mode 100644 (file)
index 0000000..50a2eff
--- /dev/null
+++ b/mcp.py
@@ -0,0 +1,45 @@
+from fastmcp import FastMCP
+from matrix_shop_bot.db import Data
+
+mcp = FastMCP("Shop Bot")
+
+@mcp.tool
+def add_item(name: str) -> list[str]:
+    return Data().add_item(name)
+
+@mcp.tool
+def buy(items:str) -> list[str]:
+    return Data().purchase_items(items)
+
+@mcp.tool
+def list_bought(store:str) -> list[str]:
+    return Data().list_purchases(store)
+
+@mcp.tool
+def clear(store_name: str, clear_all:bool=False) -> list[str]:
+    return Data().clear_list(store_name, clear_all)
+
+
+@mcp.tool
+def shop_at(store_name:str) -> list[str]:
+    '''Select store to shop at'''
+    return Data().get_shopping_list(store_name)
+
+
+@mcp.tool
+def list() -> list[str]:
+    '''Use previous store'''
+    return Data().get_last_shopping_list()
+
+
+@mcp.tool
+def list_stores() -> list[str]:
+    return Data().get_stores()
+
+
+@mcp.tool
+def list_purchases(store: str) -> list[str]:
+    return Data().list_purchases(store)
+
+if __name__ == "__main__":
+    mcp.run()
index 4c0329a8b91c5bb42253e584fe803a0d6dd1c5c3..68e0183fbb50c269c9e32dce4058b6ab05c742d9 100644 (file)
@@ -14,6 +14,7 @@ dependencies = [
 
 [project.optional-dependencies]
 test = ['mypy']
+llm = ['fastmcp']  # pip install -e ".[llm]"
 
 [tool.setuptools.packages.find]
 exclude = ["service*", "store*", "backups*"]