> ## Documentation Index
> Fetch the complete documentation index at: https://coding-1afcb9be.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 工具参考

> 按类别列出 MCP 工具、输入行为和边界。

# 工具参考

本页列出 `coding_tools_mcp.server` 当前实现的工具。实际可见工具由 `--tool-profile` 决定。

## Profiles

| Profile               | 暴露工具                             |
| --------------------- | -------------------------------- |
| `full`                | 暴露全部实现工具。                        |
| `read-only`           | 只暴露检查类工具，隐藏补丁、命令、cwd 修改和权限请求等工具。 |
| `compat-readonly-all` | 兼容模式：把暴露工具注解为只读，但部分工具仍可能改变本地状态。  |

## 服务和工作区工具

| 工具                       | 用途                             | 关键输入   |
| ------------------------ | ------------------------------ | ------ |
| `server_info`            | 返回服务元数据、协议信息、当前 profile 和能力信息。 | 无      |
| `check_exec_environment` | 报告命令执行环境和隔离状态。                 | 无      |
| `get_default_cwd`        | 返回运行时默认工作目录。                   | 无      |
| `set_default_cwd`        | 修改后续相对命令操作使用的默认工作目录。           | `path` |

`set_default_cwd` 不会在 `read-only` profile 中暴露。

## 文件和搜索工具

| 工具            | 用途                 | 关键输入                                                                                                  |
| ------------- | ------------------ | ----------------------------------------------------------------------------------------------------- |
| `read_file`   | 从工作区文件读取 UTF-8 文本。 | `path`、`start_line`、`end_line`、`max_bytes`、`encoding`                                                 |
| `list_dir`    | 列出目录项，可递归。         | `path`、`recursive`、`max_depth`、`max_entries`、`include_hidden`、`include_ignored`、`sort`                |
| `list_files`  | 按 glob 风格模式查找文件。   | `path`、`patterns`、`glob`、`exclude_patterns`、`include_hidden`、`include_ignored`、`max_results`、`sort`   |
| `search_text` | 用字面量或正则搜索文本。       | `query`、`path`、`regex`、`case_sensitive`、`include_globs`、`exclude_globs`、`context_lines`、`max_results` |

注意：

* `read_file` 只支持 `utf-8`，会拒绝看起来像二进制的文件。
* `read_file.max_bytes` 上限为 1 MiB。
* `search_text` 优先使用 `rg`，不可用时回退到 Python 扫描。
* 默认忽略 `.git`、`node_modules`、构建产物、虚拟环境和常见缓存目录。

## 编辑工具

| 工具            | 用途                     | 关键输入              |
| ------------- | ---------------------- | ----------------- |
| `apply_patch` | 在工作区内应用 unified patch。 | `patch`、`dry_run` |

`apply_patch` 在 `read-only` 中隐藏。可以先用 `dry_run` 验证补丁。

## 命令工具

| 工具             | 用途                         | 关键输入                                                                                |
| -------------- | -------------------------- | ----------------------------------------------------------------------------------- |
| `exec_command` | 在工作区中启动或运行命令。              | `cmd`、`workdir`、`timeout_ms`、`yield_time_ms`、`max_output_bytes`、`stdin`、`tty`、`env` |
| `write_stdin`  | 向运行中的命令 session 写入输入或轮询输出。 | `session_id`、`chars`、`yield_time_ms`、`max_output_bytes`                             |
| `kill_session` | 终止运行中的命令 session。          | `session_id`、`signal`、`wait_ms`、`max_output_bytes`                                  |

命令行为受权限模式影响。`safe` 会阻止网络特征命令、shell 展开、内联脚本、敏感环境和宽泛临时目录写入。`trusted` 允许常见本地开发流程，同时保留敏感环境过滤和可用时的 Landlock。`dangerous` 会关闭命令权限门禁。

## Git 工具

| 工具           | 用途                         | 关键输入                                                            |
| ------------ | -------------------------- | --------------------------------------------------------------- |
| `git_status` | 返回仓库状态。                    | `path`、`include_untracked`、`max_entries`                        |
| `git_diff`   | 返回 staged 或 unstaged diff。 | `path`、`paths`、`staged`、`unstaged`、`context_lines`、`max_bytes`  |
| `git_log`    | 返回最近提交。                    | `path`、`ref`、`max_count`、`skip`                                 |
| `git_show`   | 查看某个 revision，可包含 diff。    | `rev`、`path`、`paths`、`include_diff`、`context_lines`、`max_bytes` |
| `git_blame`  | 返回指定行范围的 blame 信息。         | `path`、`rev`、`start_line`、`end_line`、`max_lines`                |

这些是 Git 查看工具，不会 commit、checkout、reset、push 或修改仓库状态。

## 权限工具

| 工具                    | 用途         | 关键输入                                                                |
| --------------------- | ---------- | ------------------------------------------------------------------- |
| `request_permissions` | 为受限操作请求权限。 | `tool_name`、`permission`、`reason`、`arguments`、`scope`、`ttl_seconds` |

`tool_name` 可取 `exec_command` 和 `apply_patch`。权限名包括 `network`、`destructive_command`、`long_timeout`、`sensitive_env`、`shell_expansion`、`inline_script`、`privileged_executable` 和 `write_generated_or_ignored`。

## 图片工具

| 工具           | 用途                                       | 关键输入                                                               |
| ------------ | ---------------------------------------- | ------------------------------------------------------------------ |
| `view_image` | 读取本地图片，并返回 MCP image payload 或 data URL。 | `path`、`max_bytes`、`max_width`、`max_height`、`auto_resize`、`output` |

`view_image` 默认启用，除非设置 `CODING_TOOLS_MCP_ENABLE_VIEW_IMAGE=0` 或外层包装禁用该能力。输入文件必须位于工作区路径边界内。
