通用代理CLI
使用 谷歌代理开发工具包(ADK) 和 双子座2.5闪光灯该代理可以推理、使用本地工具并连接到模型上下文协议(MCP)服务器。
特性
- 代理推理:用途
LlmAgent用于复杂的任务处理。 - 本地工具:轻松添加自定义JavaScript/TypeScript函数作为工具。
- MCP集成:连接到任何符合MCP标准的服务器(本地或远程)以扩展功能。
- 流媒体用户界面:终端中的实时响应流。
先决条件
- Node.js(v18或更高版本)
- Gemini API密钥来自 谷歌AI工作室
入门指南
- 克隆存储库:
git clone https://github.com/jean-alain42/agent-adk.git
cd agent-adk- 安装依赖项:
npm install- 配置环境:
创建一个 .env 根目录中的文件:
GEMINI_API_KEY=your_api_key_here- 运行代理:
npm start添加工具
1.本地工具
您可以在中添加本地工具 index.ts 使用 FunctionTool 类别:
const myTool = new FunctionTool({
name: "getWeather",
description: "Get the current weather for a city",
parameters: z.object({
city: z.string(),
}),
execute: async ({ city }) => {
// Your logic here
return { weather: "Sunny in " + city };
},
});2.MCP服务器
使用连接到外部工具集 MCPToolset:
// Local Stdio Server
const mcpTools = new MCPToolset({
type: "StdioConnectionParams",
serverParams: {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-everything"],
},
});
// Remote SSE Server
const remoteTools = new MCPToolset({
type: "StreamableHTTPConnectionParams",
url: "https://example.com/mcp",
});要使用这些工具,请将它们添加到 tools 初始化时使用数组 LlmAgent 在 index.ts.
使用提示
- 退出:类型
exit结束会议。 - 工具:代理将根据您的提示自动决定何时使用工具。
- 状态:本地工具,如
getCurrentTime和MCP工具server-everything测试套件已预先配置。
许可证
麻省理工学院
