mcp-client / app.py
Techno-1's picture
Indented rest of program after with statement
dade101 verified
raw
history blame
835 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=["What's the weather like?"],
title="Agent with MCP Tools",
description="This is a simple agent that uses MCP tools to answer questions.",
)
demo.launch()