|
| 1 | +from mcp.server.fastmcp import FastMCP |
| 2 | +import logging |
| 3 | + |
| 4 | +# to start (after .venv setup): |
| 5 | +# python spendee/spendee_mcp.py |
| 6 | + |
| 7 | +# to test: |
| 8 | +# DANGEROUSLY_OMIT_AUTH=true mcp dev spendee/spendee_mcp.py |
| 9 | +# Then on the url: http://localhost:6274/ |
| 10 | +# setup "Transport Type" to "Streamable HTTP" |
| 11 | +# and "Server URL" to "http://localhost:8000/mcp" |
| 12 | + |
| 13 | +logging.basicConfig(level=logging.DEBUG) |
| 14 | +mcp = FastMCP("spendee", host="0.0.0.0", port=8000) |
| 15 | + |
| 16 | +@mcp.tool() |
| 17 | +def get_wallets(): |
| 18 | + # Hardcoded example wallets |
| 19 | + example_wallets = [ |
| 20 | + {"id": 1, "name": "Main Account", "currency": "USD", "balance": 1234.56}, |
| 21 | + {"id": 2, "name": "Savings", "currency": "EUR", "balance": 7890.12}, |
| 22 | + ] |
| 23 | + return example_wallets |
| 24 | + |
| 25 | +if __name__ == "__main__": |
| 26 | + mcp.run(transport="streamable-http") |
| 27 | + |
| 28 | +# relevant URLs for learning: |
| 29 | +# - https://modelcontextprotocol.io/specification/2025-06-18/server/tools |
| 30 | +# - https://www.aibootcamp.dev/blog/remote-mcp-servers |
| 31 | +# - https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_configuration-format |
| 32 | +# - https://docs.anthropic.com/en/docs/claude-code/mcp |
| 33 | +# - https://modelcontextprotocol.io/docs/tools/debugging |
| 34 | +# - https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#session-management |
| 35 | +# - https://github.com/modelcontextprotocol/python-sdk?tab=readme-ov-file#authentication |
0 commit comments