Spaces:
Running
Running
Commit
·
b0dd11f
1
Parent(s):
e8c25e9
mcp bug with for huggyface secret
Browse files- utils/mcp_client.py +7 -1
utils/mcp_client.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
# utils/mcp_client.py
|
| 2 |
import asyncio
|
|
|
|
| 3 |
from typing import Dict, Any, List, Optional
|
| 4 |
from mcp import ClientSession, StdioServerParameters
|
| 5 |
from mcp.client.stdio import stdio_client
|
|
@@ -11,7 +12,12 @@ class MCPMux:
|
|
| 11 |
self._streams = {} # Store streams to keep them alive
|
| 12 |
|
| 13 |
async def connect_stdio(self, name: str, command: str, args: Optional[List[str]] = None, env: Optional[Dict[str,str]] = None):
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Use async context manager for stdio_client
|
| 17 |
stdio = stdio_client(params)
|
|
|
|
| 1 |
# utils/mcp_client.py
|
| 2 |
import asyncio
|
| 3 |
+
import os
|
| 4 |
from typing import Dict, Any, List, Optional
|
| 5 |
from mcp import ClientSession, StdioServerParameters
|
| 6 |
from mcp.client.stdio import stdio_client
|
|
|
|
| 12 |
self._streams = {} # Store streams to keep them alive
|
| 13 |
|
| 14 |
async def connect_stdio(self, name: str, command: str, args: Optional[List[str]] = None, env: Optional[Dict[str,str]] = None):
|
| 15 |
+
# Inherit current env so secrets (e.g., ANTHROPIC_API_KEY) reach child servers
|
| 16 |
+
inherited_env = os.environ.copy()
|
| 17 |
+
if env:
|
| 18 |
+
inherited_env.update(env)
|
| 19 |
+
|
| 20 |
+
params = StdioServerParameters(command=command, args=args or [], env=inherited_env)
|
| 21 |
|
| 22 |
# Use async context manager for stdio_client
|
| 23 |
stdio = stdio_client(params)
|