Skip to content

Commit 5e9a549

Browse files
authored
Merge pull request #98 from bayesways/mcp-client-fix
change client example to demonstrate usage of tool
2 parents 7311c2a + ee2d91c commit 5e9a549

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

units/en/unit2/gradio-client.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ Here's the complete example of the MCP Client in Gradio:
110110
import gradio as gr
111111
import os
112112

113-
from mcp import StdioServerParameters
114-
from smolagents import InferenceClientModel, CodeAgent, ToolCollection, MCPClient
113+
from smolagents import InferenceClientModel, CodeAgent, MCPClient
115114

116115

117116
try:
@@ -121,12 +120,12 @@ try:
121120
tools = mcp_client.get_tools()
122121

123122
model = InferenceClientModel(token=os.getenv("HUGGINGFACE_API_TOKEN"))
124-
agent = CodeAgent(tools=[*tools], model=model)
123+
agent = CodeAgent(tools=[*tools], model=model, additional_authorized_imports=["json", "ast", "urllib", "base64"])
125124

126125
demo = gr.ChatInterface(
127126
fn=lambda message, history: str(agent.run(message)),
128127
type="messages",
129-
examples=["Prime factorization of 68"],
128+
examples=["Analyze the sentiment of the following text 'This is awesome'"],
130129
title="Agent with MCP Tools",
131130
description="This is a simple agent that uses MCP tools to answer questions.",
132131
)

0 commit comments

Comments
 (0)