Skip to main content
ClaudeWave

A Lisp with first-class LLM primitives, implemented in Rust

MCP ServersOfficial Registry24 stars1 forksRustMITUpdated today
Install in Claude Code / Claude Desktop
Method: Manual · sema
Claude Code CLI
git clone https://github.com/sema-lisp/sema
claude_desktop_config.json (Claude Desktop)
{
  "mcpServers": {
    "sema": {
      "command": "sema"
    }
  }
}
1. Run the command above in your terminal (Claude Code), or paste the JSON config into claude_desktop_config.json (Claude Desktop).
2. Replace any <placeholder> values with your API keys or paths.
3. Restart Claude. The MCP server and its tools appear automatically.
💡 Install the binary first: cargo install sema (or build from https://github.com/sema-lisp/sema).
Use cases

MCP Servers overview

<p align="center">
  <img src="https://raw.githubusercontent.com/sema-lisp/sema/main/assets/og-github.jpg" alt="Sema — Stop rewriting the agent loop." width="800">
</p>

<p align="center">
  A Lisp where LLM agents are language primitives, not an SDK —<br>
  compiled to a fast bytecode VM, shipped as a single binary.
</p>

<p align="center">
  <a href="https://sema.run"><img src="https://img.shields.io/badge/try_it-sema.run-c8a855?style=flat" alt="Playground"></a>
  <a href="https://sema-lang.com/docs/"><img src="https://img.shields.io/badge/docs-sema--lang.com-c8a855?style=flat" alt="Docs"></a>
  <a href="https://github.com/sema-lisp/sema/releases/latest"><img src="https://img.shields.io/github/v/tag/sema-lisp/sema?label=version&color=c8a855&style=flat" alt="Version"></a>
  <a href="https://codecov.io/gh/sema-lisp/sema"><img src="https://codecov.io/gh/sema-lisp/sema/graph/badge.svg" alt="Coverage"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-c8a855?style=flat" alt="License"></a>
</p>

<p align="center">
  <a href="https://sema-lang.com/docs/"><b>Docs</b></a> ·
  <a href="https://sema.run"><b>Playground</b></a> ·
  <a href="https://sema-lang.com/docs/for-agents"><b>For Agents</b></a> ·
  <a href="https://github.com/sema-lisp/sema/tree/main/examples"><b>Examples</b></a> ·
  <a href="https://github.com/sema-lisp/sema/issues"><b>Issues</b></a>
</p>

**Stop rewriting the agent loop.** Every LLM script grows the same scaffolding — retries, caching, cost caps, rate limits, tool dispatch, conversation state. Sema makes that scaffolding the runtime: your script stays the size of its idea, ships as a single binary, and your coding agent already speaks the language.

Sema is a Scheme-like Lisp where **prompts are s-expressions**, **conversations are persistent data structures**, and **LLM calls are just another form of evaluation** — with Clojure-style keywords (`:foo`), map literals (`{:key val}`), and vector literals (`[1 2 3]`).

## What It Looks Like

A coding agent with file tools, safety checks, and budget tracking — in ~40 lines:

```scheme
;; Define tools the LLM can call
(deftool read-file
  "Read a file's contents"
  {:path {:type :string :description "File path"}}
  (lambda (path)
    (if (file/exists? path) (file/read path) "File not found")))

(deftool edit-file
  "Replace text in a file"
  {:path {:type :string} :old {:type :string} :new {:type :string}}
  (lambda (path old new)
    (file/write path (string/replace (file/read path) old new))
    "Done"))

(deftool run-command
  "Run a shell command"
  {:command {:type :string :description "Shell command to run"}}
  (lambda (command) (:stdout (shell "sh" "-c" command))))

;; Create an agent with tools, system prompt, and spending limit
(defagent coder
  {:system (format "You are a coding assistant. Working directory: ~a" (sys/cwd))
   :tools [read-file edit-file run-command]
   :max-turns 20})   ; no :model → uses the configured default provider

;; Run it — budget is scoped, automatically restored after the block
(llm/with-budget {:max-cost-usd 0.50} (lambda ()
  (define result (agent/run coder "Add error handling to src/main.rs"))
  (println (:response result))
  (println (format "Cost: $~a" (:spent (llm/budget-remaining))))))
```

## Key Features

```scheme
;; Simple completion
(llm/complete "Explain monads in one sentence")

;; Structured data extraction — returns a map, not a string
(llm/extract
  {:vendor {:type :string} :amount {:type :number} :date {:type :string}}
  "Bought coffee for $4.50 at Blue Bottle on Jan 15")
;; => {:amount 4.5 :date "2025-01-15" :vendor "Blue Bottle"}

;; Classification
(llm/classify (list :positive :negative :neutral) "This product is amazing!")
;; => :positive

;; Multi-turn conversations as immutable data
(define conv (conversation/new {:model "claude-haiku-4-5-20251001"}))
(define conv (conversation/say conv "The secret number is 7"))
(define conv (conversation/say conv "What's the secret number?"))
(conversation/last-reply conv) ;; => "The secret number is 7."

;; Streaming
(llm/stream "Tell me a story" {:max-tokens 500})

;; Batch — all prompts sent concurrently
(llm/batch (list "Translate 'hello' to French"
                 "Translate 'hello' to Spanish"
                 "Translate 'hello' to German"))

;; Vision — extract structured data from images
(llm/extract-from-image
  {:text :string :background_color :string}
  "assets/logo.png")
;; => {:background_color "white" :text "Sema"}

;; Multi-modal chat — send images in messages
(define img (file/read-bytes "photo.jpg"))
(llm/chat (list (message/with-image :user "Describe this image." img)))

;; Cost tracking
(llm/set-budget 1.00)
(llm/budget-remaining) ;; => {:limit 1.0 :spent 0.05 :remaining 0.95}

;; Response caching — avoid duplicate API calls during development
(llm/with-cache (lambda ()
  (llm/complete "Explain monads")))

;; Cassettes — record real responses once, replay them in CI (no keys, no network)
(llm/with-cassette "fixtures/run.jsonl" {:mode :auto} (lambda ()
  (llm/complete "Explain monads")))

;; Fallback chains — automatic provider failover
(llm/with-fallback [:anthropic :openai :groq]
  (lambda () (llm/complete "Hello")))

;; In-memory vector store for semantic search (RAG)
(vector-store/create "docs")
(vector-store/add "docs" "id" (llm/embed "text") {:source "file.txt"})
(vector-store/search "docs" (llm/embed "query") 5)

;; Cross-encoder reranking — the retrieve-many → rerank-to-a-few RAG move
(llm/rerank "how do I read a file?"
            ["file/read returns a string" "http/get fetches a URL"]
            {:top-k 3})
;; => ({:index 0 :score 0.98 :document "file/read returns a string"} ...)

;; Text chunking for LLM pipelines
(text/chunk long-document {:size 500 :overlap 100})

;; Prompt templates
(prompt/render "Hello {{name}}" {:name "Alice"})
; => "Hello Alice"

;; Persistent key-value store
(kv/open "cache" "cache.json")
(kv/set "cache" "key" {:data "value"})
(kv/get "cache" "key")
```

## Supported Providers

All providers are auto-configured from environment variables — just set the API key and go.

| Provider              | Chat | Stream | Tools | Embeddings | Vision |
| --------------------- | ---- | ------ | ----- | ---------- | ------ |
| **Anthropic**         | ✅   | ✅     | ✅    | —          | ✅     |
| **OpenAI**            | ✅   | ✅     | ✅    | ✅         | ✅     |
| **Google Gemini**     | ✅   | ✅     | ✅    | —          | ✅     |
| **Ollama**            | ✅   | ✅     | ✅    | —          | ✅     |
| **Groq**              | ✅   | ✅     | ✅    | —          | —      |
| **xAI**               | ✅   | ✅     | ✅    | —          | —      |
| **Mistral**           | ✅   | ✅     | ✅    | —          | —      |
| **Moonshot**          | ✅   | ✅     | ✅    | —          | —      |
| **Jina**              | —    | —      | —     | ✅         | —      |
| **Voyage**            | —    | —      | —     | ✅         | —      |
| **Cohere**            | —    | —      | —     | ✅         | —      |
| **Any OpenAI-compat** | ✅   | ✅     | ✅    | —          | ✅     |
| **Custom (Lisp)**     | ✅   | —      | ✅    | —          | —      |

## It's Also a Real Lisp

Hundreds of built-in functions, tail-call optimization, macros, modules, error handling — not a toy.

```scheme
;; Closures, higher-order functions, TCO
(define (fibonacci n)
  (let loop ((i 0) (a 0) (b 1))
    (if (= i n) a (loop (+ i 1) b (+ a b)))))
(fibonacci 50) ;; => 12586269025

;; Full R7RS numeric tower — bignums, exact rationals, complex numbers
(expt 2 100)   ;; => 1267650600228229401496703205376
(+ 1/2 1/3)    ;; => 5/6
(sqrt -1)      ;; => 0+1i

;; Maps, keywords-as-functions, f-strings
(define person {:name "Ada" :age 36 :langs ["Lisp" "Rust"]})
(:name person) ;; => "Ada"
(println f"${(:name person)} knows ${(length (:langs person))} languages")

;; Destructuring
(let (({:keys [name age]} person))
  (println f"${name} is ${age}"))

;; Pattern matching with guards
(define (classify n)
  (match n
    (x when (> x 100) "big")
    (x when (> x 0)   "small")
    (_                 "non-positive")))

;; Functional pipelines
(->> (range 1 100)
     (filter even?)
     (map #(* % %))
     (take 5))
;; => (4 16 36 64 100)

;; Nested data access
(define config {:db {:host "localhost" :port 5432}})
(get-in config [:db :host])  ;; => "localhost"

;; Macros
(defmacro unless (test . body)
  `(if ,test nil (begin ,@body)))

