
agent-tool
io.github.knewstimek由 GitHub 账号 knewstimek 发布v0.4.2更新于 Oct 24, 2026
Encoding-aware, indentation-smart file tools for AI coding agents with SSH, SFTP, and 20+ tools.
概览
本地 MCP 服务器,为编程智能体提供保留编码与缩进的读写编辑工具,以及 shell、SSH/SFTP、HTTP 和进程控制能力。
- 可以做什么
- 读取、写入、编辑、打补丁、比较、复制、重命名和删除文件,并保留原编码、换行符与缩进风格
- 用 grep、glob、listdir、校验和、文件信息与编码转换来搜索和浏览代码
- 在持久 bash 或 PowerShell 会话中执行命令,列出和终止进程,并通过 SSH 执行远程命令
- 通过 SFTP 上传、下载、列目录、改权限和重命名远程文件
- 抓取网址、发送任意 HTTP 请求,并按路径读取 JSON、YAML 或 TOML 配置中的单个值
- 通过 toolbox 网关按需加载其他工具,并切换 schema 配置以节省上下文
- 适用场景
- 适合在真实代码仓库上工作的编程智能体,尤其是文件并非纯 UTF-8 或使用制表符缩进的项目,以及需要同时具备 shell、远程服务器和 HTTP 访问的场景。core-lite 与 core 配置能让工具列表保持精简。
- 运行要求
- 以本地二进制形式运行在用户机器上(仅桌面端),可通过 agent-tool install 命令或手动配置 MCP 客户端安装。可选环境变量 AGENT_TOOL_PROFILE、AGENT_TOOL_FALLBACK_ENCODING 和 AGENT_TOOL_CONNECTION_PROFILE_FILE 用于设置配置档、编码与 SSH 连接配置。SSH/SFTP 需要主机、用户和密钥信息,通常写在本地 connections.json 中。
安装
在 SourceWeft 中
- 打开 控制台中的 agent-tool,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
agent-tool
[agent-tool MCP server]MCP (Model Context Protocol) tool server for AI coding agents.
Why?
Built-in tools in AI coding agents (Claude Code, Cursor, Codex, etc.) have known limitations:
- Tab indentation breaks: LLMs output spaces, but your project uses tabs. The built-in Edit tool writes spaces as-is, corrupting your indentation style.
- Encoding corruption: Editing EUC-KR, Shift-JIS, or GB18030 files silently converts them to UTF-8, breaking legacy projects.
- Too many separate tools: Making the agent find, install, and configure Redis CLI, MySQL client, SSH client, etc. is tedious and error-prone. agent-tool bundles 40 tools into one binary and exposes them on demand through compact profiles.
- No reverse engineering support: Built-in tools can't disassemble binaries, inspect PE/ELF headers, find function boundaries, or search cross-references. agent-tool includes static binary analysis (disassembly, decompilation to C with PDB/DWARF types, xref, function detection), a DAP debugger, and CheatEngine-style memory tools -- giving your agent full reverse engineering capabilities.
- Network censorship: In some countries, government-level web filtering breaks plain
curl/wgetrequests. agent-tool uses ECH (Encrypted Client Hello) and DoH (DNS over HTTPS) by default to work around these restrictions.
agent-tool solves these with agent-oriented tools that preserve project conventions while keeping model context bounded.
Supported Agents
Claude Code, Codex CLI, Cursor, Windsurf, Cline, Gemini CLI, and any MCP-compatible agent.
LLM-efficient by default
The default core profile exposes only 11 schemas (including toolbox) instead of
all 40. In a protocol-level measurement this reduced the serialized tool list from
about 74 KB (full) to 15 KB. For the smallest steady-state context, start with
--profile core-lite; its five schemas are about 6.4 KB and expose only read,
write, edit, grep, and toolbox. Use
toolbox(operation="describe", tool="ssh", compact=true, tool_operation="execute")
to load only one operation's fields and required list, then invoke it through
toolbox(operation="call", tool="ssh", arguments={...}). The gateway does not
depend on dynamic tool-list refresh, so it works with fixed-binding clients such as
Codex. Describe returns a tool/version-bound schema_handle; sending it on a later
describe returns a short unchanged acknowledgement when the schema is still current.
Common compact operations include SSH execution, MySQL queries, file copy, Windows
screenshots/clipboard images, and static-analysis operations. You can also start
with --profile core-lite|coding|remote|analysis|full.
Potentially large text responses default to 32K characters with a 128K hard ceiling.
Truncation is always visible and pageable tools return next_offset or next_cursor.
Local relative paths resolve against an explicit workspace, then the MCP client root.
Features
Persistent analysis annotations
The existing analyze tool can save user comments and labels in SQLite with
annotation_set, search/read them with annotation_list, and remove them with
annotation_delete. Disassembly and decompilation load saved notes automatically.
These are user assessments, visibly separate from automatic symbols and debug types;
labels and subjects do not rename engine symbols or override inferred types.
Call through toolbox (operation="call", tool="analyze", arguments={...}); use
toolbox describe or help topic analyze for the full schema and examples.
annotations_pathmanually selects the SQLite file for saving and loading; relative paths use the workspace/MCP root. The default is<user config dir>/agent-tool/analysis-annotations.sqlite(Windows: under%APPDATA%). Reads do not create databases; the firstannotation_setdoes. This is separate from the rebuildable codegraph DB and disposable analysis cache.- Notes are scoped by the full binary SHA-256 and static address. Identical
copies keep their notes; changed binaries do not inherit them. There is no
automatic migration between builds. Use a static
va(hex or file/debug symbol) or PErva(module-relative offset), not a live ASLR address or file offset. annotation_kindisinstruction(default),function(entry address), ordecompile. Optionalsubjectidentifies a register, operand, or variable at that location.annotation_statusishypothesis(default),confirmed, orrejected; this records the user's assessment.- For a C-line comment, first run
decompilewithline_numbers=true. Pass the returnedcode_hash, the C-bodyline(L number), the function entryva, andannotation_kind="decompile"toannotation_set. Notes render before the corresponding line. A changed C snapshot keeps the note at the function header asneeds_reviewinstead of attaching it to another line. Headers, annotations, and trailing type definitions do not count toward L numbers. - Function notes appear above the C body. Instruction notes appear inline in disassembly. Decompile also gathers instruction notes inside exact PDB/.pdata or sized ELF-symbol ranges, showing each original VA above the C body. Unknown ranges fall back to entry notes with a notice; at most 16 ranges per function are used. These notes are not guessed onto individual C lines.
- Set without an ID creates a new anchor; it rejects an occupied anchor instead
of overwriting another editor's work. Update by
annotation_idrequires the exactexpected_revisionstring from set/list. Omitted fields are preserved; nonempty top-level fields update only those values. Useannotation_patchfor explicit empty strings orline=0; its supplied fields override top-level values. The merged record must still have a label or comment and a valid anchor. Delete requires both ID and expected revision. Stale edits/deletes fail without changing the record; read it again before retrying. Revisions remain strings, including in rendered notes and abbreviated receipts. - List supports address, kind, subject, status, ID and literal
queryfilters (ASCII case folding).max_resultsdefaults to 50 (max 200);result_offsetis a row index andnext_result_offsetcontinues the JSON list. Output limits can shorten a page; raisemax_output_charswhen a single listed note cannot fit. Writes require at least 256 output characters, checked before any change. If full write details cannot fit, success still returns a short JSON receipt withsaved,annotation_id,revision(ordeleted) anddetails_omitted=true. Disassembly/decompile page by character instead. Rendered views cap notes at 500; list retrieves the rest. - Annotation DB load failures produce a visible warning alongside the original
disassembly/decompilation; annotation CRUD still reports DB errors normally.
Legacy v1/v2 DBs remain readable without modification. Their first write
atomically migrates to v3, adding missing revision/evidence/provenance/anchor
fields. Existing revisions are preserved (v1 starts at
"1"). Older builds that only understand v1/v2 cannot open a v3 DB.
Partial edit example (use the ID and revision returned by your last read):
Batch and evidence example:
- A batch contains 1..32
set/deleteitems sharing one binary and DB. It opens and hashes once; each item commits independently and returns an indexed receipt, including conflicts. Successful items remain committed when another fails. Requiredmax_output_charsis at least768 * item_count + 256, checked before any changes. The default budget supports 32 items. A DB-open error fails the envelope; cancellation leaves completed items committed and marks remaining items failed. - Optional
evidencestores up to 16 user-supplied observations withkind(static,runtime,user), optional exact-stringva,source, and requireddetail.provenancerecords the origin of the judgment. Neither sources nor observations are fetched or automatically verified. Both appear in saved/rendered notes and are searchable; sparse edits preserve them.annotation_patchwithevidence:[]orprovenance:""explicitly clears them. - When saving a C-line note, include the exact raw line in
anchor_text.annotation_suggestwith itsannotation_iddecompiles that function and returns the currentcode_hash, revision and up to three candidate lines. Unchanged snapshots use the original line; otherwise stored text or token overlap proposes candidates. Equal top scores are markedambiguous. Generic/missing anchors may produce no candidates. Old notes without text need manual selection after a snapshot change. Suggestions never write the DB. After review, callannotation_setwith ID,expected_revisionandannotation_patch:{"line":N,"code_hash":"<current hash>","anchor_text":"<raw line>"}. The revision guard still applies. Source/detail/provenance limits are 512/1024/512 UTF-8 bytes;anchor_textis one C line, max 2048 bytes.
Keep private annotation databases out of public Git history. This repository ignores
*.annotations.sqlite* and the default DB filename. Custom filenames need their
own ignore rule. Keep a backup of durable notes; clearing analysis caches does not
remove them.
Key Improvements
Smart Indentation
LLMs typically output spaces, but many projects use tabs. AgentTool auto-converts indentation to match the file's existing style.
- Reads
.editorconfigforindent_styleandindent_size - Falls back to content-based detection (first 100 lines)
- Protects legacy files: won't convert if actual content contradicts
.editorconfig
Encoding Preservation
Edits preserve the original file encoding instead of forcing UTF-8.
- Detection priority: BOM →
.editorconfigcharset → BOM-less UTF-16 → valid UTF-8 → chardet auto-detection → fallback encoding - Supported: UTF-8, UTF-8 BOM, EUC-KR, Shift-JIS, ISO-8859-1, UTF-16 (LE/BE, with or without BOM), and more
- No false warnings on ASCII: valid UTF-8 is verified directly, so plain ASCII files never raise a low-confidence warning
- Line endings: Detects LF, CRLF, CR, and mixed files.
editmatches a multi-lineold_stringwhether the file uses CRLF or LF, including files that mix both, and text inserted byedit/regexreplacefollows the newline style of the region it lands in, so the rest of the file is left byte-identical
Token-safe directory listings
listdir defaults to 500 entries per page and returns next_cursor when more
entries are available. Narrow results with directories_only, files_only,
name_pattern (for example A*), or multiple OR patterns in include.
Use counts_only=true when only matching file/directory counts are needed.
Idle memory release
After 30 minutes with no tool call, the server returns its heap to the OS. A stdio MCP server cannot tell an abandoned client from a quiet one -- the process that spawned it may be alive, finished with it, and still holding the pipe open, so no EOF ever arrives -- and exiting on that guess would break a session that merely paused. Releasing the memory is the safe half of that trade: an instance that once read a 50MB file settles back to its ~20MB baseline instead of holding 200MB for the rest of the machine's uptime. Open shell and ssh sessions survive, and nothing the client can observe changes.
Quick Start
- Download the binary for your OS from Releases
- Run
agent-tool install(oragent-tool install claudefor a specific agent) - Restart your IDE / agent
- Done — the compact core tools are available immediately;
toolboxdescribes and calls every other tool on demand
Or just ask your AI agent to do it for you:
"Download agent-tool from https://github.com/knewstimek/agent-tool/releases/latest and run
agent-tool install"
Any capable AI coding agent (Claude Code, Codex, etc.) can handle the full download → install → restart flow automatically.
Recommended: Tell your agent to prefer agent-tool
After installing, agents will have access to agent-tool but may still default to built-in tools (Read, Edit, etc.). To ensure agents prefer agent-tool's encoding-aware, indentation-smart tools, add one of the instructions below.
Code navigation tip: For large projects, add this to your CLAUDE.md / AGENTS.md to enable AST-based code navigation:
Pick Strict or Soft:
Where to put it:
Claude Code — CLAUDE.md (per-project) or global instructions
Per-project — add to your project's CLAUDE.md:
Global (all projects) — add to ~/.claude/CLAUDE.md:
Hard enforcement — deny built-in file tools at the permission level via ~/.claude/settings.json:
This makes Claude Code's built-in file tools unavailable, so the agent is forced to use agent-tool. Recommended when you want strict enforcement without relying on prompt instructions.
Codex CLI — model_instructions.md (global)
- Add to
~/.codex/config.toml(top-level, not inside[mcp_servers.*]):
- Create
~/.codex/model_instructions.md:
- Restart Codex.
Per-project — add to your project's AGENTS.md instead.
Cursor / Windsurf / Cline — .cursorrules or AGENTS.md
Add to your project's .cursorrules, .windsurfrules, or AGENTS.md:
Installation
Auto-install (recommended)
Install permission levels:
Approval level is independent of schema profile: installation may approve the full
namespace while the server still starts with the token-efficient core profile.
toolbox is intentionally not auto-approved by --safe-approve, because its
operation=call gateway can invoke network, shell, database, and process-control
tools. Safe-mode users should review each toolbox approval and avoid granting it a
permanent allow rule unless they intend to trust the full AgentTool namespace.
Manual setup
Claude Code / Cursor / Cline (settings.json or mcp.json):
Codex CLI (~/.codex/config.toml):
Options
Profiles are presets: core-lite (read/write/edit/grep/toolbox), core (11
schemas), coding (core plus broader file/build/shell tools), remote, analysis,
and full. Append +tool names to a preset for a custom initial inventory;
for example, core+copy+delete+ssh+wintool exposes 15 tools while leaving analysis
and other remote tools behind the gateway. The same syntax works in
AGENT_TOOL_PROFILE and toolbox operation=profile. Unknown tools or empty
components reject the whole selection before any tools are registered.
At runtime, prefer the
client-independent toolbox gateway: operation=describe returns one tool's schema
(compact=true plus tool_operation limits it to one operation), and
operation=call invokes it through the stable toolbox binding. Re-send a returned
schema_handle to avoid receiving an unchanged schema again. When command
diagnostics are compacted, operation=output retrieves the bounded raw output by
its reported ID for 30 minutes and reports next_offset when paging is needed. enable,
disable, and profile remain available for clients that honor
tools/list_changed; fixed-binding clients can always keep using the gateway.
Environment Variable
Set AGENT_TOOL_FALLBACK_ENCODING and/or AGENT_TOOL_PROFILE to avoid repeating CLI flags:
Priority: CLI flag > environment variable > default (UTF-8).
Local SSH/SFTP connection profiles
SSH and SFTP accept either connection_profile or a session-local connection_id,
so host, user, key, and jump-host fields do not need to be repeated. Profiles are
read from the OS user config directory at agent-tool/connections.json; override the
location with AGENT_TOOL_CONNECTION_PROFILE_FILE. Keep this file local and explicitly
ignored if it is placed inside a workspace.
An initial call returns an opaque connection_id that remains reusable by both tools
for 30 minutes. Local profiles default to trusted:true; set trusted:false to show the
private-address warning on every call instead of once per pooled connection. This affects
only display; SSRF blocking and cloud metadata protection are unchanged. SSH also supports quiet, echo_command, and
result_only; the last returns compact JSON centered on stdout, stderr, and
exit_code. SFTP supports quiet, result_only, and upload_many (up to 100 files).
For Windows PowerShell, pass script text in powershell_script instead of command.
SSH uploads a unique UTF-8 temporary .ps1 through a short PowerShell command's
standard input, executes its contents with
a short PowerShell launcher, and deletes it after success or failure. Standalone
powershell[.exe] / pwsh[.exe] commands using -EncodedCommand (or -enc, -ec,
-e) are staged automatically at 8,000 UTF-16 code units. Safe profile, interactive,
apartment, and execution-policy options are preserved; unsupported options or shell
suffixes require explicit powershell_script input. Scripts are limited to 4 MiB.
SFTP is not required, including on legacy Windows SSH servers.
Preparation and foreground execution share timeout_sec. Background scripts use
the same upload and cleanup path, then expose job_id for status/tail/cancel.
The remote launcher attempts cleanup in finally; confirmed completion also triggers
bounded SSH cleanup. Cancellation or connection loss does not prove remote termination,
so the tool leaves deletion to the remote launcher and reports cleanup_warning if
completion or cleanup could not be confirmed. This warning is separate from the
script's exit code and captured output.
Local SSH private-key conversion
ssh_key converts a private-key file without sending its contents over the network or
returning key material in the response. Input is auto-detected as PPK, PEM, PKCS#8, or
OpenSSH. The output format is one of ppk, pem, pkcs8, or openssh.
PPK output uses version 3. Passphrase-protected PPK output uses Argon2id,
AES-256-CBC, and HMAC-SHA-256; protected OpenSSH output uses OpenSSH's modern
encrypted format. Traditional PEM and PKCS#8 output are deliberately unencrypted;
use openssh or ppk when output encryption is required. New files are mode 0600,
and existing files are not replaced unless overwrite=true.
Runtime Configuration
Agents can change settings at runtime via set_config without restarting:
Build
Cross-compile:
Release
The guarded GitHub workflow runs tests, builds all declared assets, creates the MCPB and checksums,
and verifies uploaded bytes. From a clean, pushed master branch, dispatch a build-only dry run:
After the dry run succeeds, publish the version declared in main.go:
The workflow requires tracked notes at docs/releases/vVERSION.md. Publication creates an
annotated tag and GitHub Release, then updates server.json with the released MCPB hash.
When RepoPlane uses this repository as its workspace, the same dry-run, publish, and status
operations are discoverable through the repository-local catalog/ manifests.
Troubleshooting
Garbled text (encoding issues)
If Korean, Japanese, or other non-ASCII text appears as garbage characters:
Option 1: Add charset to your .editorconfig:
Option 2: Set environment variable (persistent):
Option 3: CLI flag (per-session):
Built-in help for agents
agent-tool includes a agent_tool_help tool that agents can call for usage guidance. When an agent encounters encoding warnings or garbled text, it can call:
Available topics: overview, encoding, indentation, tools, troubleshooting
Security
agent-tool provides powerful system access (SSH, MySQL, Redis, file operations, HTTP requests). When used with AI coding agents, be aware of prompt injection risks:
- SSRF Protection: Cloud metadata IPs (169.254.x.x, fe80::/10) are always blocked regardless of settings. Private IP access is configurable per protocol via
set_config(allow_http_private,allow_mysql_private,allow_redis_private,allow_ssh_private) - DLP (Data Loss Prevention): All outbound HTTP request bodies are scanned for sensitive data patterns (PEM private keys, AWS access keys, GitHub/GitLab tokens, Slack tokens, .env file dumps) and blocked before transmission
- Prompt Injection Warnings: Allowed private IP connections show a compact warning; trusted local SSH/SFTP profiles show it once per pooled connection
- Zip Slip protection: Archive entries with
../path traversal are blocked (both zip and tar) - Zip Bomb protection: Single file limit (1GB), total extraction limit (5GB)
- Symlinks: Skipped by default. Enable via
set_config allow_symlinks=true(tar only; zip symlinks always skipped). Even when enabled, symlinks targeting outside the output directory are blocked - File size limit: Configurable max file size (default 100MB) prevents OOM on large files. Adjustable via
set_config max_file_size_mb=N - Encoding safety: chardet uses 64KB sample (not full file) for memory efficiency
For maximum security, review the AI agent's tool calls before approving, especially for SSH commands, HTTP requests to external URLs, and database queries.
Tech Stack
- Language: Go
- MCP SDK: github.com/modelcontextprotocol/go-sdk
- Encoding: saintfish/chardet + golang.org/x/text
- Distribution: Single binary (cross-compiled)
- Decompiler: Gosleigh with embedded Ghidra x86/x64 language specs
- PDB: gopdb (PDB 7.0 reader and MSVC demangler)
License
The decompiler (Gosleigh) and the Ghidra language specs it embeds are licensed under the Apache License 2.0; Gosleigh is a reimplementation of the Ghidra decompiler, developed by the National Security Agency (https://github.com/NationalSecurityAgency/ghidra).
来源:README.md,提交 b495c0d
工具
0版本历史
1- v0.4.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分