shrink-mcp 0.4.2__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 humer90000
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.
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: shrink-mcp
3
+ Version: 0.4.2
4
+ Summary: Fewer tokens for coding agents. Shrink git diffs, test logs, and repo trees. MCP for Cursor, Claude Code, Codex, and VS Code.
5
+ Author: humer90000
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 humer90000
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Requires-Python: >=3.9
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Provides-Extra: tokens
32
+ Requires-Dist: tiktoken; extra == "tokens"
33
+ Dynamic: license-file
34
+
35
+ # shrink-mcp
36
+
37
+ Experimental project. The package name is shrink-mcp. The command is still `shrink`. Fewer tokens for coding agents. Shrinks a git diff, a test log, or a repo tree when the context window is getting fat and the model starts forgetting. The first line is a rough before -> after token count. It is useful, and it is not a finished product.
38
+
39
+ Use it from a terminal, over localhost HTTP, or as an MCP server. Cursor, Claude Code, Codex, VS Code, and Claude Desktop can all call it. Only the config file changes.
40
+
41
+ Python 3.9 or newer. No required packages. MIT license.
42
+
43
+ On this Windows box `python` is the store stub and does nothing. Use `py -3`. If your `python` actually runs, use that instead.
44
+
45
+ ## examples
46
+
47
+ Both were `py -3 shrink.py log build.log` on this machine, no tiktoken. The first line of the answer is the before -> after count.
48
+
49
+ ### Same line, 200 times
50
+
51
+ The file had 201 lines. Line 1 through 200 were identical. Line 201 was the error.
52
+
53
+ ```
54
+ compile ok
55
+ compile ok
56
+ compile ok
57
+ ... 197 more "compile ok" ...
58
+ Error: disk full, cannot write C:/build/out.bin
59
+ ```
60
+
61
+ 415 tokens in. The program printed only this:
62
+
63
+ ```
64
+ rough tokens: 415 -> 18
65
+
66
+ compile ok x200
67
+ Error: disk full, cannot write C:/build/out.bin
68
+ ```
69
+
70
+ `x200` means the line was there 200 times. The error sentence is unchanged.
71
+
72
+ ### 120 different lines, one error in the middle
73
+
74
+ Nothing repeats. `file_001` through `file_120`, and at `file_071` the compiler error:
75
+
76
+ ```
77
+ compiled src/file_001.ts
78
+ compiled src/file_002.ts
79
+ compiled src/file_003.ts
80
+ ... file_004 through file_070, each name different ...
81
+ src/pay.ts(40,12): error TS2304: Cannot find name total
82
+ compiled src/file_072.ts
83
+ ... file_073 through file_120 ...
84
+ ```
85
+
86
+ 732 tokens in, 176 back. `file_001` through `file_068` are gone. The error is still there, with the two lines above it, and the end of the file is still there:
87
+
88
+ ```
89
+ rough tokens: 732 -> 176
90
+
91
+ ... lines hidden: 68
92
+ compiled src/file_069.ts
93
+ compiled src/file_070.ts
94
+ src/pay.ts(40,12): error TS2304: Cannot find name total
95
+ compiled src/file_072.ts
96
+ compiled src/file_073.ts
97
+ compiled src/file_074.ts
98
+ compiled src/file_075.ts
99
+ compiled src/file_076.ts
100
+ compiled src/file_077.ts
101
+ compiled src/file_078.ts
102
+ ... lines hidden: 27
103
+ compiled src/file_106.ts
104
+ compiled src/file_107.ts
105
+ compiled src/file_108.ts
106
+ compiled src/file_109.ts
107
+ compiled src/file_110.ts
108
+ compiled src/file_111.ts
109
+ compiled src/file_112.ts
110
+ compiled src/file_113.ts
111
+ compiled src/file_114.ts
112
+ compiled src/file_115.ts
113
+ compiled src/file_116.ts
114
+ compiled src/file_117.ts
115
+ compiled src/file_118.ts
116
+ compiled src/file_119.ts
117
+ compiled src/file_120.ts
118
+ ```
119
+
120
+ `... lines hidden: 68` is `file_001` to `file_068`. The second hidden block is `file_079` to `file_105`. What a person needs from this log is the `TS2304` line, and it survived.
121
+
122
+ ## install
123
+
124
+ From PyPI:
125
+
126
+ ```
127
+ py -3 -m pip install shrink-mcp
128
+ shrink --version
129
+ ```
130
+
131
+ From a checkout of this repo:
132
+
133
+ ```
134
+ py -3 -m pip install -e .
135
+ ```
136
+
137
+ # was: python setup.py install
138
+ # there is no setup.py anymore
139
+
140
+ Without installing, the same thing is `py -3 shrink.py ...` from this folder.
141
+
142
+ Optional, closer token counts (cl100k, same family most chat APIs use):
143
+
144
+ ```
145
+ py -3 -m pip install "shrink-mcp[tokens]"
146
+ ```
147
+
148
+ Without that extra the count is a split on words and punctuation. It is still a guess, not the invoice.
149
+
150
+ ## use it
151
+
152
+ ```
153
+ shrink diff
154
+ shrink log build.log
155
+ shrink tree
156
+ type build.log | shrink
157
+ ```
158
+
159
+ `shrink log` with no file and no pipe used to wait forever. It now says so. A UTF-16 log from Notepad is read, including when it is posted to `/log`. Repeated lines collapse (`compile ok x200`). When the lines are all different and the file is long, it keeps the error, a few lines around it, and the tail. That is the second example above.
160
+
161
+ A line counts as an error for pytest (`FAIL`, `assert`), npm (`npm ERR!`), Rust (`error[E0308]`, `panicked`), Go (`FAIL`), a Python traceback (the exception at the bottom stays, not just the word Traceback), and a shell crash (`segmentation fault`). A line that only says `0 errors` or `errors: 0` does not.
162
+
163
+ `diff` has to run inside a git repo. Lockfiles, images and binary patches are not expanded, even when the diff is short. A long file keeps the header and the first chunk of changes, then a line saying how many were hidden. A repo that has no commit yet lists the new files instead of dying on `HEAD`. A short normal diff is left alone. Cutting those made small edits worse.
164
+
165
+ `tree` skips `node_modules`, `.git`, `.venv`, `venv`, `dist`, `build`, `target`, `__pycache__`, `.next`, `coverage` and `*.egg-info`. It opens three levels. Anything deeper is one note, `deeper folders not opened`, not a list of names. A directory with a lot of files shows the first dozen and a count of the rest.
166
+
167
+ ```
168
+ shrink serve
169
+ curl.exe -s --data-binary @build.log http://127.0.0.1:8765/log
170
+ ```
171
+
172
+ Listens on 127.0.0.1 only. `GET /health`. `POST /shrink` takes `{"op":"log","text":"..."}` or `diff` / `tree` with `path`. The field `kind` still works. The draft called it that.
173
+
174
+ Other port: `shrink serve 9000`.
175
+
176
+ `shrink watch` rewrites `.shrink/last.txt` every two seconds, for an agent that can read a file and cannot start MCP. Don't commit `.shrink`.
177
+
178
+ ## editor
179
+
180
+ Print the snippet:
181
+
182
+ ```
183
+ shrink setup
184
+ shrink setup vscode
185
+ shrink setup claude
186
+ shrink setup claude-desktop
187
+ shrink setup codex
188
+ ```
189
+
190
+ Merge it in. Other servers in that file stay put. Codex is toml, so `--write` appends a block and will not add a second one:
191
+
192
+ ```
193
+ shrink setup cursor --write
194
+ shrink setup vscode --write
195
+ shrink setup claude --write
196
+ shrink setup claude-desktop --write
197
+ shrink setup codex --write
198
+ ```
199
+
200
+ Where `--write` goes:
201
+
202
+ - cursor: `%USERPROFILE%\.cursor\mcp.json`
203
+ - vscode: `.vscode/mcp.json` in the current folder
204
+ - claude code: `.mcp.json` in the current folder
205
+ - claude desktop: `%APPDATA%\Claude\claude_desktop_config.json`
206
+ - codex: `%USERPROFILE%\.codex\config.toml`
207
+
208
+ Restart the editor after that. It does not always reload a config that is already open.
209
+
210
+ The tools are `shrink_diff`, `shrink_log`, `shrink_tree`. Don't start `shrink mcp` yourself. The editor does.
211
+
212
+ ## what it will not do
213
+
214
+ It does not call a model. It does not apply the diff back. It does not open a port on the network. A log bigger than about 2 MB is cut. The token line is an estimate unless you installed the `tokens` extra.
@@ -0,0 +1,180 @@
1
+ # shrink-mcp
2
+
3
+ Experimental project. The package name is shrink-mcp. The command is still `shrink`. Fewer tokens for coding agents. Shrinks a git diff, a test log, or a repo tree when the context window is getting fat and the model starts forgetting. The first line is a rough before -> after token count. It is useful, and it is not a finished product.
4
+
5
+ Use it from a terminal, over localhost HTTP, or as an MCP server. Cursor, Claude Code, Codex, VS Code, and Claude Desktop can all call it. Only the config file changes.
6
+
7
+ Python 3.9 or newer. No required packages. MIT license.
8
+
9
+ On this Windows box `python` is the store stub and does nothing. Use `py -3`. If your `python` actually runs, use that instead.
10
+
11
+ ## examples
12
+
13
+ Both were `py -3 shrink.py log build.log` on this machine, no tiktoken. The first line of the answer is the before -> after count.
14
+
15
+ ### Same line, 200 times
16
+
17
+ The file had 201 lines. Line 1 through 200 were identical. Line 201 was the error.
18
+
19
+ ```
20
+ compile ok
21
+ compile ok
22
+ compile ok
23
+ ... 197 more "compile ok" ...
24
+ Error: disk full, cannot write C:/build/out.bin
25
+ ```
26
+
27
+ 415 tokens in. The program printed only this:
28
+
29
+ ```
30
+ rough tokens: 415 -> 18
31
+
32
+ compile ok x200
33
+ Error: disk full, cannot write C:/build/out.bin
34
+ ```
35
+
36
+ `x200` means the line was there 200 times. The error sentence is unchanged.
37
+
38
+ ### 120 different lines, one error in the middle
39
+
40
+ Nothing repeats. `file_001` through `file_120`, and at `file_071` the compiler error:
41
+
42
+ ```
43
+ compiled src/file_001.ts
44
+ compiled src/file_002.ts
45
+ compiled src/file_003.ts
46
+ ... file_004 through file_070, each name different ...
47
+ src/pay.ts(40,12): error TS2304: Cannot find name total
48
+ compiled src/file_072.ts
49
+ ... file_073 through file_120 ...
50
+ ```
51
+
52
+ 732 tokens in, 176 back. `file_001` through `file_068` are gone. The error is still there, with the two lines above it, and the end of the file is still there:
53
+
54
+ ```
55
+ rough tokens: 732 -> 176
56
+
57
+ ... lines hidden: 68
58
+ compiled src/file_069.ts
59
+ compiled src/file_070.ts
60
+ src/pay.ts(40,12): error TS2304: Cannot find name total
61
+ compiled src/file_072.ts
62
+ compiled src/file_073.ts
63
+ compiled src/file_074.ts
64
+ compiled src/file_075.ts
65
+ compiled src/file_076.ts
66
+ compiled src/file_077.ts
67
+ compiled src/file_078.ts
68
+ ... lines hidden: 27
69
+ compiled src/file_106.ts
70
+ compiled src/file_107.ts
71
+ compiled src/file_108.ts
72
+ compiled src/file_109.ts
73
+ compiled src/file_110.ts
74
+ compiled src/file_111.ts
75
+ compiled src/file_112.ts
76
+ compiled src/file_113.ts
77
+ compiled src/file_114.ts
78
+ compiled src/file_115.ts
79
+ compiled src/file_116.ts
80
+ compiled src/file_117.ts
81
+ compiled src/file_118.ts
82
+ compiled src/file_119.ts
83
+ compiled src/file_120.ts
84
+ ```
85
+
86
+ `... lines hidden: 68` is `file_001` to `file_068`. The second hidden block is `file_079` to `file_105`. What a person needs from this log is the `TS2304` line, and it survived.
87
+
88
+ ## install
89
+
90
+ From PyPI:
91
+
92
+ ```
93
+ py -3 -m pip install shrink-mcp
94
+ shrink --version
95
+ ```
96
+
97
+ From a checkout of this repo:
98
+
99
+ ```
100
+ py -3 -m pip install -e .
101
+ ```
102
+
103
+ # was: python setup.py install
104
+ # there is no setup.py anymore
105
+
106
+ Without installing, the same thing is `py -3 shrink.py ...` from this folder.
107
+
108
+ Optional, closer token counts (cl100k, same family most chat APIs use):
109
+
110
+ ```
111
+ py -3 -m pip install "shrink-mcp[tokens]"
112
+ ```
113
+
114
+ Without that extra the count is a split on words and punctuation. It is still a guess, not the invoice.
115
+
116
+ ## use it
117
+
118
+ ```
119
+ shrink diff
120
+ shrink log build.log
121
+ shrink tree
122
+ type build.log | shrink
123
+ ```
124
+
125
+ `shrink log` with no file and no pipe used to wait forever. It now says so. A UTF-16 log from Notepad is read, including when it is posted to `/log`. Repeated lines collapse (`compile ok x200`). When the lines are all different and the file is long, it keeps the error, a few lines around it, and the tail. That is the second example above.
126
+
127
+ A line counts as an error for pytest (`FAIL`, `assert`), npm (`npm ERR!`), Rust (`error[E0308]`, `panicked`), Go (`FAIL`), a Python traceback (the exception at the bottom stays, not just the word Traceback), and a shell crash (`segmentation fault`). A line that only says `0 errors` or `errors: 0` does not.
128
+
129
+ `diff` has to run inside a git repo. Lockfiles, images and binary patches are not expanded, even when the diff is short. A long file keeps the header and the first chunk of changes, then a line saying how many were hidden. A repo that has no commit yet lists the new files instead of dying on `HEAD`. A short normal diff is left alone. Cutting those made small edits worse.
130
+
131
+ `tree` skips `node_modules`, `.git`, `.venv`, `venv`, `dist`, `build`, `target`, `__pycache__`, `.next`, `coverage` and `*.egg-info`. It opens three levels. Anything deeper is one note, `deeper folders not opened`, not a list of names. A directory with a lot of files shows the first dozen and a count of the rest.
132
+
133
+ ```
134
+ shrink serve
135
+ curl.exe -s --data-binary @build.log http://127.0.0.1:8765/log
136
+ ```
137
+
138
+ Listens on 127.0.0.1 only. `GET /health`. `POST /shrink` takes `{"op":"log","text":"..."}` or `diff` / `tree` with `path`. The field `kind` still works. The draft called it that.
139
+
140
+ Other port: `shrink serve 9000`.
141
+
142
+ `shrink watch` rewrites `.shrink/last.txt` every two seconds, for an agent that can read a file and cannot start MCP. Don't commit `.shrink`.
143
+
144
+ ## editor
145
+
146
+ Print the snippet:
147
+
148
+ ```
149
+ shrink setup
150
+ shrink setup vscode
151
+ shrink setup claude
152
+ shrink setup claude-desktop
153
+ shrink setup codex
154
+ ```
155
+
156
+ Merge it in. Other servers in that file stay put. Codex is toml, so `--write` appends a block and will not add a second one:
157
+
158
+ ```
159
+ shrink setup cursor --write
160
+ shrink setup vscode --write
161
+ shrink setup claude --write
162
+ shrink setup claude-desktop --write
163
+ shrink setup codex --write
164
+ ```
165
+
166
+ Where `--write` goes:
167
+
168
+ - cursor: `%USERPROFILE%\.cursor\mcp.json`
169
+ - vscode: `.vscode/mcp.json` in the current folder
170
+ - claude code: `.mcp.json` in the current folder
171
+ - claude desktop: `%APPDATA%\Claude\claude_desktop_config.json`
172
+ - codex: `%USERPROFILE%\.codex\config.toml`
173
+
174
+ Restart the editor after that. It does not always reload a config that is already open.
175
+
176
+ The tools are `shrink_diff`, `shrink_log`, `shrink_tree`. Don't start `shrink mcp` yourself. The editor does.
177
+
178
+ ## what it will not do
179
+
180
+ It does not call a model. It does not apply the diff back. It does not open a port on the network. A log bigger than about 2 MB is cut. The token line is an estimate unless you installed the `tokens` extra.
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "shrink-mcp"
7
+ version = "0.4.2"
8
+ description = "Fewer tokens for coding agents. Shrink git diffs, test logs, and repo trees. MCP for Cursor, Claude Code, Codex, and VS Code."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "humer90000" }]
13
+
14
+ [project.optional-dependencies]
15
+ # plain install stays stdlib. this extra makes the token line match cl100k
16
+ tokens = ["tiktoken"]
17
+
18
+ [project.scripts]
19
+ shrink = "shrink:main"
20
+
21
+ [tool.setuptools]
22
+ py-modules = ["shrink"]
23
+ license-files = ["LICENSE"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+