Commit 6124ef0
authored
mcp: add
## What
A bundled `view` module + a global, gorgeous polars HTML render, so
agents stop hand-rolling `Result(user_html=...)` and stop shelling to
`ls`/`grep`/`cat`.
- **`view.ls/tree/grep/find` return plain `polars.DataFrame`s** → they
compose with the full polars API (`.filter()/.sort()/.join()`) *and*
render as a styled table.
- **`view.cat/read/head/tail/json/diff` return a `Code` view**:
pygments-highlighted HTML for the human, raw text as the agent's value
(no token cost for the HTML).
- **`01-ix-polars.py` installs `view.df_html` as the global
`pl.DataFrame._repr_html_`** so every frame (view's, the agent's, the
human's) gets the same dark, dtype-aware table and stays composable. The
agent's text/plain repr is untouched.
- Built on the bundled `fff`/`polars`/`pygments` (pygments newly added).
No bash.
- Advertised in the MCP server instructions so sessions discover it.
## Look
Flat dark Tokyo-night palette: dtype subheaders, zebra rows, orange
right-aligned tabular-num numerics, green strings, purple bools, muted
italic `null`. (Prototyped + screenshotted before building.)
## Validated
✅ `nix build .#mcp` · ✅ `.#mcp.tests.viewSmoke` (helpers + composability
+ df_html + Code views, cross-platform) · ✅ `nix run .#lint`
Empirically checked the high-risk areas: HTML **escaping** (a
`</td><script>` filename renders as `<script>`, XSS-safe), **empty
frames** (grep no-hits → "0 rows", sort guarded), **fff is sync**
(`grep`/`find`; async are `agrep`/`afind`), **no re-entrancy** (df_html
never re-renders; override lives in startup, not import), and a **safe
`df_html` fallback** (render failure → `<pre>`, never breaks display).
_Authored with Claude (Opus 4.8)._view module + sexy global polars HTML render (#777)1 parent edb799c commit 6124ef0
5 files changed
Lines changed: 561 additions & 2 deletions
File tree
- packages/mcp
- ix_notebook_mcp
- ipython
- src/view/view
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
229 | 249 | | |
230 | 250 | | |
231 | 251 | | |
| |||
335 | 355 | | |
336 | 356 | | |
337 | 357 | | |
| 358 | + | |
| 359 | + | |
338 | 360 | | |
339 | 361 | | |
340 | 362 | | |
| |||
362 | 384 | | |
363 | 385 | | |
364 | 386 | | |
| 387 | + | |
365 | 388 | | |
366 | 389 | | |
367 | 390 | | |
| |||
897 | 920 | | |
898 | 921 | | |
899 | 922 | | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
900 | 987 | | |
901 | 988 | | |
902 | 989 | | |
| |||
920 | 1007 | | |
921 | 1008 | | |
922 | 1009 | | |
| 1010 | + | |
923 | 1011 | | |
924 | 1012 | | |
925 | 1013 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
0 commit comments