Token导航 LogoToken导航TokenDH.com
CLI Agent MCP logo
开发工具stdio官方级别未说明来源级核验

CLI Agent MCP

MCP Server

CLI代理MCP服务器为AI代理提供统一的模型上下文协议接口,支持多种AI工具(如Codex、Gemini、Claude等)的调用和协作,适用于代码分析、UI设计、图像生成等多种场景。

工具数

11

提示词数

0

GitHub Stars

22

资源数

0
AI协作代码分析PythonClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

shiharuharu

提供方

shiharuharu

最后核验

2026/5/17 20:20

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uvx cli-agent-mcp

详细介绍

cli代理mcp

中文文档

用于CLI AI代理的统一MCP(模型上下文协议)服务器。提供一个接口来调用Codex、Gemini、Claude、OpenCode CLI工具和Nano Banana Pro图像生成。

为什么选择cli代理mcp?

这不仅仅是一个CLI包装器——它是一个 编排模式 用于多模型协作。

你不能清楚地表达你的要求吗? 让克劳德来编排。描述你想要什么,它会将你模糊的想法分解为适合代理人的具体任务。授权行为迫使事情变得清晰。

规划一个宏伟的产品愿景? 每个型号都有一个独特的镜头:

  • 法典:评论家。它的分析眼光捕捉到你错过的东西,挑战假设,发现边缘案例。
  • 双子座:创意。发散思维,意想不到的联系,你不知道自己需要的火花。
  • 克劳德:抄写员。忠实的执行,清晰的文档,将想法转化为可工作的代码。
  • 香蕉:艺术家。为UI模型、产品视觉效果和创意资产生成高保真图像。

想要持续的结果? 使用 handoff_file 捕获代理输出,然后让Claude综合多个分析的见解。

我们不只是包装CLIs——我们提供 思维框架 用于人类与人工智能的协作。

特性

  • 统一接口:单个MCP服务器暴露多个CLI代理
  • GUI仪表板:使用pywebview进行实时任务监控
  • 请求隔离:用于安全并发使用的每个请求执行上下文
  • 信号处理:通过信号情报优雅地取消,而不会杀死服务器
  • 调试日志:用于调试的全面子流程输出捕获

截图

CLI Agent MCP GUI

安装

# Install from PyPI (when published)
uvx cli-agent-mcp

# Install from GitHub
uvx --from git+https://github.com/shiharuharu/cli-agent-mcp.git cli-agent-mcp

# Install from source (editable mode for development)
uvx --from /path/to/cli-agent-mcp cli-agent-mcp

# Or use pip
pip install -e .

配置

通过环境变量进行配置:

变量描述默认值
CAM_ENABLE已启用工具的逗号分隔列表(空=全部)"" (全部)
CAM_DISABLE禁用工具的逗号分隔列表(从启用中减去)""
CAM_GUI启用GUI仪表板true
CAM_GUI_DETAILGUI详细模式false
CAM_GUI_KEEP退出时保持GUIfalse
CAM_GUI_HOSTGUI绑定主机127.0.0.1
CAM_GUI_PORTGUI绑定端口(设置一个固定端口,以保持URL在重新启动时的稳定)0 (随机)
CAM_DEBUG在MCP响应中包含调试信息false
CAM_LOG_DEBUG将调试日志写入临时文件false
CAM_SIGINT_MODE信号处理(cancel/exit/cancel_then_exit)cancel
CAM_SIGINT_DOUBLE_TAP_WINDOW双击退出窗口(秒)1.0

工具

法典

调用OpenAI Codex CLI代理进行深度代码分析和关键审查。

最佳:代码审查、bug查找、安全分析

参数类型必填默认说明
promptstring-代理任务说明
workspacestring-项目目录的绝对路径
handoff_filestring-必修的。服务器端仅追加输出捕获(始终包裹在 ``)
continuation_idstring""从上一个响应转到继续对话
permissionstringread-only权限级别: read-only, workspace-write, unlimited
modelstring""模型覆盖(仅在明确要求时指定)
report_modebooleanfalse生成独立报告格式
compact_responsebooleanfalse返回紧凑状态消息而不是完整输出(完整输出仍写入handoff_file)
verbose_outputbooleanfalse返回包括推理在内的详细输出
context_paths数组[]参考文件/目录路径以提供上下文
image数组[]视觉上下文中图像文件的绝对路径
task_notestring""GUI显示标签
debugboolean(全局)覆盖此调用的调试设置

双子座

调用Google Gemini CLI代理进行UI设计和全面分析。

最佳:UI模型、图像分析、需求发现、全文分析

