image-search-mcp 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
image_search_mcp/main.py CHANGED
@@ -43,14 +43,35 @@ def main():
43
43
  if args.sse:
44
44
  try:
45
45
  import uvicorn
46
- # Attempt to find the ASGI app from FastMCP instance
47
- app = mcp
48
- if hasattr(mcp, "_sse_app"):
49
- app = mcp._sse_app
50
- elif hasattr(mcp, "app"):
51
- app = mcp.app
46
+ from starlette.applications import Starlette
47
+ from starlette.routing import Route
48
+ from mcp.server.sse import SseServerTransport
49
+
50
+ # 1. Initialize SSE transport
51
+ # The transport handles the /sse and /messages endpoints
52
+ sse = SseServerTransport("/messages")
53
+
54
+ # 2. Define the ASGI app routes manually to match FastMCP internal logic
55
+ async def handle_sse(request):
56
+ async with sse.connect_sse(request.scope, request.receive, request.send) as (read_stream, write_stream):
57
+ # Use the underlying server from FastMCP instance
58
+ await mcp._server.run(
59
+ read_stream,
60
+ write_stream,
61
+ mcp._server.create_initialization_options()
62
+ )
63
+
64
+ starlette_app = Starlette(
65
+ debug=True,
66
+ routes=[
67
+ Route("/sse", endpoint=handle_sse),
68
+ Route("/messages", endpoint=sse.handle_messages, methods=["POST"]),
69
+ ]
70
+ )
71
+
72
+ app = starlette_app
52
73
 
53
- # Check for Auth Token
74
+ # 3. Apply Auth Middleware if token is provided
54
75
  auth_token = os.environ.get("MCP_AUTH_TOKEN")
55
76
  if auth_token:
56
77
  print(f"🔒 Authentication enabled. Require Bearer token.")
@@ -58,11 +79,10 @@ def main():
58
79
 
59
80
  print(f"Starting SSE server on {args.host}:{args.port}...")
60
81
  uvicorn.run(app, host=args.host, port=args.port)
61
- except ImportError:
62
- print("Error: 'uvicorn' is required for SSE mode. Please install it: pip install uvicorn")
63
- sys.exit(1)
64
82
  except Exception as e:
65
83
  print(f"Error starting SSE server: {e}")
84
+ import traceback
85
+ traceback.print_exc()
66
86
  sys.exit(1)
67
87
  else:
68
88
  # Stdio mode (Default)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: image-search-mcp
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: MCP server for Reverse Image Search using PicImageSearch
5
5
  Author-email: Your Name <your.email@example.com>
6
6
  License: MIT
@@ -0,0 +1,8 @@
1
+ image_search_mcp/__init__.py,sha256=h6DgLFO4TMUk7_wCJ2jn2Y6IkFmfzb-Z7jX-G5UCYVc,43
2
+ image_search_mcp/main.py,sha256=7QbxEYk0FRbvZ5mR5Saxtw5wUsdJrEo_AYId-tC--cA,3510
3
+ image_search_mcp/server.py,sha256=zDfg1BAB1yPFdvBBkGbBxsGpUEnOAMORnA7LN-4g5Xg,13445
4
+ image_search_mcp-0.1.2.dist-info/METADATA,sha256=iqYyvMEdIQR5K1VEhom7_Ml0-N8cXYkEiJ1Znqj17bI,5434
5
+ image_search_mcp-0.1.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ image_search_mcp-0.1.2.dist-info/entry_points.txt,sha256=BD8buPHSQ9yLqGM6w_UGTKjYkVRu_IjH_R736MsDQXM,64
7
+ image_search_mcp-0.1.2.dist-info/top_level.txt,sha256=toz9LX_-JYwJIcGbvfVSH0ap99Nsp2mdzvitLWHyYWo,17
8
+ image_search_mcp-0.1.2.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- image_search_mcp/__init__.py,sha256=h6DgLFO4TMUk7_wCJ2jn2Y6IkFmfzb-Z7jX-G5UCYVc,43
2
- image_search_mcp/main.py,sha256=fnTL5SoXKMa3S2navLqLcd6P8FZZv2aPk2gthqdLIYk,2653
3
- image_search_mcp/server.py,sha256=zDfg1BAB1yPFdvBBkGbBxsGpUEnOAMORnA7LN-4g5Xg,13445
4
- image_search_mcp-0.1.0.dist-info/METADATA,sha256=VGcB-_4vwByKfs_BH-RTQOaDxvql_MRBqJnWBS6kzlU,5434
5
- image_search_mcp-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
- image_search_mcp-0.1.0.dist-info/entry_points.txt,sha256=BD8buPHSQ9yLqGM6w_UGTKjYkVRu_IjH_R736MsDQXM,64
7
- image_search_mcp-0.1.0.dist-info/top_level.txt,sha256=toz9LX_-JYwJIcGbvfVSH0ap99Nsp2mdzvitLWHyYWo,17
8
- image_search_mcp-0.1.0.dist-info/RECORD,,