{"slug": "show-hn-typed-polyglot-compiler-for-cli-api-mcp-generation", "title": "Show HN: Typed polyglot compiler for CLI/API/MCP generation", "summary": "Morloc, a typed polyglot compiler in beta after roughly ten years of development, composes functions across languages under a common type system and generates CLIs, APIs, and MCP tool definitions from those types and declarative docstrings. The compiler runs natively on Linux, macOS ARM chips, and Windows WSL, and its author says the core feature is slowly stabilizing while regular backwards-incompatible changes continue. The project is seeking community contributors to report bugs and write modules.", "body_md": "Morloc composes functions across languages under a common type system and transforms modules into rich CLIs, APIs, and MCPs.\n\nWrite ordinary code in ordinary languages, source it into a Morloc script, and provide a type. These functions are then first class citizens. They can be used freely within a rich functional language. The Morloc compiler generates the CLI, API, MCP model, and usage statements from the types and declarative docstring instructions.\n\nMorloc runs natively on Linux, macOS (new ARM chips), and Windows WSL.\n\nRun this to install the Morloc Installation Manager (`mim`):\n\n```\ncurl -fsSL https://raw.githubusercontent.com/morloc-project/morloc-manager/main/scripts/install.sh | sh\nmim new     # bulid the environment\nmim shell   # drop into a shell\nmim demo    # pull cool morloc demos\n```\n\nThe build is native by default, add the `--engine docker` flag to build in a\ncontainer (or `podman` or `apptainer`). The environment automatically handles\ndependencies for Morloc builds via the Pixi package manager. See the manual\nsection [Getting Started](https://morloc-project.github.io/docs/#_getting_started) for more info.\n\nYou may freeze Morloc environments into Docker images with `mim freeze`.\n\nTwo functions, in two languages, neither aware of the other. A C++ sum:\n\n``` js\n// foo.hpp\n#pragma once\n#include <vector>\n\ndouble sum(const std::vector<double>& vec) {\n    double sum = 0.0;\n    for (double value : vec) {\n        sum += value;\n    }\n    return sum;\n}\n```\n\nand a parallel map in Python:\n\n``` python\n# foo.py\nimport multiprocessing as mp\n\ndef pmap(f, xs):\n    with mp.Pool() as pool:\n        results = pool.map(f, xs)\n    return results\n```\n\nNeither file imports anything from Morloc. The Morloc module gives each a type and composes them:\n\n``` python\n-- sums.loc\nmodule m (sum, sumOfSums)\n\nimport root-py\nimport root-cpp\n\nsource Py from \"foo.py\" (\"pmap\")\nsource Cpp from \"foo.hpp\" (\"sum\")\n\npmap :: (a -> b) -> [a] -> [b]\n\n--' Add up a list of numbers\nsum :: [Real] -> Real\n\n--' Add up a list of lists, summing each in parallel\nsumOfSums :: [[Real]] -> Real\nsumOfSums = sum . pmap sum\n```\n\n`.` is function composition, so `sumOfSums` reads right to left: `pmap sum` sums\neach inner list in parallel, and the outer `sum` adds the results.\n\n``` bash\n$ morloc make sums.loc\n$ ./sums sumOfSums '[[1,2],[3,4,5]]'\n15\n```\n\nA Python function called a C++ function across a process boundary, and you wrote no binding, no serializer, and no argument parser.\n\nBuilding the program creats a CLI tool from the given types and docstrings:\n\n```\n$ ./sums -h\nUsage: ./sums <nexus_options> <command> <command_options>\n\nCommands:\n  sum        Add up a list of numbers\n  sumOfSums  Add up a list of lists, summing each in parallel\n\nGeneral Options:\n  -h, --help  Print help; -hh adds details and examples, -hhh adds schemas\n              (nexus options: -h @)\n```\n\n`./sums sum -h` goes further and prints the argument types the compiler derived.\n\nIt can also serve as an MCP server (`./sums --mcp-tools` emits JSON Schema tool\ndefinitions), an HTTP, TCP, and Unix-socket service, and a module that another\nMorloc module can import and re-export. None of these are separate builds or a\nseparate descriptions, so none of them can drift from the functions: changing\na return type changes all interfaces.\n\nMorloc has been in development for about ten years and is in beta. I use it for my own work and am currently trying to build a community.\n\nThe test suite is massive and growing, but many bugs remain. The core feature is\nslowly stabilizing, but I still make regular backwards incompatible changes. Play\nwith the cutting edge and you might bleed. Track your blood over here:\n[issue tracker](https://github.com/morloc-project/morloc/issues).\n\nThe hard part is finished. The ongoing work is the long tail of bug fixes and ecosystem development. That is where I need people. Here's what I'm looking for:\n\n- **Report what breaks.** Try it out, tell me what breaks\n- **Write a module.** Take something you already maintain, give it types, and\nshare it. I would be happy to collaborate.\n- **Fix the editor tooling.** Add support for your favorite editor.\n- **Bring a language.** Every new language brings fun design questions, I would\nbe happy to work with you in bringing your language into the Morloc ecosystem.\n- **Tell me the right way to build a type system.** There is a lot of theory to\nhash through and I've half-assed more than half of it. If you're a theorist,\nI'd love to hear from you. There's a paper or two buried somewhere in all of\nthis.\n\nIf you are interested in playing with Morloc (or want to drown my in money),\nfeel free to contact me at [z@morloc.io](https://github.com/morloc-project/morloc/blob/master/z@morloc.io).\n\nApache 2.0. See [LICENSE](https://github.com/morloc-project/morloc/blob/master/LICENSE).", "url": "https://wpnews.pro/news/show-hn-typed-polyglot-compiler-for-cli-api-mcp-generation", "canonical_source": "https://github.com/morloc-project/morloc", "published_at": "2026-09-22 21:02:44+00:00", "updated_at": "2026-09-22 21:23:56.688035+00:00", "lang": "en", "topics": ["developer-tools", "agent-protocols", "ai-agents"], "entities": ["Morloc", "Pixi", "Docker", "Podman", "Apptainer", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/show-hn-typed-polyglot-compiler-for-cli-api-mcp-generation", "markdown": "https://wpnews.pro/news/show-hn-typed-polyglot-compiler-for-cli-api-mcp-generation.md", "text": "https://wpnews.pro/news/show-hn-typed-polyglot-compiler-for-cli-api-mcp-generation.txt", "jsonld": "https://wpnews.pro/news/show-hn-typed-polyglot-compiler-for-cli-api-mcp-generation.jsonld"}}