参数类型必填默认说明
promptstring-代理任务说明
workspacestring-项目目录的绝对路径
handoff_filestring-必修的。服务器端仅追加输出捕获(始终包裹在 ``)
continuation_idstring""从上一个响应转到继续对话
permissionstringread-only权限级别: read-only, workspace-write, unlimited
modelstring""模型覆盖
report_modebooleanfalse生成独立报告格式
compact_responsebooleanfalse返回紧凑状态消息而不是完整输出(完整输出仍写入handoff_file)
verbose_outputbooleanfalse返回包括推理在内的详细输出
context_paths数组[]参考文件/目录路径以提供上下文
task_notestring""GUI显示标签
debugboolean(全局)覆盖此调用的调试设置

克劳德

调用Anthropic Claude CLI代理进行代码实现。

最佳:功能实现、重构、代码生成

参数类型必填默认说明
promptstring-代理任务说明
workspacestring-项目目录的绝对路径
handoff_filestring-必修的。服务器端仅追加输出捕获(始终包裹在 ``)
continuation_idstring""从上一个响应转到继续对话
permissionstringread-only权限级别: read-only, workspace-write, unlimited
modelstring""模型覆盖(sonnet, opus,或完整型号名称)
report_modebooleanfalse生成独立报告格式
compact_responsebooleanfalse返回紧凑状态消息而不是完整输出(完整输出仍写入handoff_file)
verbose_outputbooleanfalse返回包括推理在内的详细输出
context_paths数组[]参考文件/目录路径以提供上下文
system_promptstring""完全替换默认系统提示
append_system_promptstring""附加到默认提示的附加说明
agentstring""指定代理名称(覆盖默认代理设置)
task_notestring""GUI显示标签
debugboolean(全局)覆盖此调用的调试设置

开源代码

调用OpenCode CLI代理进行全栈开发。

最佳:快速原型制作、多框架项目

参数类型必填默认说明
promptstring-代理任务说明
workspacestring-项目目录的绝对路径
handoff_filestring-必修的。服务器端仅追加输出捕获(始终包裹在 ``)
continuation_idstring""从上一个响应转到继续对话
permissionstringread-only权限级别: read-only, workspace-write, unlimited
modelstring""模型覆盖(格式: provider/model)
report_modebooleanfalse生成独立报告格式
compact_responsebooleanfalse返回紧凑状态消息而不是完整输出(完整输出仍写入handoff_file)
verbose_outputbooleanfalse返回包括推理在内的详细输出
context_paths数组[]参考文件/目录路径以提供上下文
file数组[]要附加的文件的绝对路径
agentstringbuild代理类型: build, plan等等。
task_notestring""GUI显示标签
debugboolean(全局)覆盖此调用的调试设置

香蕉

通过Nano Banana Pro API生成高保真图像。

最佳:UI模型、产品视觉效果、信息图表、建筑渲染、角色艺术

Nano Banana Pro具有出色的理解力和视觉表达能力——你的快速创造力是唯一的限制,而不是模型。

参数类型必填默认说明
promptstring-图像生成提示
save_pathstring-用于保存图像的基本目录
task_notestring-子目录名称(建议使用英文,例如“英雄横幅”)。文件保存到 {save_path}/{task_note}/
images数组[]具有可选角色和标签的参考图像(绝对路径)
aspect_ratiostring"1:1"图像宽高比: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
resolutionstring"1K"图像分辨率: 1K, 2K, 4K
include_thoughtsbooleanfalse在回应中纳入思考过程

环境变量:

变量必填默认描述
BANANA_AUTH_TOKEN-Google API密钥或Bearer令牌
BANANA_ENDPOINThttps://generativelanguage.googleapis.comAPI终结点(版本路径自动添加)

提示最佳实践:

  • 明确请求图像(例如,以“生成图像:”开头或包含 "output":"image")
  • 对复杂的请求使用结构化规范(JSON/XML标签/标记部分)
  • 使用 MUST/STRICT/CRITICAL 对于不可协商的约束
  • 添加负面约束(例如,“无水印”、“无失真手”)

图像

通过OpenRouter兼容或OpenAI兼容的端点生成图像。

最佳:当您需要与各种提供商兼容时,可以生成通用图像。为了获得Gemini模型的最佳效果,请使用 banana 工具代替。

参数类型必填默认说明
promptstring-图像生成提示
save_pathstring-用于保存图像的基本目录
task_notestring-子目录名称(建议使用英文,例如“英雄横幅”)。文件保存到 {save_path}/{task_note}/
images数组[]具有可选角色和标签的参考图像(绝对路径)
aspect_ratiostring"1:1"图像宽高比: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
resolutionstring"1K"图像分辨率: 1K, 2K, 4K
modelstring(env)用于生成的模型
api_type字符串(env)API类型: openrouter_chat, openai_images, openai_responses

