Entz commited on
Commit
ba7bc65
·
verified ·
1 Parent(s): 1ccb5ca

Upload 6 files

Browse files
Files changed (4) hide show
  1. backend.py +15 -13
  2. huggingface.yaml +5 -0
  3. requirements.txt +1 -4
  4. stock_server.py +1 -1
backend.py CHANGED
@@ -3,7 +3,8 @@
3
  Backend module for MCP Agent
4
  Handles all the MCP server connections, LLM setup, and agent logic
5
  """
6
-
 
7
  import os
8
  import re
9
  import asyncio
@@ -171,18 +172,19 @@ class MCPAgent:
171
 
172
  # Start the Stock server separately first: `python stockserver.py`
173
  self.client = MultiServerMCPClient(
174
- {
175
- "arithmetic": {
176
- "command": "python",
177
- "args": ["arithmetic_server.py"],
178
- "transport": "stdio",
179
- },
180
- "stocks": {
181
- "url": "http://localhost:8000/mcp",
182
- "transport": "streamable_http",
183
- },
184
- }
185
- )
 
186
 
187
  # 1. MCP client + tools
188
  self.tools = await self.client.get_tools()
 
3
  Backend module for MCP Agent
4
  Handles all the MCP server connections, LLM setup, and agent logic
5
  """
6
+ import sys
7
+ from pathlib import Path
8
  import os
9
  import re
10
  import asyncio
 
172
 
173
  # Start the Stock server separately first: `python stockserver.py`
174
  self.client = MultiServerMCPClient(
175
+ {
176
+ "arithmetic": {
177
+ "command": sys.executable,
178
+ "args": [str(here / "arithmetic_server.py")],
179
+ "transport": "stdio",
180
+ },
181
+ "stocks": {
182
+ "command": sys.executable,
183
+ "args": [str(here / "stock_server.py")],
184
+ "transport": "stdio",
185
+ },
186
+ }
187
+ )
188
 
189
  # 1. MCP client + tools
190
  self.tools = await self.client.get_tools()
huggingface.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # huggingface.yaml
2
+ title: mcp-agent-chat
3
+ sdk: streamlit
4
+ app_file: frontend.py
5
+ python_version: "3.10"
requirements.txt CHANGED
@@ -2,12 +2,9 @@ langchain-mcp-adapters==0.1.9
2
  mcp==1.12.3
3
  langgraph==0.6.3
4
  langchain-huggingface==0.3.1
5
- aiohttp=3.12.15
6
-
7
-
8
  streamlit==1.48.0
9
  python-dotenv
10
  huggingface-hub
11
-
12
  fastmcp
13
  asyncio
 
2
  mcp==1.12.3
3
  langgraph==0.6.3
4
  langchain-huggingface==0.3.1
5
+ aiohttp==3.12.15
 
 
6
  streamlit==1.48.0
7
  python-dotenv
8
  huggingface-hub
 
9
  fastmcp
10
  asyncio
stock_server.py CHANGED
@@ -60,4 +60,4 @@ async def get_company_news(symbol: str, limit: int = 3) -> str:
60
  3. {symbol} unveils new product line for 2025"""
61
 
62
  if __name__ == "__main__":
63
- mcp.run(transport="streamable-http")
 
60
  3. {symbol} unveils new product line for 2025"""
61
 
62
  if __name__ == "__main__":
63
+ mcp.run(transport="stdio")