Terse
An MCP server exposing Terse language tooling for AI agents.
Evaluate Terse source with a configurable gas limit, returning a JSON-safe result and captured print output.
Transpile Terse source into readable, executable Python.
Count Terse source tokens with
tiktokencl100k_base, falling back to a character-based estimate.Parse Terse source and return the AST as JSON.
Define, list, and clear session
$aliases, which expand before evaluation or parsing.
Provides Stripe usage reporting integration: verifies HMAC-signed metered execution receipts, aggregates tokens-saved per customer per month, and reports usage to Stripe billing meter events.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Terse
An AI-native code language: a machine-designed prefix HIR for AI coding agents.
AI agents write human-designed languages — verbose, infix, and syntax-error-prone. Terse is a canonical prefix intermediate representation designed for machines: fixed-arity ops, one spelling per construct, structured errors built for repair loops, and a surface syntax measured to be token-cheaper than Python.
Why
Every mainstream language was designed for human eyes: infix operators with precedence tables, multiple spellings for the same construct (if vs ternary vs statement), significant whitespace, and error messages written for people. When an AI coding agent emits code, each of those is a failure mode — a misplaced paren or a precedence guess costs a repair iteration.
Terse removes the decisions a model shouldn't have to make:
Prefix, always.
(add a (mul b c))— the op comes first, so the structure of every form is known after one token. No precedence tables, no associativity, exactly one way to parenthesize anything.Canonical. One spelling per construct, enforced by the parser.
ifis always prefix;true/false/nullare always lowercase; bare symbols are always variable references. Canonicality shrinks the output distribution a model must learn and makes diffs, caches, and dedup exact.Dense. The v0.2 syntax was shaped by
cl100k_basemeasurements: juxtaposed parens, head-position calls, n-aryif, and fusion ops for hot patterns. Reference solutions measure 0.60–1.00× Python tokens across 8 bench tasks (seebench/).Fixed arities, checked at parse time.
(add 1)fails withE103 arity-mismatchbefore anything runs.Structured errors for repair loops. Every failure is a
TerseErrorwith a stable code (E100–E300), phase, op, source position,expected/got, and a concretehint. Feederr.to_dict()back to the model and the fix is usually one shot.Constrained-decoding grammar.
terse/grammar.gbnfis a GBNF grammar for the full language — under constrained decoding, syntax errors become impossible, and the only remaining failures are semantic ones the error protocol already covers.
Related MCP server: @hyperscript-tools/mcp-server
Quickstart
import terse
# Parse: surface syntax -> AST tuples
ast = terse.parse("(let x 40 (add x 2))") # ("let", "x", 40, ("add", ("var", "x"), 2))
# Run: (value, printed_output)
value, output = terse.run(ast) # (42, "")
# Transpile: AST -> readable Python, verified by exec
src = terse.to_python(ast)
ns = {}
exec(compile(src, "<terse>", "exec"), ns)
ns["_terse_result"] # 42CLI:
python -m terse run examples/fib.terse # run; prints program output, "=> <value>" to stderr
python -m terse run prog.terse --gas 1000000 # with a custom gas budget
python -m terse transpile prog.terse # print the generated Python
python -m terse check prog.terse # parse only; prints OK or error JSON (exit 0/1)Errors are machine-readable JSON on stderr:
$ python -m terse check broken.terse
{"code": "E103", "phase": "parse", "op": "add", "pos": {"line": 1, "col": 1, "index": 1}, ...}A taste of the language:
; recursive fibonacci via def
(def fib(n)(if(lt n 2)n(add(fib(dec n))(fib(dec(dec n))))))
(print(fib 10)) ; => 55
; fizzbuzz: n-ary if, divisibility op, juxtaposed parens
(for i(range 1 21)(print(if(divis i 15)"fizzbuzz"(divis i 3)"fizz"(divis i 5)"buzz"i)))
; wordcount: fold + inc, no pre-seeding needed
(print(fold(acc w)(dict)(list "a" "b" "a")(inc acc w))) ; => {'a': 2, 'b': 1}Repo layout
terse/ the language package (pure Python 3.10+, stdlib only)
parser.py .terse surface syntax -> AST (tokenizer + recursive descent)
errors.py TerseError hierarchy + the E100–E300 code registry
interp.py tree-walking interpreter: run/run_source, gas sandbox
to_python.py AST -> readable Python transpiler (emits _terse_result)
grammar.gbnf GBNF grammar for constrained decoding
__main__.py CLI: run / transpile / check
SPEC.md the language specification (syntax, ops, semantics, errors)
examples/ 8 sample programs + expected.json (exact expected stdout)
bench/ TTCP benchmark: `python -m bench.run` (8 tasks, token ratios)
tests/ pytest suite (220 tests)
mcp/ MCP server: eval/transpile/tokens/parse as agent tools (stdio)
api/ metered execution API: POST /meter -> HMAC-signed receipts (see notes/metered-api.md)
billing/ Stripe usage reporting: verify receipts, aggregate tokens-saved
per customer per month, report to billing meter events
(see billing/README.md for the honest status)
LICENSE Apache-2.0Key semantics: div is true division; and/or are n-ary and short-circuit; let is letrec for closures and def defines named (recursive) functions; put/push/inc are functional; print returns null; evaluation is gas-metered (E205 on exhaustion). See SPEC.md for the full contract.
Status
v0.3 — 160 tests green. New: fmt string interpolation ((fmt "hi {}" name) — ties Python f-strings, beats cat on sentences; see notes/density-v0.3.md for the measured decision rule). Rejected after measurement: -> threading macro (13 tokens vs 9 nested — BPE doesn't fuse (->). v0.2 density ratios hold: 0.60–1.00× Python tokens across the 8-task benchmark, all stdout MATCH. MCP server (mcp/) exposes eval/transpile/token-count/parse as agent tools over stdio.
Roadmap
TTCP leaderboard — live in
leaderboard/(methodology, scoring tool, static page): models compete on token-efficiency vs Python across the 8 fixed bench tasks, stdout-verified. First-try validity with live repair loops is the defined-but-unmeasured second metric.Paired training corpora: Terse↔Python parallel programs for fine-tuning.
Fine-tuning open models on Terse for direct generation.
More backends: additional transpile targets beyond Python.
License
Apache-2.0 — see LICENSE.
Available Tools
7 toolsterse_alias_clearB
Clear all session $aliases.
Inputs: no named parameters.
terse_alias_defineA
Define a session macro: $alias expands to the given Terse form everywhere it appears as a variable afterwards. Define a repeated subtree once, then write $alias (1-2 tokens) instead of the full form. $names are reserved for aliases — do not bind them with let/def/fn.
Inputs: alias (required), expansion (required).
terse_alias_listA
List the session's defined $aliases and their expansions.
Inputs: no named parameters.
terse_evalA
Evaluate Terse source with the tree-walking interpreter. Returns the result value (JSON-safe) and captured print output lines. Session $aliases (see terse_alias_define) are expanded before evaluation.
Inputs: source (required), gas.
terse_parseA
Parse Terse source and return the AST as JSON (tuples become lists). Session $aliases are expanded first.
Inputs: source (required).
terse_tokensA
Count tokens of Terse source with tiktoken cl100k_base; falls back to a ceil(len/4) character estimate when tiktoken is unavailable.
Inputs: source (required).
terse_transpileC
Transpile Terse source to readable, executable Python.
Inputs: source (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
TDQS
Scored across 7 tools
Each tool targets a distinct operation: eval (run code), parse (produce AST), transpile (emit Python), tokens (count), and three clearly-scoped alias operations. There is no meaningful overlap—parse vs eval vs transpile are different outputs despite all consuming Terse source. An agent can pick the right tool unambiguously.
Every tool carries the terse_ prefix, which gives strong family cohesion. The alias group (terse_alias_list/define/clear) uses a group_verb form while the core operations (terse_eval/parse/transpile/tokens) use prefix_verb, a minor deviation but still readable and predictable.
Seven tools is well within the ideal range and each earns its place: four core language operations plus three alias lifecycle tools. Nothing feels padded or missing at the count level.
The language-tooling domain is well covered: eval, parse, transpile, token counting, plus alias define/list/clear. The one gap is granular alias management—there is no way to remove or inspect a single alias, only clear-all—but this is a minor workaroundable omission.
Maintenance
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
An MCP server that provides agents access to the KeldynAI platform
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Related MCP Servers
- AlicenseAqualityBmaintenanceToken-efficient Python stdio MCP server exposing safe text-file search, reading, and refactoring tools.161Apache 2.0
- AlicenseNot gradedqualityBmaintenanceMCP server providing parser-backed validation, parsing, documentation, and editor assistance for AI agents working with _hyperscript.MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for deterministic, zero-dependency context-window math, enabling token estimation, text truncation, and budget reporting without a tokenizer.MIT
- AlicenseNot gradedqualityDmaintenanceZero-dependency stdio MCP server for token-aware prompt version diffs. Compare prompts or files and get machine-readable token delta reports with confidence labels.MIT