nikko-pfffff commited on
Commit
e4ee95a
·
1 Parent(s): c63b708

initial commit

Browse files
Files changed (7) hide show
  1. .gitignore +11 -0
  2. .python-version +1 -0
  3. client.py +8 -0
  4. client2.py +26 -0
  5. main.py +6 -0
  6. pyproject.toml +10 -0
  7. uv.lock +0 -0
.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .env
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.13
client.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from smolagents.mcp_client import MCPClient
2
+
3
+ with MCPClient(
4
+ {"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse", "transport": "sse",},
5
+ structured_output=True
6
+ ) as tools:
7
+ # Tools from the remote server are available
8
+ print("\n".join(f"{t.name}: {t.description}" for t in tools))
client2.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ from smolagents import InferenceClientModel, CodeAgent, MCPClient
5
+
6
+
7
+ try:
8
+ mcp_client = MCPClient(
9
+ {"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse", "transport": "sse",}
10
+ )
11
+ tools = mcp_client.get_tools()
12
+
13
+ model = InferenceClientModel(token=os.getenv("HUGGINGFACE_API_TOKEN"))
14
+ agent = CodeAgent(tools=[*tools], model=model, additional_authorized_imports=["json", "ast", "urllib", "base64"])
15
+
16
+ demo = gr.ChatInterface(
17
+ fn=lambda message, history: str(agent.run(message)),
18
+ type="messages",
19
+ examples=["Analyze the sentiment of the following text 'This is awesome'"],
20
+ title="Agent with MCP Tools",
21
+ description="This is a simple agent that uses MCP tools to answer questions.",
22
+ )
23
+
24
+ demo.launch()
25
+ finally:
26
+ mcp_client.disconnect()
main.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ def main():
2
+ print("Hello from mcp-client!")
3
+
4
+
5
+ if __name__ == "__main__":
6
+ main()
pyproject.toml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "mcp-client"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = [
8
+ "gradio[mcp]>=6.0.2",
9
+ "smolagents[mcp]>=1.23.0",
10
+ ]
uv.lock ADDED
The diff for this file is too large to render. See raw diff