Install
npm install @langchain/mcp-adapters
Connect
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
const MEWCP_API_KEY = "API_KEY";
async function main() {
const client = new MultiServerMCPClient({
mcpServers: {
mewcp: {
url: "https://gateway.mewcp.com/personal/mcp",
headers: {
Authorization: `Bearer ${MEWCP_API_KEY}`,
},
},
},
});
const tools = await client.getTools();
console.log(
"Available tools:",
tools.map((t) => t.name),
);
// -> ["search", "get_schema", "list_accounts", "call_tool"]
await client.close();
}
main();
You get four tools rather than the tools of each app. Your agent uses them to reach every app you have connected. See How MewCP works.
Call a tool directly
const callTool = tools.find((t) => t.name === "call_tool")!;
const result = await callTool.invoke({
server_maskedId: "google-calendar",
tool_name: "list_events",
args: {
calendar_id: "primary",
time_min: "2026-01-15T00:00:00Z",
time_max: "2026-01-16T00:00:00Z",
},
});
console.log(result);
If you have connected more than one account for the same app, add alias: "work" to select one.
Use with a LangChain agent
Hand all four tools to the agent and let it work out the rest:
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { HumanMessage } from "@langchain/core/messages";
async function main() {
const client = new MultiServerMCPClient({
mcpServers: {
mewcp: {
url: "https://gateway.mewcp.com/personal/mcp",
headers: { Authorization: `Bearer ${MEWCP_API_KEY}` },
},
},
});
const tools = await client.getTools();
const model = new ChatOpenAI({ model: "gpt-4o" });
const agent = createReactAgent({ llm: model, tools });
const result = await agent.invoke({
messages: [new HumanMessage("What is on my calendar tomorrow?")],
});
console.log(result.messages.at(-1)?.content);
await client.close();
}
main();
The agent will call search to find the calendar tool, get_schema for its parameters, then call_tool to run it.
Where to find your values
| Value | Where to get it |
|---|
API_KEY | Dashboard -> API Keys |
| Connected apps | Dashboard -> Servers |
Last modified on