Spaces:
Runtime error
Runtime error
app.py completed
Browse files
app.py
CHANGED
|
@@ -13,6 +13,24 @@ with MCPClient(
|
|
| 13 |
# Tools from the remote server are available
|
| 14 |
print("\n".join(f"{t.name}: {t.description}" for t in tools))
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
# Create gradio interface
|
|
@@ -26,5 +44,4 @@ with MCPClient(
|
|
| 26 |
# )
|
| 27 |
|
| 28 |
# # Launch the interface and MCP server
|
| 29 |
-
# if __name__ == "__main__":
|
| 30 |
# demo.launch(mcp_server=True)
|
|
|
|
| 13 |
# Tools from the remote server are available
|
| 14 |
print("\n".join(f"{t.name}: {t.description}" for t in tools))
|
| 15 |
|
| 16 |
+
mcp_client = MCPClient(
|
| 17 |
+
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse"} # This is the MCP Client we created in the previous section
|
| 18 |
+
)
|
| 19 |
+
tools = mcp_client.get_tools()
|
| 20 |
+
|
| 21 |
+
model = InferenceClientModel(token=os.getenv("mcp"))
|
| 22 |
+
agent = CodeAgent(tools=[*tools], model=model)
|
| 23 |
+
|
| 24 |
+
demo = gr.ChatInterface(
|
| 25 |
+
fn=lambda message, history: str(agent.run(message)),
|
| 26 |
+
type="messages",
|
| 27 |
+
examples=["today weather is nice"],
|
| 28 |
+
title="Agent with MCP Tools",
|
| 29 |
+
description="This is a simple agent that uses MCP tools to answer questions."
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# if __name__ == "__main__":
|
| 33 |
+
demo.launch()
|
| 34 |
|
| 35 |
|
| 36 |
# Create gradio interface
|
|
|
|
| 44 |
# )
|
| 45 |
|
| 46 |
# # Launch the interface and MCP server
|
|
|
|
| 47 |
# demo.launch(mcp_server=True)
|