image-search-mcp 0.1.1__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,17 +43,35 @@ def main():
43
43
  if args.sse:
44
44
  try:
45
45
  import uvicorn
46
- # FastMCP's Starlette app is usually available via the ._app attribute
47
- # after some initialization, or we can use its built-in server logic.
48
- # To apply middleware, we need the actual ASGI app.
49
-
50
- # This is a more robust way to get the ASGI app from FastMCP
51
- from mcp.server.fastmcp import FastMCP
52
-
53
- # Force initialization of the SSE app if possible
54
- app = mcp.as_asgi_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
55
73
 
56
- # Check for Auth Token
74
+ # 3. Apply Auth Middleware if token is provided
57
75
  auth_token = os.environ.get("MCP_AUTH_TOKEN")
58
76
  if auth_token:
59
77
  print(f"🔒 Authentication enabled. Require Bearer token.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: image-search-mcp
3
- Version: 0.1.1
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=GmXTnS47NjXZiJH3QB2UryiI8Hyr8QBVFKfyfTDFH4o,2808
3
- image_search_mcp/server.py,sha256=zDfg1BAB1yPFdvBBkGbBxsGpUEnOAMORnA7LN-4g5Xg,13445
4
- image_search_mcp-0.1.1.dist-info/METADATA,sha256=pL67qCh6bxWI2k7qBPI2gcUGlEEuMwGDc0TUTfwoNvo,5434
5
- image_search_mcp-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
- image_search_mcp-0.1.1.dist-info/entry_points.txt,sha256=BD8buPHSQ9yLqGM6w_UGTKjYkVRu_IjH_R736MsDQXM,64
7
- image_search_mcp-0.1.1.dist-info/top_level.txt,sha256=toz9LX_-JYwJIcGbvfVSH0ap99Nsp2mdzvitLWHyYWo,17
8
- image_search_mcp-0.1.1.dist-info/RECORD,,