全部產品
Search
文件中心

AgentBay:CodeSpace

更新時間:Dec 24, 2025

開放能力概覽

工具

名稱

描述

支援說明

System

create_sandbox

建立一個新的AgentBay沙箱環境並返回ID。

支援

kill_sandbox

任務完成後釋放資源。

支援

shell

在Linux平台上執行一個shell命令,支援逾時控制,並返回命令輸出或錯誤資訊。

支援

CodeSpace

run_code

在 Linux 平台上運行指定上下文中的代碼並返回輸出或錯誤。

支援

Shell

shell

執行 shell 命令並返回輸出或錯誤。

支援

FileSystem

create_directory

建立一個新目錄或確保目錄存在。可以在一次操作中建立多個嵌套目錄。如果目錄已存在,此操作將靜默成功。非常適合設定專案所需的目錄結構或確保所需路徑存在。僅在允許的目錄中工作。

支援

edit_file

對文字檔進行基於行的編輯。每次編輯會用新內容替換精確的行序列。返回 git 樣式的差異以顯示所做的更改。僅在允許的目錄中工作。

支援

get_file_info

檢索檔案或目錄的詳細中繼資料。返回包括大小、建立時間、最後修改時間、許可權和類型的綜合資訊。此工具非常適合在不讀取實際內容的情況下瞭解檔案特性。僅在允許的目錄中工作。

支援

read_file

從檔案系統讀取檔案的內容。可以指定一個可選的 offset(以位元組為單位)來從特定位置開始讀取,以及一個可選的 length(以位元組為單位)來限制要讀取的位元組數。如果 length 被省略或為 0,檔案將讀取到末尾。處理各種文本編碼,並在檔案無法讀取時提供詳細的錯誤資訊。僅在允許的目錄中工作。

支援

read_multiple_files

同時讀取多個檔案的內容。這比逐個讀取檔案更高效,當你需要分析或比較多個檔案時。每個檔案的內容會以其路徑作為參考返回。單個檔案讀取失敗不會停止整個操作。僅在允許的目錄中工作。

支援

list_directory

擷取指定路徑中所有檔案和目錄的詳細列表。結果通過 [FILE] 和 [DIR] 首碼清楚地區分檔案和目錄。此工具對於瞭解目錄結構和尋找特定檔案非常有用。僅在允許的目錄中工作。

支援

move_file

移動或重新命名檔案和目錄。可以在一次操作中移動檔案到不同目錄並重新命名。如果目標已存在,操作將失敗。可以在不同目錄之間工作,並可用於在同一目錄內進行簡單重新命名。源和目標都必須在允許的目錄中。

支援

search_files

遞迴搜尋匹配模式的檔案和目錄。從起始路徑搜尋所有子目錄。搜尋區分大小寫並匹配部分名稱。返回所有匹配項的完整路徑。非常適合在不知道確切位置時尋找檔案。僅在允許的目錄中搜尋。

支援

write_file

建立一個新檔案或寫入現有檔案的內容。可以選擇完全覆蓋檔案或通過指定 mode 參數追加到檔案末尾。使用 overwrite 模式(預設)在寫入前清除檔案,或使用 append 模式將內容添加到檔案末尾。處理帶適當編碼的常值內容。僅在允許的目錄中工作。

支援

System

提供對沙箱環境的生命週期管理能力。

名稱

描述

參數

create_sandbox

建立一個新的AgentBay沙箱環境並返回ID。

{
  "type": "object",
  "properties": {},
  "required": []
}

kill_sandbox

任務完成後釋放資源。

{
  "type": "object",
  "properties": {
    "sandbox_id": {
      "type": "string",
      "title": "Sandbox Id",
      "description": "The sandbox ID is the identifier for the tool execution environment. This sandbox_id comes from the create_sandbox tool."
    }
  },
  "required": [
    "sandbox_id"
  ]
}

shell

在Linux平台上執行一個shell命令,支援逾時控制,並返回命令輸出或錯誤資訊。

{
  "type": "object",
  "required": [
    "sandbox_id",
    "command",
    "timeout_ms"
  ],
  "properties": {
    "sandbox_id": {
      "type": "string",
      "title": "Sandbox Id",
      "description": "The sandbox ID is the identifier for the tool execution environment. This sandbox_id comes from the create_sandbox tool."
    },
    "cwd": {
      "description": "The working directory for command execution",
      "type": "string"
    },
    "envs": {
      "description": "Environment variables for command execution, e.g. {\"env1\":\"123\",\"env2\":\"abc\"}",
      "type": "object"
    },
    "timeout_ms": {
      "default": 1000,
      "description": "Command execution timeout (unit: milliseconds). If not specified, the default value (such as 1000 milliseconds) is used",
      "type": "integer"
    },
    "command": {
      "description": "client input command",
      "type": "string"
    }
  }
}

CodeSpace

名稱

描述

參數

run_code

在 Linux 平台上運行指定上下文中的代碼並返回輸出或錯誤。

{
  "inputSchema": {
    "properties": {
      "code": {
        "description": "要執行的代碼",
        "type": "string"
      },
      "language": {
        "description": "用於代碼執行的程式設計語言。支援的值:'python', 'javascript'。如果未指定,預設使用 Python。",
        "type": "string"
      },
      "timeout_s": {
        "default": 300,
        "description": "命令執行逾時時間(單位:秒)。如果未指定,預設值(例如 300 秒),最大 3600 秒。",
        "type": "integer"
      }
    },
    "required": ["code"],
    "type": "object"
  }
}

Shell

執行Shell命令(帶逾時控制)。

名稱

描述

參數

shell

執行 shell 命令並返回輸出或錯誤。

{
  "inputSchema": {
    "properties": {
      "command": {
        "description": "用戶端輸入的命令",
        "type": "string"
      },
      "timeout_ms": {
        "default": 1000,
        "description": "命令執行逾時時間(單位:毫秒)。如果未指定,預設值(例如 1000 毫秒)",
        "type": "integer"
      }
    },
    "required": ["command", "timeout_ms"],
    "type": "object"
  }
}

FileSystem

提供檔案系統操作(如上傳、下載和管理)。

名稱

描述

參數

create_directory

建立一個新目錄或確保目錄存在。可以在一次操作中建立多個嵌套目錄。如果目錄已存在,此操作將靜默成功。非常適合設定專案所需的目錄結構或確保所需路徑存在。僅在允許的目錄中工作。

{
  "inputSchema": {
    "properties": {
      "path": {
        "description": "要建立的目錄路徑。",
        "type": "string"
      }
    },
    "required": ["path"],
    "type": "object"
  }
}

edit_file

對文字檔進行基於行的編輯。每次編輯會用新內容替換精確的行序列。返回 git 樣式的差異以顯示所做的更改。僅在允許的目錄中工作。

{
  "inputSchema": {
    "properties": {
      "dryRun": {
        "default": false,
        "description": "使用 git 樣式的差異格式預覽更改",
        "type": "boolean"
      },
      "edits": {
        "items": {
          "properties": {
            "newText": {
              "description": "要替換的新文本",
              "type": "string"
            },
            "oldText": {
              "description": "要搜尋的文本 - 必須完全符合",
              "type": "string"
            }
          },
          "required": ["oldText", "newText"],
          "type": "object"
        },
        "type": "array"
      },
      "path": {
        "description": "要編輯的檔案路徑。",
        "type": "string"
      }
    },
    "required": ["path", "edits"],
    "type": "object"
  }
}

get_file_info

檢索檔案或目錄的詳細中繼資料。返回包括大小、建立時間、最後修改時間、許可權和類型的綜合資訊。此工具非常適合在不讀取實際內容的情況下瞭解檔案特性。僅在允許的目錄中工作。

{
  "inputSchema": {
    "properties": {
      "path": {
        "description": "要檢查的檔案或目錄路徑。",
        "type": "string"
      }
    },
    "required": ["path"],
    "type": "object"
  }
}

read_file