环境变量:

变量必填默认描述
IMAGE_AUTH_TOKEN-用于图像生成的API密钥
IMAGE_ENDPOINThttps://openrouter.ai/apiAPI终结点(版本路径自动添加)
IMAGE_MODELgpt-image-1默认型号
IMAGE_API_TYPEopenrouter_chatAPI类型: openrouter_chat, openai_images, openai_responses

\*\_与模板并行

使用简单的占位符模板批量执行任务。适用于所有CLI代理:

  • codex_parallel_with_template
  • gemini_parallel_with_template
  • claude_parallel_with_template
  • opencode_parallel_with_template

最佳:批代码审查、批文件处理、结构化数据批分析

模板语法:

Supported:
  {{ name }}              # Simple variable substitution
  {{ vars.file_path }}    # Dotted dict path (nested dict lookup)
  {{{{                    # Escape to output {{
  }}}}                    # Escape to output }}

NOT supported:
  {{ a | default(...) }}  # Filters
  {{ foo.bar() }}         # Function calls
  {{ a + b }}             # Expressions
  {% if %}...{% endif %}  # Conditionals
  {% for %}...{% endfor %} # Loops
参数类型必填默认说明
templatestring-用于生成提示的占位符模板
variables数组-变量字典列表(每个字典生成一个任务)
workspacestring-项目目录的绝对路径
handoff_filestring-服务器端仅追加输出捕获
task_note_templatestring""每个任务标签的模板
permissionstringread-only权限级别
parallel_max_concurrency整数20最大并发任务数
parallel_fail_fastbooleanfalse首次失败时停止
context_paths数组[]所有任务的共享上下文路径
context_paths_parallel数组[]每个任务的上下文路径(长度必须与变量匹配)

自动注入变量 (在模板中可用,覆盖变量\[i\]中的同名键):

  • task_index:当前任务的基于1的索引
  • task_count:任务总数
  • vars:原始变量\[i\]dict

示例:批处理代码审核

{
  "template": "Review {{ file_path }} focusing on {{ focus }}. Task {{ task_index }}/{{ task_count }}.",
  "variables": [
    {"file_path": "src/handlers/cli.py", "focus": "error handling"},
    {"file_path": "src/handlers/parallel.py", "focus": "concurrency safety"},
    {"file_path": "src/server.py", "focus": "input validation"}
  ],
  "task_note_template": "[Review] {{ file_path }}",
  "workspace": "/path/to/project",
  "handoff_file": ".agent-handoff/review_batch.md",
  "parallel_max_concurrency": 3
}

获取url

获取GUI仪表板URL。返回可访问实时事件查看器的HTTP URL。

无需参数。

提示注入

一些参数使用以下命令自动向提示中注入额外内容 `` XML标签。这些标签使调试和识别系统注入的内容变得容易。

report_mode

report_mode 设置后,注入输出格式要求:


  
    This response will be saved as a standalone document.
    Write so it can be understood WITHOUT any prior conversation context.
    Do NOT reference "above", "previous messages", or "as discussed".
    Use the same language as the user's request.
  
  
    
3-7 bullet points with key findings and conclusions

    
Restate the task/problem so readers understand without chat history

    
Step-by-step reasoning with evidence; include file:line references

    
Actionable next steps ordered by priority

  
  Write with enough detail to be useful standalone, but avoid unnecessary filler.

context_paths

context_paths 注入参考路径:


  
    These paths are provided as reference for project structure.
    You may use them to understand naming conventions and file organization.
  
  

    
/src/api/handlers.py

    
/config/settings.json

  

无状态设计

重要:每个工具调用都是无状态的——代理对以前的调用没有记忆。

  • 新对话 (没有 continuation_id):在你的提示中包括所有相关的背景、细节、限制和先前的发现。
  • 继续对话 (与 continuation_id):代理保留该会话的上下文,因此您可以简短。

如果您的请求引用了之前的上下文(例如,“修复该错误”、“继续工作”),您必须:

  1. 提供 continuation_id 根据之前的回复,或
  2. 将参考扩展到具体细节

交接文件

handoff_file 所有CLI工具都需要。服务器在执行后将每个工具输出附加到此文件中。

行为(始终):

  • 仅附加(从不覆盖)
  • 包装为 `agent, continuation_id, task_note, task_index, status`
  • task_index:单个任务= 0;并行任务= 1..N
  • 失败时,仍附加 status="error" 和a Error: ... 消息

