Install
pip install langchain-mcp-adapters
Connect
import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
MEWCP_API_KEY = "API_KEY"
async def main():
async with MultiServerMCPClient(
{
"mewcp": {
"transport": "streamable_http",
"url": "https://gateway.mewcp.com/personal/mcp",
"headers": {"Authorization": f"Bearer {MEWCP_API_KEY}"},
}
}
) as client:
tools = await client.get_tools()
print("Available tools:", [t.name for t in tools])
# -> ["search", "get_schema", "list_accounts", "call_tool"]
asyncio.run(main())
Note: transport value is "streamable_http" (underscore).
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
call_tool = next(t for t in tools if t.name == "call_tool")
result = await call_tool.ainvoke(
{
"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",
},
}
)
print(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 asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
async def main():
async with MultiServerMCPClient(
{
"mewcp": {
"transport": "streamable_http",
"url": "https://gateway.mewcp.com/personal/mcp",
"headers": {"Authorization": f"Bearer {MEWCP_API_KEY}"},
}
}
) as client:
tools = await client.get_tools()
model = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(model, tools)
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "What is on my calendar tomorrow?"}]}
)
print(result["messages"][-1].content)
asyncio.run(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