@casualtheorics/argdown-mcp 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -0
  3. package/dist/server.js +241678 -0
  4. package/package.json +60 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Casual Theorics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # @casualtheorics/argdown-mcp
2
+
3
+ An MCP server that exposes [Argdown](https://argdown.org/) parsing, JSON export, and Dung grounded-extension reasoning to language models. Give Claude (or any MCP-capable model) the ability to parse, validate, inspect, and resolve attacks within Argdown documents — including files with `@import` directives. This server does not render HTML, SVG, dot, or PDF; it is strictly a parse/validate/export/extension tool.
4
+
5
+ ## Install
6
+
7
+ **One-shot via npx:**
8
+
9
+ ```bash
10
+ npx -y @casualtheorics/argdown-mcp
11
+ ```
12
+
13
+ **One-shot via Yarn:**
14
+
15
+ ```bash
16
+ yarn dlx @casualtheorics/argdown-mcp
17
+ ```
18
+
19
+ **Claude Code (recommended for persistent access):**
20
+
21
+ ```bash
22
+ claude mcp add --scope user argdown -- npx -y @casualtheorics/argdown-mcp
23
+ ```
24
+
25
+ **Claude Desktop** — add to `claude_desktop_config.json`:
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "argdown": {
31
+ "command": "npx",
32
+ "args": ["-y", "@casualtheorics/argdown-mcp"]
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## What is Argdown?
39
+
40
+ [Argdown](https://argdown.org/) is a plain-text markup language for argument mapping. It lets you write complex argumentation structures — statements, arguments, attacks, supports — in a human-readable format. This server lets a language model parse and inspect those documents without needing the Argdown desktop application or CLI.
41
+
42
+ ## Tools
43
+
44
+ ### `parse`
45
+
46
+ Parses an Argdown document and returns a structural summary plus diagnostics.
47
+
48
+ **Input:**
49
+
50
+ ```json
51
+ { "kind": "inline" | "file", "source": "...", "path": "..." }
52
+ ```
53
+
54
+ - `kind: "inline"` — pass the Argdown markup as `source`.
55
+ - `kind: "file"` — pass the filesystem path as `path`. `@import` directives resolve relative to the importer file, not CWD.
56
+
57
+ **Returns:**
58
+
59
+ - A summary line with statement, argument, and section counts.
60
+ - A diagnostic block listing any lexer/parser errors with `line:col` positions, and any plugin exceptions.
61
+ - A `(not valid Argdown)` hint when the input parses but contains only synthetic (`Untitled N`) statements with no relations, arguments, or sections — the Argdown parser is permissive, so this heuristic catches "definitely not Argdown" inputs.
62
+
63
+ **`isError: true`** when any of the following are true:
64
+
65
+ - Lexer or parser errors are present.
66
+ - A plugin threw an exception.
67
+ - The document parses to only synthetic anonymous statements with no relations, arguments, or sections.
68
+
69
+ ### `export_json`
70
+
71
+ Same as `parse`, but also returns the full `IArgdownResponse.json` payload in a fenced JSON block.
72
+
73
+ **Input:** same shape as `parse`.
74
+
75
+ **Returns:** everything `parse` returns, plus a JSON block containing statements, arguments, relations, and sections as structured data.
76
+
77
+ ### `dung_extensions`
78
+
79
+ Computes the grounded extension under [Dung's abstract argumentation framework](https://plato.stanford.edu/entries/argument/) — i.e., which arguments survive once every attack has been resolved. Uses Caminada's three-valued labelling algorithm.
80
+
81
+ **Input:** same shape as `parse` / `export_json`.
82
+
83
+ **Returns:**
84
+
85
+ - A summary line: `Grounded extension: N IN, M OUT, K UNDEC over A arguments and R attacks.`
86
+ - A fenced JSON block with the full partition:
87
+
88
+ ```json
89
+ {
90
+ "extension": { "in": ["..."], "out": ["..."], "undec": ["..."] },
91
+ "argumentCount": 0,
92
+ "attackCount": 0
93
+ }
94
+ ```
95
+
96
+ **Semantics:**
97
+
98
+ - **IN** — accepted: every attacker of this argument is OUT.
99
+ - **OUT** — defeated: at least one attacker is IN.
100
+ - **UNDEC** — undecided: caught in an unresolved cycle.
101
+
102
+ **Scope:**
103
+
104
+ - Only **argument-to-argument** attack relations are considered (written `<X>\n - <Y>` in Argdown). Statement-level attacks (`[s1]\n - [s2]`) are intentionally ignored — Dung's framework is abstract over arguments; lifting statement attacks belongs to a structured-argumentation layer (ASPIC+, ABA), which is out of scope.
105
+ - Only the **grounded** semantics is computed. Preferred, stable, complete, semi-stable, and ideal semantics are out of scope for v0.2.
106
+ - Undercuts (`relationType: "undercut"`) target inference nodes, not arguments, and are filtered out.
107
+ - A self-attacker with no external defeater is UNDEC; with an IN external defeater, it is OUT.
108
+
109
+ ## Architecture
110
+
111
+ **Plugin set:** The server runs three `@argdown/core` plugins: parse, model, and JSON export. Rendering plugins (html, svg, dot, pdf), selection/color/tag/group plugins, and `argdown.config.json` discovery are all intentionally excluded. The goal is a minimal, deterministic parse surface.
112
+
113
+ **Bundle:** The package ships as a single self-contained `dist/server.js` (~6 MB) with no runtime npm dependencies. It bundles `@argdown/core`, `@argdown/node`, the MCP SDK, and Zod via tsup, using a `createRequire` ESM shim to satisfy `@argdown/node`'s CommonJS expectations.
114
+
115
+ **Input schema:** The wire schema is a flat `{ kind, source?, path? }` object rather than a discriminated union, because the MCP SDK's `normalizeObjectSchema` does not accept `z.discriminatedUnion(...)`. Handler-side enforcement ensures the appropriate field (`source` or `path`) is present for each `kind` value.
116
+
117
+ ## Troubleshooting
118
+
119
+ - **`@import` paths are relative to the importer file, not CWD.** If `main.argdown` imports `imports/sub.argdown`, the path resolves from the directory containing `main.argdown`.
120
+
121
+ - **`@import` cycles** are detected by `@argdown/node`'s IncludePlugin and surfaced in `response.exceptions`. The server will not hang.
122
+
123
+ - **`(not valid Argdown)` hint** appears when the input parses successfully but produces only synthetic `Untitled N` statements with no relations. This is the server's heuristic for catching non-Argdown content passed to `kind: "inline"`.
124
+
125
+ ## Security
126
+
127
+ Path mode (`kind: "file"`) reads any file the server process can read. There is no sandboxing. Do not run this server as root, and treat its filesystem access scope as equivalent to any other tool the model can invoke (e.g., Bash).
128
+
129
+ ## Platform support
130
+
131
+ Linux and macOS only. Windows is not supported (`package.json` sets `"os": ["!win32"]` and will refuse to install).
132
+
133
+ ## Contributing
134
+
135
+ ```bash
136
+ corepack enable # one-time
137
+ git clone <repo>
138
+ yarn install # no-op — zero-installs, PnP cache is committed
139
+ yarn typecheck
140
+ yarn test
141
+ yarn build
142
+ yarn smoke
143
+ ```
144
+
145
+ For editor PnP integration:
146
+
147
+ ```bash
148
+ yarn dlx @yarnpkg/sdks vscode # or: idea, vim, etc.
149
+ ```
150
+
151
+ ## License
152
+
153
+ MIT. See the `LICENSE` file.