安全注意事项:

  • 避免对同一路径进行并发写入(输出可能会交错)
  • 避免双重写入冲突:不要指向 handoff_file 在要求代理编辑的文件中
  • 推荐:使用 .agent-handoff/ (例如。, .agent-handoff/handoff_chain.md)

包装示例:


... agent response (Markdown) ...

迁移: save_filehandoff_file

save_file, save_file_with_wrapper,以及 save_file_with_append_mode 被移除。使用 handoff_file 相反(必需;始终附加;始终包装)。

响应格式

所有响应都以XML格式包装:

成功响应


  ...  
  
    Agent's response content...
  
  session-id-here
  ...  

错误响应

错误响应包括允许重试的部分进度:


  Error message
  ...  
  
...
    
  session-id
  Task failed. Above is the output collected so far. You can send 'continue' with this continuation_id to retry.
  ...

权限级别

级别描述CodexGeminiClaudeOpenCodeBanana
read-only只能读取文件--sandbox read-only只读工具--tools Read,Grep,Globedit: deny, bash: deny仅读取工作区图像
workspace-write可以修改工作区中的文件--sandbox workspace-write所有工具+沙盒--tools Read,Edit,Write,Bashedit: allow, bash: ask仅写入工作区
unlimited完全系统访问权限(谨慎使用)--sandbox danger-full-access所有工具,无沙盒--tools defaultedit: allow, bash: allow完全访问

调试模式

启用调试模式以获取详细的执行信息:

# Enable debug info in responses
export CAM_DEBUG=true

# Enable detailed log file
export CAM_LOG_DEBUG=true

CAM_LOG_DEBUG=true,日志将写入:

/tmp/cli-agent-mcp/cam_debug_YYYYMMDD_HHMMSS.log

调试输出包括:

  • 完整子流程命令
  • 完成stdout/stderr输出
  • 返回代码
  • MCP请求/响应摘要

MCP配置

添加到您的MCP客户端配置中(例如,Claude Desktop claude_desktop_config.json):

基本配置

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"]
    }
  }
}

从GitHub安装

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/shiharuharu/cli-agent-mcp.git",
        "cli-agent-mcp"
      ]
    }
  }
}

具有调试模式

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/shiharuharu/cli-agent-mcp.git",
        "cli-agent-mcp"
      ],
      "env": {
        "CAM_DEBUG": "true",
        "CAM_LOG_DEBUG": "true"
      }
    }
  }
}

禁用GUI

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"],
      "env": {
        "CAM_GUI": "false"
      }
    }
  }
}

限制可用工具

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"],
      "env": {
        "CAM_ENABLE": "claude,gemini"
      }
    }
  }
}

禁用图像工具

{
  "mcpServers": {
    "cli-agent-mcp": {
      "command": "uvx",
      "args": ["cli-agent-mcp"],
      "env": {
        "CAM_DISABLE": "banana,image"
      }
    }
  }
}

项目结构

cli-agent-mcp/
├── src/cli_agent_mcp/
│   ├── __init__.py          # Package exports
│   ├── __main__.py          # Entry point
│   ├── app.py               # Server lifecycle (run_server, main)
│   ├── server.py            # MCP protocol adapter (create_server)
│   ├── tool_schema.py       # Tool descriptions and JSON schemas
│   ├── config.py            # Configuration management
│   ├── gui_manager.py       # GUI dashboard manager
│   ├── orchestrator.py      # Request registry
│   ├── signal_manager.py    # Signal handling (SIGINT/SIGTERM)
│   ├── handlers/            # Tool handlers
│   │   ├── base.py          # ToolContext, ToolHandler base class
│   │   ├── cli.py           # CLI tools (codex/gemini/claude/opencode)
│   │   ├── parallel.py      # Parallel execution (*_parallel tools)
│   │   ├── parallel_with_template.py  # Template-based parallel (*_parallel_with_template)
│   │   └── image_tools.py   # Image tools (banana/image)
│   ├── utils/               # Utility functions
│   │   ├── xml_wrapper.py   # XML escaping and wrapper building
│   │   ├── prompt_injection.py  # Prompt injection helpers
│   │   └── simple_template.py   # Simple placeholder template engine
│   └── shared/              # Shared modules
│       ├── invokers/        # CLI invoker implementations
│       ├── parsers/         # Output parsers
│       ├── gui/             # GUI components
│       └── response_formatter.py  # Response formatting
└── tests/

发展

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

许可证

麻省理工学院

目录标签

目录标签

AI协作代码分析PythonClaude本地部署CLI工具多模型集成图像生成

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

11

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotokenlocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP