swatplus-mcp
Tamandua
让您已经在使用的编码助手 —— Claude Code、Copilot、Codex、本地模型 —— 在 SWAT+ 上更便宜、更准确。
它不是助手。它仅通过静态分析构建 SWAT+ Fortran 源码的纯事实索引,并将其作为 MCP 工具以及您检出目录中的一个文件提供。过程及其位置、调用图、带单元号的文件 I/O、按字段路径的变量写入、带索引变量的循环头、派生类型及其源码内联说明的单位和含义。其中没有任何内容是由模型编写的。
为什么要费这个劲:当被要求列出 hru_control 中的循环时,一个基于原始源码工作的助手读完了全部 890 行,却产出了一份整洁的 18 项表格——而实际有 21 项。答案中没有任何迹象表明它不完整。在这里,穷尽性问题在构造上就是穷尽的,每一行都带有其文件和行号。
现状:
docs/status.md← 从这里开始依赖锁定:
docs/pins.toml
使用
如果你只想要这些工具 —— 无需 SWAT+ 检出或解析器:
pip install "git+https://github.com/tugraskan/Tamandua.git@v0.1.1"带标签的软件包包含固定版本的 SWAT+ 事实快照。未来的 PyPI 发行名称是 swatplus-tamandua(tamandua 已被一个无关项目占用)。将你的助手指向该服务器,无需任何机器特定路径:
// .mcp.json (Claude Code) — VS Code uses .vscode/mcp.json, where these
// entries nest inside a top-level "servers" object instead.
{
"mcpServers": {
"swatplus-source": {
"command": "swatplus-mcp",
"args": ["--compact"]
}
}
}如果你有 SWAT+ 检出和解析器,直接将服务器指向源码:
swatplus-mcp --source /path/to/swatplus --compact运行中的进程会在每次请求前对工作 Fortran 目录树计算指纹。它只会在编辑后重新解析,因此下一条答案会紧跟源码,无需手动重建或重启服务器。
要为他人生成可移植的事实文件:
cd <your swatplus checkout> && swatplus-build这会写入 swatplus-facts.json,仅此而已。以 --facts 启动的服务器会在该文件被替换时察觉,并在不重启的情况下重新加载最新的完整快照。随软件包捆绑的发布快照按设计保持静态。
如果你的工具无法运行 MCP 服务器,swatplus-build --markdown 还会渲染 SWATPLUS_INDEX.md,并让每个助手指令文件(CLAUDE.md、AGENTS.md、.github/copilot-instructions.md)指向它,以便改用 grep 检索。这是后备方案,不是默认方案。
该检查对工作树(而不是最后一次提交)计算哈希——提问所涉及的是正在编辑的代码,而正是在这种时候,基于提交的检查会把过时索引当作最新状态。
Related MCP server: Open Mind
与 dataselector 搭配
swatplus-dataselector 提供另一半:输入文件中某一列的含义,以及真实 TxtInOut 数据集中的内容。两者并不重叠——这个知道 Fortran 做什么,那个知道文件里有什么。同时运行两者,并告诉你的助手哪个对应哪个。
布局
tamandua/
├── index/ # build the facts, render, install pointers, snapshot
│ ├── build.py # static analysis -> SourceIndex
│ ├── snapshot.py # read/write swatplus-facts.json, so serving needs no parser
│ ├── render.py # SOURCE_INDEX.md
│ ├── install.py # assistant instruction-file pointers
│ └── scope.py # loop nesting, for conditional breakpoints
├── mcp/server.py # 14 read-only tools over the same objects
├── mcp/client.py # generic MCP stdio client (talk to another server)
├── output/reader.py # query a run's output files
└── config.py # loads docs/pins.toml开发
export SWATPLUS_SOURCE=/path/to/swatplus
export SWATPLUS_REFERENCE_CORPUS=/path/to/swatplus-reference-corpus # the parser
python -m pip install -e ".[dev]"
pytest # 151 pass, 9 skipped (128/32 without the parser)解析器只是构建时依赖:捆绑的事实文件让已安装的服务器既不需要解析器也不需要 SWAT+ 源码即可运行(参见 D-8)。传入 --facts 以使用另一个快照,或传入 --source 从检出目录实时构建。
# build the publishable artifacts
swatplus-build --facts dist/swatplus-facts.json --out dist/SWATPLUS_INDEX.md
# serve them with nothing else installed
swatplus-mcp --facts dist/swatplus-facts.json打上 v*.*.* 标签会触发运行 .github/workflows/release.yml,该工作流会根据锁定的提交构建两者,删除检出目录,验证快照仍然能够回答,然后发布它。
原则
仅事实——如果是模型编写的,它就不会进入索引。每一条声明都带有其文件和行号。先测量,再下结论;发现记录在 docs/*_experiment.md 中,并附有生成它们的脚本。这项工作中的八个缺陷都是由日常使用发现的,没有一个是由任何测试工具发现的,因此宁可实际运行它,也不要仅靠推理。
Available Tools
15 toolsbreakpointB
Where to stop to watch a variable, and on what condition: the routines that assign it, the loops enclosing each assignment, and their index variables. Relevant scanner warnings are returned separately when present.
Inputs: variable (required).
calleesA
Routines this procedure calls. Exhaustive, not truncated.
Inputs: procedure (required).
callersA
Routines that call this procedure. Exhaustive over the whole tree, never sampled or truncated -- one result means exactly one caller, not a partial list.
Inputs: procedure (required).
call_pathC
How execution reaches a procedure, from an entry point down.
Inputs: procedure (required).
describe_typeB
Every field of a derived type, with units, meaning and declaration -- what a state object like aqu_d actually contains, including whether a component is a scalar or a dimension(:), allocatable array.
Inputs: name (required).
file_ioA
Which routines open/read/write a file, with unit numbers and lines. Resolves output files opened via open_output_file. Exhaustive over the whole tree, not truncated.
Inputs: file (required).
find_procedureA
Locate a SWAT+ procedure: source file, line range, module, module imports and only lists, every argument and local declaration with source line/type/initial/inline units and meaning, and select-case vocabularies. All stored fields are returned, never sampled or truncated. Returns advisory scanner warnings in a second content block when this procedure has any; these are not compiler errors.
Inputs: name (required).
loopsA
Loop headers in a procedure with their index variables and start/end lines, for setting a conditional breakpoint. Exhaustive -- every loop in the procedure, not a sample. Relevant scanner warnings are returned separately when present.
Inputs: procedure (required).
module_variableA
A variable declared in a module body -- its declaring module, type, full declaration (so an allocatable array is distinguishable from a scalar), line, units and meaning. This is the program's global state: a state object like aqu_d is a module-level instance, which describe_type cannot confirm exists. Where a bare name is declared in more than one module, every candidate is returned rather than one being chosen. Falls back to a name and documented-meaning search when there is no exact match. Exhaustive, not truncated.
Inputs: name (required), module.
provenanceA
Which SWAT+ checkout and commit this index describes, its compile-check status, and scanner-warning count.
Inputs: no named parameters.
read_outputA
Summarise a column of a run's output file: count, first, last, min and max with where they occurred, and how many values went negative.
Inputs: file (required), column (required), where, label_by.
scope_atA
Which loops enclose a given line of a procedure, outermost first -- the variables live at that point. Relevant scanner warnings are returned separately when present.
Inputs: line (required), procedure (required).
search_fieldsA
Find a variable from ordinary words. Searches what the source says each field means, e.g. 'recharge' or 'lateral flow', and returns identifiers with units.
Inputs: text (required).
unit_usersA
Routines using a Fortran unit number, and the file each use targets. Optionally filter by operation. Exhaustive, not truncated.
Inputs: unit (required), op.
writersA
Routines that assign a variable, with line numbers and the complete logical assignment statement for derived-type paths when the RHS sidecar is installed. Exhaustive over the whole tree, never sampled or truncated. Relevant scanner warnings are returned separately when present.
Inputs: variable (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Each tool targets a distinct analysis query (type description, module variables, call graph, file I/O, unit numbers, writers, loops, provenance). Minor overlap exists in the loop/scope cluster (breakpoint, scope_at, loops all touch enclosing loops and conditions) and in describe_type vs module_variable, but the descriptions explicitly delineate them.
All names are snake_case, which is consistent casing. Verb styles vary somewhat (verb_noun like describe_type/find_procedure vs bare nouns like callers/writers/loops/provenance), but every name is short, readable and semantically descriptive.
15 tools sit squarely in the well-scoped range for a static-analysis server, and each one covers a distinct query surface (variables, types, control flow, call graph, I/O, provenance) rather than duplicating effort.
The surface covers variable/type introspection, control flow, the call graph in both directions, file/unit I/O, output reading, and provenance -- a strong read-only analysis toolkit. Minor gaps like enumerating all procedures in a module or listing modules could exist, but core navigation workflows are covered.
Maintenance
Related MCP Connectors
Repository knowledge graph MCP server for codebase understanding and debugging.
MCP server for querying Forkast documentation
Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.
The Cortex MCP server provides read-only access to real-time engineering context from the Cortex developer portal, allowing AI coding assistants to answer natural language questions about your organization's catalog (microservices, libraries, domains, teams, infrastructure), scorecards (engineering standards and best practices), initiatives (goals and deadlines), and Engineering Intelligence metrics. It includes tools for querying documentation, tracking personal entities, and accessing AI-assisted insights across the entire Cortex ecosystem.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA local, SQLite-backed code index for Claude Code, exposed over MCP, enabling targeted code retrieval without external APIs.249 PyPI1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that builds a deterministic, source-traceable knowledge index of any codebase, enabling glossary lookup, code graphs, and exact-token search with every fact linked to its source file and line.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients such as Claude Desktop and Claude Code to query an indexed source repository through path-guarded tools for hybrid keyword-and-vector code search, file snippets, symbol explanations, reference lookups, and test-skeleton suggestions. Serves those results over stdio with cited file:line locations so agents can answer questions about a codebase and drive grounded code review.MIT
- AlicenseNot gradedqualityCmaintenanceEnables coding agents to search local repositories and retrieve bounded, cited source chunks, look up full indexed chunks, and inspect index statistics through read-only MCP tools over stdio.MIT