Gemini commited on
Commit ·
a2bcd22
1
Parent(s): 7eb908d
refactor: Simplify app.py for debugging
Browse filesThis commit simplifies the app.py file by removing the streaming logic and returning a simple response from the root endpoint. This is done to isolate the problem and confirm that the FastAPI application is working correctly.
app.py
CHANGED
|
@@ -6,51 +6,6 @@ import os
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
-
async def run_mcp_server():
|
| 10 |
-
"""Runs the notion-mcp-server and yields its output."""
|
| 11 |
-
env = os.environ.copy()
|
| 12 |
-
auth_token = env.get("BEARER")
|
| 13 |
-
command = ["/notion-mcp-server/bin/cli.mjs"]
|
| 14 |
-
if auth_token:
|
| 15 |
-
command.extend(["--auth-token", auth_token])
|
| 16 |
-
|
| 17 |
-
process = await asyncio.create_subprocess_exec(
|
| 18 |
-
*command,
|
| 19 |
-
stdout=subprocess.PIPE,
|
| 20 |
-
stderr=subprocess.PIPE,
|
| 21 |
-
env=env,
|
| 22 |
-
)
|
| 23 |
-
|
| 24 |
-
if process.stdout:
|
| 25 |
-
while not process.stdout.at_eof():
|
| 26 |
-
line = await process.stdout.readline()
|
| 27 |
-
if not line:
|
| 28 |
-
break
|
| 29 |
-
yield line
|
| 30 |
-
|
| 31 |
-
if process.stderr:
|
| 32 |
-
while not process.stderr.at_eof():
|
| 33 |
-
line = await process.stderr.readline()
|
| 34 |
-
if not line:
|
| 35 |
-
break
|
| 36 |
-
yield line
|
| 37 |
-
|
| 38 |
-
@app.api_route("/health", methods=["GET"])
|
| 39 |
-
async def proxy_health(request: Request):
|
| 40 |
-
async with httpx.AsyncClient() as client:
|
| 41 |
-
url = "http://localhost:7860/health"
|
| 42 |
-
headers = {key: value for key, value in request.headers.items() if key.lower() not in ('host',)}
|
| 43 |
-
|
| 44 |
-
response = await client.request(
|
| 45 |
-
method=request.method,
|
| 46 |
-
url=url,
|
| 47 |
-
headers=headers,
|
| 48 |
-
params=request.query_params,
|
| 49 |
-
content=await request.body(),
|
| 50 |
-
)
|
| 51 |
-
return Response(content=response.content, status_code=response.status_code, headers=dict(response.headers))
|
| 52 |
-
|
| 53 |
@app.get("/")
|
| 54 |
-
async def
|
| 55 |
-
"""
|
| 56 |
-
return StreamingResponse(run_mcp_server())
|
|
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
@app.get("/")
|
| 10 |
+
async def root():
|
| 11 |
+
return {"message": "Notion MCP Keyed is running"}
|
|
|