Skip to content

Commit 7ab99e7

Browse files
committed
new: MCP env variables referenced in agents will be set from environment value if found and not already set
1 parent 98807f9 commit 7ab99e7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

nerve/tools/mcp/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import typing as t
23
from contextlib import AsyncExitStack, asynccontextmanager
34

@@ -13,6 +14,13 @@ class Client:
1314
name: str = ""
1415

1516
def __init__(self, name: str, server: Configuration.MCPServer):
17+
for key, value in server.env.items():
18+
if not value:
19+
env_val = os.getenv(key)
20+
if env_val:
21+
logger.debug("setting {} from env", key)
22+
server.env[key] = env_val
23+
1624
self.name = name
1725
self.server = server
1826
self.server_params = StdioServerParameters(command=server.command, args=server.args, env=server.env)

nerve/tools/mcp/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async def get_tools_from_mcp(name: str, server: Configuration.MCPServer) -> list
122122
for mcp_tool in mpc_tools:
123123
func_body, type_defs = await create_function_body(client, mcp_tool)
124124

125-
print(func_body)
125+
# print(func_body)
126126
exec(func_body, type_defs)
127127

128128
tool_fn = wrap_tool_function(type_defs[mcp_tool.name])

0 commit comments

Comments
 (0)