從檔案系統讀取檔案的內容。可以指定一個可選的 offset(以位元組為單位)來從特定位置開始讀取,以及一個可選的 length(以位元組為單位)來限制要讀取的位元組數。如果 length 被省略或為 0,檔案將讀取到末尾。處理各種文本編碼,並在檔案無法讀取時提供詳細的錯誤資訊。僅在允許的目錄中工作。

{
  "inputSchema": {
    "properties": {
      "length": {
        "description": "要讀取的位元組數。如果省略或為 0,讀取到檔案末尾。",
        "minimum": 0,
        "type": "integer"
      },
      "offset": {
        "default": 0,
        "description": "從這個位元組位移量開始讀取。",
        "minimum": 0,
        "type": "integer"
      },
      "path": {
        "description": "要讀取的檔案路徑。",
        "type": "string"
      }
    },
    "required": ["path"],
    "type": "object"
  }
}

read_multiple_files

同時讀取多個檔案的內容。這比逐個讀取檔案更高效,當你需要分析或比較多個檔案時。每個檔案的內容會以其路徑作為參考返回。單個檔案讀取失敗不會停止整個操作。僅在允許的目錄中工作。

{
  "inputSchema": {
    "properties": {
      "paths": {
        "description": "要讀取的檔案路徑數組。",
        "items": {
          "type": "string"
        },
        "type": "array"
      }
    },
    "required": ["paths"],
    "type": "object"
  }
}

list_directory

擷取指定路徑中所有檔案和目錄的詳細列表。結果通過 [FILE] 和 [DIR] 首碼清楚地區分檔案和目錄。此工具對於瞭解目錄結構和尋找特定檔案非常有用。僅在允許的目錄中工作。

{
  "inputSchema": {
    "properties": {
      "path": {
        "description": "要列出的目錄路徑。",
        "type": "string"
      }
    },
    "required": ["path"],
    "type": "object"
  }
}

move_file

移動或重新命名檔案和目錄。可以在一次操作中移動檔案到不同目錄並重新命名。如果目標已存在,操作將失敗。可以在不同目錄之間工作,並可用於在同一目錄內進行簡單重新命名。源和目標都必須在允許的目錄中。

{
  "inputSchema": {
    "properties": {
      "destination": {
        "description": "目標檔案或目錄路徑。",
        "type": "string"
      },
      "source": {
        "description": "源檔案或目錄路徑。",
        "type": "string"
      }
    },
    "required": ["source", "destination"],
    "type": "object"
  }
}

search_files

遞迴搜尋匹配模式的檔案和目錄。從起始路徑搜尋所有子目錄。搜尋區分大小寫並匹配部分名稱。返回所有匹配項的完整路徑。非常適合在不知道確切位置時尋找檔案。僅在允許的目錄中搜尋。

