LangChain
LangChain:langchain[mcp] 透過 MCPAdapter 將 aicharged.io 的工具轉換為 LangChain 工具。
- API 金鑰(Bearer)
用戶端程式碼
推薦import asyncio, os
from fastmcp import Client
from langchain.mcp import MCPAdapter
async def main():
client = Client("https://aicharged.io/api/v1/mcp", auth=os.environ["AICHARGED_API_KEY"])
async with MCPAdapter(client) as adapter:
tools = await adapter.list_tools()
print([tool.name for tool in tools])
asyncio.run(main())
舊的 langchain-mcp-adapters 套件已停止維護;langchain[mcp] 以 FastMCP 用戶端為基礎。
安裝套件
pip install "langchain[mcp]"