swatplus-mcp
Tamandua
すでに使っているコーディングアシスタント — Claude Code、Copilot、Codex、ローカルモデル — を、SWAT+ 上でより安く、より正確にします。
それはアシスタントではありません。SWAT+ の Fortran ソースを静的解析のみから ファクトのみのインデックス を構築し、それを MCP ツール として、またチェックアウト内のファイルとして提供します。位置情報付きのプロシージャ、コールグラフ、ユニット番号付きのファイル I/O、フィールドパスによる変数の書き込み、インデックス変数付きのループヘッダ、ソースがインラインで文書化している単位と意味を備えた派生型。その中にモデルが書いたものは何もありません。
なぜやるのか:hru_control のループを列挙するよう頼まれたとき、生のソースを扱うアシスタントは 890 行すべてを読み、21 個中 18 個のきれいな表を作りました。その回答には、不完全であることを示すものは何もありませんでした。網羅を求める質問には、ここでは構造上、網羅的な答えが返ります。すべての行にはファイルと行番号が付いています。
現状:
docs/status.md← ここから始めてください決定事項:
docs/decisions.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 データセットに何が含まれているか。この2つは重複しません — こちらは 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.jsonv*.*.* のタグを付けると .github/workflows/release.yml が実行され、固定されたコミットに対して両方をビルドし、チェックアウトを削除し、スナップショットが依然として回答を返すことを検証して、公開します。
原則
ファクトのみ — モデルが書いたものはインデックスに入りません。すべての主張には、そのファイルと行番号が付いています。結論を出す前に測定してください。調査結果は、それを生成したスクリプトとともに docs/*_experiment.md にあります。この作業で見つかった8 つの欠陥は、すべて通常の使用によるもので、ハーネスによるものはゼロでした。したがって、推論するよりも実際に実行することを優先してください。
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.112 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