Context
This first tests have been written in a decidated repository but it is better to keep them in the MCP
Note
Finally found a solution for the beloved corporate proxy with undici :
import { createAgent, tool } from "langchain";
import * as z from "zod";
import { setGlobalDispatcher, ProxyAgent } from "undici";
const proxyAgent = new ProxyAgent(process.env.HTTP_PROXY);
setGlobalDispatcher(proxyAgent);
const getWeather = tool(
(input) => `It's always sunny in ${input.city}!`,
{
name: "get_weather",
description: "Get the weather for a given city",
schema: z.object({
city: z.string().describe("The city to get the weather for"),
}),
}
);
const agent = createAgent({
model: "claude-sonnet-4-6",
tools: [getWeather],
});
console.log(
await agent.invoke({
messages: [{ role: "user", content: "What's the weather in Tokyo?" }],
})
);
Context
This first tests have been written in a decidated repository but it is better to keep them in the MCP
Note
Finally found a solution for the beloved corporate proxy with undici :