From 86d1ad49b9c2de58e4e53ead894835e6eada60bc Mon Sep 17 00:00:00 2001 From: xhnoob <274180263@qq.com> Date: Fri, 13 Mar 2026 12:14:42 +0800 Subject: [PATCH 1/2] feat: Add Trae MCP Server integration - Add mcp_server.py for Trae IDE MCP protocol support - Add .trae-plugin configuration files - Enable CLI-Anything to work with Trae IDE --- .../.trae-plugin/mcp-config.json | 10 ++ cli-anything-plugin/.trae-plugin/plugin.json | 34 ++++ cli-anything-plugin/mcp_server.py | 147 ++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 cli-anything-plugin/.trae-plugin/mcp-config.json create mode 100644 cli-anything-plugin/.trae-plugin/plugin.json create mode 100644 cli-anything-plugin/mcp_server.py diff --git a/cli-anything-plugin/.trae-plugin/mcp-config.json b/cli-anything-plugin/.trae-plugin/mcp-config.json new file mode 100644 index 0000000..63c2180 --- /dev/null +++ b/cli-anything-plugin/.trae-plugin/mcp-config.json @@ -0,0 +1,10 @@ +{ + "mcpServers": { + "cli-anything": { + "command": "python", + "args": [ + "D:\\AwesomeGithub\\CLI-Anything\\cli-anything-plugin\\mcp_server.py" + ] + } + } +} diff --git a/cli-anything-plugin/.trae-plugin/plugin.json b/cli-anything-plugin/.trae-plugin/plugin.json new file mode 100644 index 0000000..530ec9c --- /dev/null +++ b/cli-anything-plugin/.trae-plugin/plugin.json @@ -0,0 +1,34 @@ +{ + "name": "cli-anything", + "description": "Build powerful, stateful CLI interfaces for any GUI application using the cli-anything harness methodology.", + "author": { + "name": "cli-anything contributors" + }, + "commands": [ + { + "name": "cli-anything", + "description": "Build a complete, stateful CLI harness for any GUI application", + "trigger": "/cli-anything" + }, + { + "name": "cli-anything-refine", + "description": "Refine an existing CLI harness to improve coverage", + "trigger": "/cli-anything:refine" + }, + { + "name": "cli-anything-test", + "description": "Run tests for a CLI harness", + "trigger": "/cli-anything:test" + }, + { + "name": "cli-anything-validate", + "description": "Validate a CLI harness against HARNESS.md standards", + "trigger": "/cli-anything:validate" + }, + { + "name": "cli-anything-list", + "description": "List all available CLI-Anything tools", + "trigger": "/cli-anything:list" + } + ] +} diff --git a/cli-anything-plugin/mcp_server.py b/cli-anything-plugin/mcp_server.py new file mode 100644 index 0000000..7d7c42a --- /dev/null +++ b/cli-anything-plugin/mcp_server.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python3 +""" +CLI-Anything MCP Server for Trae IDE +Using FastMCP framework for simpler setup +""" + +from mcp.server.fastmcp import FastMCP +from pathlib import Path + +PLUGIN_DIR = Path(__file__).parent +COMMANDS_DIR = PLUGIN_DIR / "commands" +HARNESS_PATH = PLUGIN_DIR / "HARNESS.md" + +mcp = FastMCP("CLI-Anything") + + +def load_command_md(command_name: str) -> str: + """Load command definition from markdown file""" + cmd_file = COMMANDS_DIR / f"{command_name}.md" + if cmd_file.exists(): + return cmd_file.read_text(encoding="utf-8") + return "" + + +@mcp.tool() +def cli_anything(software_path: str) -> str: + """Build a complete, stateful CLI harness for any GUI application""" + cmd_doc = load_command_md("cli-anything") + return f"""# CLI-Anything Build Command + +## Instructions +{cmd_doc} + +## Usage +To build a CLI harness, provide the software path or GitHub URL: + +- Local path: `{software_path}` +- GitHub URL: `https://github.com/user/repo` + +The agent will follow the HARNESS.md methodology to: +1. Analyze the codebase +2. Design CLI architecture +3. Implement the CLI +4. Create tests +5. Document everything +""" + + +@mcp.tool() +def cli_anything_refine(software_path: str, focus: str = "All capabilities") -> str: + """Refine an existing CLI harness to improve coverage""" + cmd_doc = load_command_md("refine") + return f"""# CLI-Anything Refine Command + +## Instructions +{cmd_doc} + +## Usage +To refine an existing CLI harness: + +- Base path: `{software_path}` +- Focus area: {focus} + +The agent will analyze gaps and expand coverage. +""" + + +@mcp.tool() +def cli_anything_test(software_path: str) -> str: + """Run tests for a CLI harness""" + cmd_doc = load_command_md("test") + return f"""# CLI-Anything Test Command + +## Instructions +{cmd_doc} + +## Usage +Software path: {software_path} +""" + + +@mcp.tool() +def cli_anything_validate(software_path: str) -> str: + """Validate a CLI harness against HARNESS.md standards""" + cmd_doc = load_command_md("validate") + return f"""# CLI-Anything Validate Command + +## Instructions +{cmd_doc} + +## Usage +Software path: {software_path} +""" + + +@mcp.tool() +def cli_anything_list(path: str = ".", depth: int = 0, json_output: bool = False) -> str: + """List all available CLI-Anything tools""" + import os + import json + + tools = [] + search_dir = Path(path) + + def scan_dir(p, current_depth): + if depth > 0 and current_depth > depth: + return + if not p.exists(): + return + for item in p.iterdir(): + if item.is_dir(): + cli_file = item / "agent-harness" / "cli_anything" + if cli_file.exists(): + tools.append({ + "name": item.name, + "path": str(item), + "status": "generated" + }) + scan_dir(item, current_depth + 1) + + scan_dir(search_dir, 0) + + if json_output: + return json.dumps(tools, indent=2) + + return f"Found {len(tools)} CLI tools:\n\n" + "\n".join(f"- {t['name']}: {t['path']} ({t['status']})" for t in tools) + + +@mcp.tool() +def get_harness_doc() -> str: + """Get the HARNESS.md documentation for cli-anything methodology""" + if HARNESS_PATH.exists(): + return HARNESS_PATH.read_text(encoding="utf-8") + return "HARNESS.md not found" + + +@mcp.tool() +def get_command_doc(command_name: str) -> str: + """Get documentation for a specific cli-anything command""" + content = load_command_md(command_name) + if not content: + content = load_command_md(f"cli-anything-{command_name}") + return content or f"Command {command_name} not found" + + +if __name__ == "__main__": + mcp.run() From 28fc975eedc57ee90d1c89592c96a9ce0f49d032 Mon Sep 17 00:00:00 2001 From: xhnoob <274180263@qq.com> Date: Fri, 13 Mar 2026 13:00:57 +0800 Subject: [PATCH 2/2] docs: Add Trae integration guide (TRAE.md) --- cli-anything-plugin/TRAE.md | 159 ++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 cli-anything-plugin/TRAE.md diff --git a/cli-anything-plugin/TRAE.md b/cli-anything-plugin/TRAE.md new file mode 100644 index 0000000..d5ce2dd --- /dev/null +++ b/cli-anything-plugin/TRAE.md @@ -0,0 +1,159 @@ +# CLI-Anything Trae Integration Guide + +This guide explains how to integrate CLI-Anything plugin with Trae IDE and use it to build CLI tools for applications like Shotcut. + +## Table of Contents + +1. [Background](#background) +2. [Prerequisites](#prerequisites) +3. [Configure MCP Server](#configure-mcp-server) +4. [Use MCP Server](#use-mcp-server) +5. [Install and Use Shotcut CLI](#install-and-use-shotcut-cli) +6. [FAQ](#faq) + +--- + +## Background + +### What is CLI-Anything? + +CLI-Anything is a framework for building CLI interfaces for GUI applications. It converts any GUI application into a CLI tool that AI Agents can use. + +### What is Trae? + +Trae is an AI-native IDE developed by ByteDance, supporting AI capability extension through MCP (Model Context Protocol). + +### Why MCP Server? + +Trae and Claude Code use different plugin systems. Claude Code uses `.claude-plugin` directory, while Trae uses MCP Server mechanism. Therefore, CLI-Anything needs to be wrapped as an MCP Server to work with Trae. + +--- + +## Prerequisites + +### 1. Install Python Dependencies + +```bash +pip install mcp click prompt-toolkit lxml pytest +``` + +### 2. Ensure CLI-Anything Plugin Exists + +CLI-Anything plugin should be located at: +``` +D:\AwesomeGithub\CLI-Anything\cli-anything-plugin\ +``` + +This directory should contain: +- `commands/` - Command definition files +- `HARNESS.md` - Methodology documentation +- `mcp_server.py` - MCP Server implementation +- `.trae-plugin/` - Trae IDE configuration + +--- + +## Configure MCP Server + +### Step 1: Create .trae-plugin Directory + +Create `.trae-plugin` directory under `cli-anything-plugin`: + +```bash +mkdir cli-anything-plugin\.trae-plugin +``` + +### Step 2: Create mcp-config.json + +Create `mcp-config.json` in `.trae-plugin` directory: + +```json +{ + "mcpServers": { + "cli-anything": { + "command": "python", + "args": [ + "D:\\AwesomeGithub\\CLI-Anything\\cli-anything-plugin\\mcp_server.py" + ] + } + } +} +``` + +### Step 3: Create plugin.json + +Create `plugin.json` in `.trae-plugin` directory: + +```json +{ + "name": "cli-anything", + "version": "1.0.0", + "description": "Build CLI harnesses for any GUI application", + "entry": "mcp_server.py" +} +``` + +--- + +## Use MCP Server + +### In Trae IDE: + +1. Open Settings → Plugins +2. Find "MCP Servers" or "Custom Servers" +3. Click "Add Server" +4. Select the `mcp-config.json` file from `cli-anything-plugin\.trae-plugin\` +5. Restart Trae IDE + +After configuration, you can use the `cli_anything` tool in Trae's AI chat to build CLI tools for any application. + +--- + +## Install and Use Shotcut CLI + +### Build CLI for Shotcut + +In Trae IDE, use the following command: + +``` +Use cli_anything to build a CLI tool for Shotcut, path is D:\AwesomeGithub\shotcut +``` + +### Install the Built CLI + +```bash +cd D:\AwesomeGithub\shotcut\agent-harness +pip install -e . +``` + +### Run Tests + +```bash +cd D:\AwesomeGithub\shotcut\agent-harness +python -m pytest cli_anything/shotcut/tests/ -v +``` + +### Use Shotcut CLI + +```bash +shotcut-cli --help +``` + +--- + +## FAQ + +### Q: MCP Server fails to start? + +A: Check Python path in `mcp-config.json` is correct. Ensure all dependencies are installed. + +### Q: Tool not available in Trae? + +A: Restart Trae IDE after configuring MCP Server. Check plugin settings. + +### Q: How to update CLI-Anything? + +A: Pull latest changes from repository and restart Trae IDE. + +--- + +For more information, visit: https://github.com/HKUDS/CLI-Anything