{
  "inputSchema": {
    "properties": {
      "excludePatterns": {
        "default": [],
        "description": "要排除的模式(可選)。",
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "path": {
        "description": "要開始搜尋的目錄路徑。",
        "type": "string"
      },
      "pattern": {
        "description": "要匹配的模式。",
        "type": "string"
      }
    },
    "required": ["path", "pattern"],
    "type": "object"
  }
}

write_file

建立一個新檔案或寫入現有檔案的內容。可以選擇完全覆蓋檔案或通過指定 mode 參數追加到檔案末尾。使用 overwrite 模式(預設)在寫入前清除檔案,或使用 append 模式將內容添加到檔案末尾。處理帶適當編碼的常值內容。僅在允許的目錄中工作。

{
  "inputSchema": {
    "properties": {
      "content": {
        "description": "要寫入的內容。",
        "type": "string"
      },
      "mode": {
        "default": "overwrite",
        "description": "寫入模式:'overwrite' 清除檔案,'append' 添加到檔案末尾。",
        "enum": ["overwrite", "append"],
        "type": "string"
      },
      "path": {
        "description": "要寫入的檔案路徑。",
        "type": "string"
      }
    },
    "required": ["path", "content"],
    "type": "object"
  }
}

MCP Tool List

{"codespace":{"tools":[{"name":"run_code","description":"Runs the code in the specified context with timeout and returns the output or an error on linux platform.","inputSchema":{"properties":{"code":{"description":"Code to execute","type":"string"},"language":{"description":"The programming language to use for code execution. Supported values: 'python', 'javascript'. If not specified, Python will be used by default.","type":"string"},"timeout_s":{"default":300,"description":"Command execution timeout (unit: seconds). If not specified, the default value (such as 300 seconds) is used, Maximum 3600 seconds","type":"integer"}},"required":["code"],"type":"object"}}]},"shell":{"tools":[{"name":"shell","description":"Executes an shell command with timeout and returns the output or an error on linux platform.","inputSchema":{"properties":{"command":{"description":"client input command","type":"string"},"timeout_ms":{"default":1000,"description":"Command execution timeout (unit: milliseconds). If not specified, the default value (such as 1000 milliseconds) is used","type":"integer"}},"required":["command","timeout_ms"],"type":"object"}}]},"filesystem":{"tools":[{"name":"create_directory","description":"Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects or ensuring required paths exist. Only works within allowed directories.","inputSchema":{"properties":{"path":{"description":"Directory path to create.","type":"string"}},"required":["path"],"type":"object"}},{"name":"edit_file","description":"Make line-based edits to a text file. Each edit replaces exact line sequences with new content. Returns a git-style diff showing the changes made. Only works within allowed directories.","inputSchema":{"properties":{"dryRun":{"default":false,"description":"Preview changes using git-style diff format","type":"boolean"},"edits":{"items":{"properties":{"newText":{"description":"Text to replace with","type":"string"},"oldText":{"description":"Text to search for - must match exactly","type":"string"}},"required":["oldText","newText"],"type":"object"},"type":"array"},"path":{"description":"File path to edit.","type":"string"}},"required":["path","edits"],"type":"object"}},{"name":"get_file_info","description":"Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.","inputSchema":{"properties":{"path":{"description":"File or directory path to inspect.","type":"string"}},"required":["path"],"type":"object"}},{"name":"read_file","description":"Read the contents of a file from the file system. You can specify an optional 'offset' (in bytes) to start reading from a specific position, and an optional 'length' (in bytes) to limit how many bytes to read. If 'length' is omitted or 0, the file will be read to the end. Handles various text encodings and provides detailed error messages if the file cannot be read. Only works within allowed directories.","inputSchema":{"properties":{"length":{"description":"Number of bytes to read. If omitted or 0, read to end of file.","minimum":0,"type":"integer"},"offset":{"default":0,"description":"Start reading from this byte offset.","minimum":0,"type":"integer"},"path":{"description":"File path to read.","type":"string"}},"required":["path"],"type":"object"}},{"name":"read_multiple_files","description":"Read the contents of multiple files simultaneously. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Only works within allowed directories.","inputSchema":{"properties":{"paths":{"description":"Array of file paths to read.","items":{"type":"string"},"type":"array"}},"required":["paths"],"type":"object"}},{"name":"list_directory","description":"Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.","inputSchema":{"properties":{"path":{"description":"Directory path to list.","type":"string"}},"required":["path"],"type":"object"}},{"name":"move_file","description":"Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail. Works across different directories and can be used for simple renaming within the same directory. Both source and destination must be within allowed directories.","inputSchema":{"properties":{"destination":{"description":"Destination file or directory path.","type":"string"},"source":{"description":"Source file or directory path.","type":"string"}},"required":["source","destination"],"type":"object"}},{"name":"search_files","description":"Recursively search for files and directories matching a pattern. Searches through all subdirectories from the starting path. The search is case-sensitive and matches partial names. Returns full paths to all matching items. Great for finding files when you don't know their exact location. Only searches within allowed directories.","inputSchema":{"properties":{"excludePatterns":{"default":[],"description":"Patterns to exclude (optional).","items":{"type":"string"},"type":"array"},"path":{"description":"Directory path to start search.","type":"string"},"pattern":{"description":"Pattern to match.","type":"string"}},"required":["path","pattern"],"type":"object"}},{"name":"write_file","description":"Create a new file or write content to an existing file. You can choose to completely overwrite the file or append to the end by specifying the 'mode' parameter. Use 'overwrite' mode (default) to clear the file before writing, or 'append' mode to add content to the end of the file. Handles text content with proper encoding. Only works within allowed directories.","inputSchema":{"properties":{"content":{"description":"Content to write.","type":"string"},"mode":{"default":"overwrite","description":"Write mode: 'overwrite' to clear file, 'append' to add to end.","enum":["overwrite","append"],"type":"string"},"path":{"description":"File path to write.","type":"string"}},"required":["path","content"],"type":"object"}}]},"oss":{"tools":[{"name":"oss_env_init","description":"Create and initialize OSS environment variables with the specified endpoint, access key ID, access key secret, security token, and region. The temporary security credentials obtained from the STS (Security Token Service). For more information, see: https://www.alibabacloud.com/help/zh/oss/developer-reference/use-temporary-access-credentials-provided-by-sts-to-access-oss?spm=a2c4g.11186623.help-menu-search-31815.d_1#9ab17afd7cs4t .","inputSchema":{"properties":{"access_key_id":{"description":"The Access Key ID for OSS authentication","type":"string"},"access_key_secret":{"description":"The Access Key Secret for OSS authentication","type":"string"},"endpoint":{"description":"The OSS service endpoint, e.g.,  If not specified, the default is https://oss-cn-hangzhou.aliyuncs.com","type":"string"},"region":{"description":"The OSS region, e.g., cn-hangzhou. If not specified, the default is cn-hangzhou","type":"string"},"security_token":{"description":"The Security Token for OSS authentication","type":"string"}},"required":["access_key_id","access_key_secret","security_token"],"type":"object"}},{"name":"oss_upload","description":"Upload a local file or directory to the specified OSS bucket. If a directory is specified, it will be compressed into a zip file before uploading. The object name in OSS can be specified; if not, the file or zip name will be used by default. Note: You must call the oss_env_init tool to initialize OSS environment variables before using this tool.","inputSchema":{"properties":{"bucket":{"description":"OSS bucket name","type":"string"},"object":{"description":"Object path in OSS bucket, e.g., test/test.txt","type":"string"},"path":{"description":"Local file or not empty directory full path to upload, e.g., /tmp/test.txt /tmp on Linux or C:/tmp/test.txt C:/tmp on Windows","type":"string"}},"required":["bucket","object","path"],"type":"object"}},{"name":"oss_download","description":"Download an object from the specified OSS bucket to the given local path. If the parent directory does not exist, it will be created automatically. If the target file already exists, it will be overwritten. Note: You must call the oss_env_init tool to initialize OSS environment variables before using this tool.","inputSchema":{"properties":{"bucket":{"description":"OSS bucket name","type":"string"},"object":{"description":"Object path in OSS bucket, e.g., test/test.txt","type":"string"},"path":{"description":"Local full path to save the downloaded file, e.g., /tmp/test.txt on Linux or C:/tmp/test.txt on Windows","type":"string"}},"required":["bucket","object","path"],"type":"object"}},{"name":"oss_upload_annon","description":"Upload a local file or directory to the specified URL using HTTP PUT. If a directory is specified, it will be compressed into a zip file before uploading. If the upload target already exists, it will be overwritten.","inputSchema":{"properties":{"path":{"description":"Local file or not empty directory full path to upload, e.g., /tmp/test.txt /tmp on Linux or C:/tmp/test.txt  C:/tmp on Windows","type":"string"},"url":{"description":"The HTTP/HTTPS URL to upload the file to","type":"string"}},"required":["url","path"],"type":"object"}},{"name":"oss_download_annon","description":"Download a file from the specified URL to the given local path. If the parent directory does not exist, it will be created automatically. If the target file already exists, it will be overwritten.","inputSchema":{"properties":{"path":{"description":"The full local file path to save the downloaded file, e.g., /tmp/test.txt on Linux or C:/tmp/test.txt on Windows","type":"string"},"url":{"description":"The HTTP/HTTPS URL to download the file from","type":"string"}},"required":["url","path"],"type":"object"}}]}}