image-search-mcp 0.1.5__py3-none-any.whl → 0.1.7__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,33 +43,30 @@ def main():
43
43
  if args.sse:
44
44
  try:
45
45
  import uvicorn
46
- from starlette.applications import Starlette
47
- from starlette.routing import Route, Mount
48
- from mcp.server.sse import SseServerTransport
49
-
50
- # 1. Initialize SSE transport
51
- sse = SseServerTransport("/messages")
52
-
53
- # 2. Define the SSE handler as a raw ASGI app to get scope, receive, send
54
- async def handle_sse(scope, receive, send):
55
- async with sse.connect_sse(scope, receive, send) as (read_stream, write_stream):
56
- # Use the underlying server from FastMCP instance
57
- await mcp.server.run(
58
- read_stream,
59
- write_stream,
60
- mcp.server.create_initialization_options()
61
- )
62
-
63
- starlette_app = Starlette(
64
- debug=True,
65
- routes=[
66
- # Mount handles the path prefix and passes raw ASGI arguments
67
- Mount("/sse", app=handle_sse),
68
- Route("/messages", endpoint=sse.handle_post_message, methods=["POST"]),
69
- ]
70
- )
46
+
47
+ # The most robust way to get the ASGI app from FastMCP (v2.3.2+)
48
+ # Explicitly setting path="/" ensures /sse and /messages are at the root
49
+ if hasattr(mcp, "http_app"):
50
+ try:
51
+ app = mcp.http_app(path="/")
52
+ except Exception:
53
+ app = mcp.http_app()
54
+ elif hasattr(mcp, "as_asgi_app"):
55
+ app = mcp.as_asgi_app()
56
+ else:
57
+ # Fallback to internal app if methods are missing
58
+ app = getattr(mcp, "_app", mcp)
71
59
 
72
- app = starlette_app
60
+ # Check for Auth Token
61
+ auth_token = os.environ.get("MCP_AUTH_TOKEN")
62
+ if auth_token:
63
+ print(f"🔒 Authentication enabled. Require Bearer token.")
64
+ app = AuthMiddleware(app, auth_token)
65
+
66
+ print(f"Starting SSE server on {args.host}:{args.port}...")
67
+ # uvicorn.run(app, host=args.host, port=args.port)
68
+ # Use a slightly more verbose uvicorn config for debugging
69
+ uvicorn.run(app, host=args.host, port=args.port, log_level="info")
73
70
 
74
71
  # 3. Apply Auth Middleware if token is provided
75
72
  auth_token = os.environ.get("MCP_AUTH_TOKEN")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: image-search-mcp
3
- Version: 0.1.5
3
+ Version: 0.1.7
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=Ci4nB22YMKOpaQzb5CxcPtjhTFzF_4uL4tCjh-e-uJA,3484
3
+ image_search_mcp/server.py,sha256=zDfg1BAB1yPFdvBBkGbBxsGpUEnOAMORnA7LN-4g5Xg,13445
4
+ image_search_mcp-0.1.7.dist-info/METADATA,sha256=AjWp3HlGplB5hkNRfgrofUs8U8k87nBJS55y72m8cLc,5434
5
+ image_search_mcp-0.1.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ image_search_mcp-0.1.7.dist-info/entry_points.txt,sha256=BD8buPHSQ9yLqGM6w_UGTKjYkVRu_IjH_R736MsDQXM,64
7
+ image_search_mcp-0.1.7.dist-info/top_level.txt,sha256=toz9LX_-JYwJIcGbvfVSH0ap99Nsp2mdzvitLWHyYWo,17
8
+ image_search_mcp-0.1.7.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=qlKRdiHH7rZIkfSFyb-sW1Vm4FQ2C7PDExGnDOdDaLo,3517
3
- image_search_mcp/server.py,sha256=zDfg1BAB1yPFdvBBkGbBxsGpUEnOAMORnA7LN-4g5Xg,13445
4
- image_search_mcp-0.1.5.dist-info/METADATA,sha256=eTZQCd1hD4_bc3lSkATn1Br1LaXEBQd0Z-DiW35iLe0,5434
5
- image_search_mcp-0.1.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
- image_search_mcp-0.1.5.dist-info/entry_points.txt,sha256=BD8buPHSQ9yLqGM6w_UGTKjYkVRu_IjH_R736MsDQXM,64
7
- image_search_mcp-0.1.5.dist-info/top_level.txt,sha256=toz9LX_-JYwJIcGbvfVSH0ap99Nsp2mdzvitLWHyYWo,17
8
- image_search_mcp-0.1.5.dist-info/RECORD,,