khoitda commited on
Commit
5de6ed4
·
1 Parent(s): e923832
Files changed (6) hide show
  1. .gitignore +10 -0
  2. .python-version +1 -0
  3. app.py +31 -0
  4. pyproject.toml +13 -0
  5. requirements.txt +2 -0
  6. uv.lock +0 -0
.gitignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.11
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ from mcp import StdioServerParameters
5
+ from smolagents import InferenceClientModel, CodeAgent, ToolCollection, MCPClient
6
+
7
+ try:
8
+ mcp_client = MCPClient(
9
+ {
10
+ "url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse",
11
+ "transport": "sse",
12
+ } # This is the MCP Client we created in the previous section
13
+ )
14
+ tools = mcp_client.get_tools()
15
+ model = InferenceClientModel(
16
+ token=os.getenv("HF_TOKEN")
17
+ )
18
+ agent = CodeAgent(tools=[*tools], model=model)
19
+
20
+
21
+ demo = gr.ChatInterface(
22
+ fn=lambda message, history: str(agent.run(message)),
23
+ type="messages",
24
+ examples=["Prime factorization of 68"],
25
+ title="Agent with MCP Tools",
26
+ description="This is a simple agent that uses MCP tools to answer questions."
27
+ )
28
+
29
+ demo.launch()
30
+ finally:
31
+ mcp_client.disconnect()
pyproject.toml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "hf-mcp"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "fastmcp>=2.8.1",
9
+ "gradio[mcp]>=5.30.0",
10
+ "httpx>=0.28.1",
11
+ "mcp[cli]>=1.9.4",
12
+ "smolagents[mcp]>=1.18.0",
13
+ ]
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ smolagents[mcp]
uv.lock ADDED
The diff for this file is too large to render. See raw diff