Skip to content

Commit ec193be

Browse files
committed
working-sse
1 parent f5d5d32 commit ec193be

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

inspect.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22
set -euo pipefail
33
cd "$(dirname "$0")"
4+
if [[ "$(which python)" != "$(pwd)/.venv/bin/python" ]]; then
5+
source .venv/bin/activate
6+
fi
47
source .venv/bin/activate
5-
DANGEROUSLY_OMIT_AUTH=true mcp dev spendee/spendee_mcp.py
8+
DANGEROUSLY_OMIT_AUTH=true mcp dev spendee/spendee_mcp.py $@

spendee/spendee_mcp.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
from fastapi import FastAPI, HTTPException, Request
77
from mcp.server.fastmcp import FastMCP
88
from mcp.server.streamable_http_manager import StreamableHTTPSessionManager
9+
import contextlib
10+
11+
from starlette.applications import Starlette
12+
from starlette.routing import Mount
13+
14+
from mcp.server.fastmcp import FastMCP
915

1016
# to start (after .venv setup):
1117
# python spendee/spendee_mcp.py
@@ -75,17 +81,20 @@ def get_wallets():
7581
# uvicorn.run(app, host="0.0.0.0", port=PORT)
7682

7783
def server_with_sse():
78-
app = FastAPI()
79-
@app.get("/")
80-
def read_root():
81-
return {"Hello": "World"}
82-
#from app.sse import create_sse_server
83-
app.mount("/", app.sse.create_sse_server(mcp))
84+
85+
# Create the Starlette app and mount the MCP servers
86+
app = Starlette(
87+
routes=[
88+
Mount("/", mcp.sse_app()),
89+
],
90+
)
91+
uvicorn.run(app, host="0.0.0.0", port=PORT)
92+
8493

8594
if __name__ == "__main__":
8695
logger.info("Starting Spendee MCP Server as SSE without authentication")
87-
mcp.run(transport="sse") # for n8n compatibility, authentication implemented on cloudflare level
88-
#server_with_sse()
96+
# for n8n compatibility, authentication implemented on cloudflare level
97+
server_with_sse()
8998

9099
# if DISABLE_AUTH:
91100
# logger.warning("Running without authentication! This is insecure and should only be used for local testing.")

0 commit comments

Comments
 (0)