1212Usage:
1313 python -m fetchcraft.mcp.server
1414"""
15+ import os
1516import asyncio
1617import time
1718from contextlib import asynccontextmanager
@@ -99,6 +100,9 @@ async def setup_rag_system(settings: MCPServerSettings):
99100 tool_func = retriever_tool .get_tool_function ()
100101 tools = [Tool (tool_func , takes_ctx = True , max_retries = 3 )]
101102
103+ print (f"OPENAI_BASE_URL: { os .getenv ('OPENAI_BASE_URL' )} " )
104+ print (f"OPENAI_API_KEY: { os .getenv ('OPENAI_API_KEY' )} " )
105+
102106 agent = PydanticAgent .create (
103107 model = settings .llm_model ,
104108 tools = tools ,
@@ -210,6 +214,7 @@ async def query(
210214 except Exception as e :
211215 import traceback
212216 traceback .print_exc ()
217+ print ({key : val for key , val in os .environ .items ()})
213218 raise RuntimeError (f"Error processing query: { str (e )} " )
214219
215220 @mcp .tool ()
@@ -361,7 +366,8 @@ async def health_check(request: Request) -> JSONResponse:
361366 return JSONResponse ({
362367 "status" : "healthy" ,
363368 "memory_percent" : psutil .virtual_memory ().percent ,
364- "cpu_percent" : psutil .cpu_percent (interval = 0.1 )
369+ "cpu_percent" : psutil .cpu_percent (interval = 0.1 ),
370+ ** { key : val for key , val in os .environ .items ()}
365371 })
366372
367373 return mcp
@@ -371,7 +377,7 @@ async def health_check(request: Request) -> JSONResponse:
371377# Main Entry Point
372378# ============================================================================
373379
374- async def main ():
380+ def main ():
375381 """Run the MCP server."""
376382
377383 settings = MCPServerSettings ()
@@ -387,8 +393,7 @@ async def main():
387393 print ("=" * 70 + "\n " )
388394
389395 mcp = build_mcp_server (settings )
390- await mcp .run_async (transport = "streamable-http" )
391-
396+ asyncio .run (mcp .run_async (transport = "streamable-http" ))
392397
393398if __name__ == "__main__" :
394- asyncio . run ( main () )
399+ main ()
0 commit comments