Spaces:
Running
on
Zero
Running
on
Zero
Update gradio_mcp_server.py
Browse files- gradio_mcp_server.py +10 -2
gradio_mcp_server.py
CHANGED
@@ -3,8 +3,7 @@ from gradio_client import Client
|
|
3 |
import sys
|
4 |
import io
|
5 |
import json
|
6 |
-
|
7 |
-
from huggingface_hub import InferenceClient
|
8 |
mcp = FastMCP("gradio-spaces")
|
9 |
|
10 |
clients = {}
|
@@ -16,6 +15,7 @@ def get_client(space_id: str) -> Client:
|
|
16 |
return clients[space_id]
|
17 |
|
18 |
|
|
|
19 |
@mcp.tool()
|
20 |
async def generate_image(prompt: str, space_id: str = "inoculatemedia/SanaSprint") -> str:
|
21 |
"""Generate an image using Flux.
|
@@ -37,3 +37,11 @@ async def generate_image(prompt: str, space_id: str = "inoculatemedia/SanaSprint
|
|
37 |
api_name="/infer"
|
38 |
)
|
39 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import sys
|
4 |
import io
|
5 |
import json
|
6 |
+
|
|
|
7 |
mcp = FastMCP("gradio-spaces")
|
8 |
|
9 |
clients = {}
|
|
|
15 |
return clients[space_id]
|
16 |
|
17 |
|
18 |
+
|
19 |
@mcp.tool()
|
20 |
async def generate_image(prompt: str, space_id: str = "inoculatemedia/SanaSprint") -> str:
|
21 |
"""Generate an image using Flux.
|
|
|
37 |
api_name="/infer"
|
38 |
)
|
39 |
return result
|
40 |
+
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
import sys
|
44 |
+
import io
|
45 |
+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
46 |
+
|
47 |
+
mcp.run(transport='stdio')
|