;; Modules
(module utils (export square)
  (define (square x) (* x x)))

;; HTTP, JSON, regex, file I/O, crypto, CSV, datetime...
(define data (json/decode (http/get "https://api.example.com/data")))
```

> 📖 Full language reference, stdlib docs, and more examples at **[sema-lang.com/docs](https://sema-lang.com/docs/)**

## Try It Now

> **[sema.run](https://sema.run)** — Browser-based playground with 20+ example programs.
> No install required. Runs entirely in WebAssembly.

## Teach Your Coding Agent Sema in One Line

Sema is new, so your agent hasn't seen it. Fix that in one command — append the
agent crib sheet to your repo's `AGENTS.md` (and point `CLAUDE.md` at it):

```bash
curl -fsSL https://sema-lang.com/docs/for-agents.md >> AGENTS.md
ln -s AGENTS.md CLAUDE.md     # Claude Code, Cursor, etc. read this
```

[`for-agents.md`](https://sema-lang.com/docs/for-agents) is a single terse page —
*everything that differs from other Lisps* — written for an LLM that already knows a
Lisp. It links to [`/llms.txt`](https://sema-lang.com/llms.txt), a machine index of every
doc page so the agent can fetch just the page it needs (e.g. `/docs/llm/tools-agents.md`)
on demand, instead of loading the whole manual. Every doc URL also serves raw Markdown —
append `.md` to any `sema-lang.com/docs/...` link and your agent gets the source, not HTML.

## Installation

Install pre-built binaries (no Rust required):

```bash
# macOS / Linux
curl -fsSL https://sema-lang.com/install.sh | sh

# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https:/
agentic-aiagentsaiinterpreterlispllmmcp-serverprogramming-languagerust

What people ask about sema

What is sema-lisp/sema?

+

sema-lisp/sema is mcp servers for the Claude AI ecosystem. A Lisp with first-class LLM primitives, implemented in Rust It has 24 GitHub stars and was last updated today.

How do I install sema?

+

You can install sema by cloning the repository (https://github.com/sema-lisp/sema) or following the README instructions on GitHub. ClaudeWave also provides quick install blocks on this page.

Is sema-lisp/sema safe to use?

+

sema-lisp/sema has not been audited yet by our security agent. Review the original repository on GitHub before using it in production.

Who maintains sema-lisp/sema?

+

sema-lisp/sema is maintained by sema-lisp. The last recorded GitHub activity is from today, with 23 open issues.

Are there alternatives to sema?

+

Yes. On ClaudeWave you can browse similar mcp servers at /categories/mcp, sorted by popularity or recent activity.

Deploy sema to your cloud

Ship this repo to production in minutes. Each platform spins up its own environment with editable env vars.

Maintain this repo? Add a badge to your README

Drop the badge into your GitHub README to show it's tracked on ClaudeWave. Each badge links back to this page and reflects the live Trust Score.

Featured on ClaudeWave: sema-lisp/sema
[![Featured on ClaudeWave](https://claudewave.com/api/badge/sema-lisp-sema)](https://claudewave.com/repo/sema-lisp-sema)
<a href="https://claudewave.com/repo/sema-lisp-sema"><img src="https://claudewave.com/api/badge/sema-lisp-sema" alt="Featured on ClaudeWave: sema-lisp/sema" width="320" height="64" /></a>

More MCP Servers

sema alternatives