mcp-client / app.py
Techno-1's picture
Changed example to work with sentiment analysis tool
eb9cf92 verified
raw
history blame contribute delete
848 Bytes
import gradio as gr
from mcp.client.stdio import StdioServerParameters
from smolagents import ToolCollection, CodeAgent
from smolagents import CodeAgent, InferenceClientModel
from smolagents.mcp_client import MCPClient
with MCPClient(
# {"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse"}
{"url": "https://techno-1-mcp-sentiment.hf.space/gradio_api/mcp/sse", "transport": "streamable-http"}
) as tools:
model = InferenceClientModel()
agent = CodeAgent(tools=[*tools], model=model)
demo = gr.ChatInterface(
fn=lambda message, history: str(agent.run(message)),
type="messages",
examples=["Analyse the sentiment of: I Love Cats"],
title="Agent with MCP Tools",
description="This is a simple agent that uses MCP tools to answer questions.",
)
demo.launch()