智能代理命令行工具

一个基于Google Agent Development Kit (ADK)和Gemini 2.5 Flash构建的智能命令行代理工具,具备推理能力、本地工具使用及与Model Context Protocol (MCP)服务器连接的功能。

  • by jean-alain42
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 jean-alain42/agent-adk

使用说明

通用代理CLI

使用 谷歌代理开发工具包(ADK) 和 双子座2.5闪光灯该代理可以推理、使用本地工具并连接到模型上下文协议(MCP)服务器。

特性

  • 代理推理:用途 LlmAgent 用于复杂的任务处理。
  • 本地工具:轻松添加自定义JavaScript/TypeScript函数作为工具。
  • MCP集成:连接到任何符合MCP标准的服务器(本地或远程)以扩展功能。
  • 流媒体用户界面:终端中的实时响应流。

先决条件

入门指南

  1. 克隆存储库:

    git clone https://github.com/jean-alain42/agent-adk.git
    cd agent-adk
    
  2. 安装依赖项:

    npm install
    
  3. 配置环境: 创建一个 .env 根目录中的文件:

    GEMINI_API_KEY=your_api_key_here
    
  4. 运行代理:

    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 测试套件已预先配置。

许可证

麻省理工学院