Leveraging Gemini CLI and the underlying Gemini LLM to build Model Context Protocol (MCP) AI applications with the Lisp language in a local development environment.
Why not just use Python?
Python has traditionally been the main coding language for ML and AI tools. One of the strengths of the MCP protocol is that the actual implementation details are independent of the development language. The reality is that not every project is coded in Python- and MCP allows you to use the latest AI approaches with other coding languages.
LISP? That Alien Programming Language works with MCP?
The goal of this article is to provide a minimal viable basic working MCP stdio server in LISP that can be run locally without any unneeded extra code or extensions.
Not a fan of functional programming?
It takes all kinds. The bottom line is different strokes for different folks and the tools can meet you where you are. The Internet has gotten over the Emacs vs Vi flame wars.
Lisp Native MCP Library
There are several available Lisp libraries in GitHub. The Lisp MCP library used in this demo/article is here:
What Is Lisp?
Lisp (historically LISP) is a family of programming languages that is the second-oldest high-level language still in widespread use (after Fortran), known for its unique syntax where both code and data are represented as lists. Its name is an acronym for “LISt Processing”.
Official Common Lisp Site
There are a few sites with Lisp resources. This site is a good starting point:
Installing Lisp
Lisp comes with a whole eco-system including tooling, utilities, and build management.
There are a few common interpreters. For ease of installation — the Steel Bank Common Lisp variant was used:
This tool comes standard in most Linux distributions. For a basic Debian 12 installation:
sudo apt-get update
sudo apt-get install sbcl
Then check the installation:
xbill@penguin:~$ sbcl --version
SBCL 2.2.9.debian
Lisp Eco-System
The main components of the Lisp eco-system include:
ASDF
ASDF provides a basic build manager and tooling for Lisp:
ASDF - Another System Definition Facility
Quicklisp
Quicklisp allows for automated setup and configuration for your Lisp packages:
What is Firestore?
Google Firestore, also known as Cloud Firestore is a part of the Google Firebase application development platform. It is fundamentally a cloud-hosted NoSQL database for storing and syncing data. Firestore can be directly accessed by mobile and web applications through native SDKs.
Gemini CLI
If not pre-installed you can download the Gemini CLI to interact with the source files and provide real-time assistance:
npm install -g @google/gemini-cli
Testing the Gemini CLI Environment
Once you have all the tools and the correct Node.js version in place- you can test the startup of Gemini CLI. You will need to authenticate with a Key or your Google Account:
gemini
Node Version Management
Gemini CLI needs a consistent, up to date version of Node. The nvm command can be used to get a standard Node environment:
Lisp MCP Documentation
The official MCP Lisp page provides samples and documentation for getting started:
mcp/docs at master · 40ants/mcp
Where do I start?
The strategy for starting MCP development is a incremental step by step approach.
First, the basic development environment is setup with the required system variables, and a working Gemini CLI configuration.
Then, a minimal Hello World Style Lisp MCP Server is built with stdio transport. This server is validated with Gemini CLI in the local environment.
This setup validates the connection from Gemini CLI to the local process via MCP. The MCP client (Gemini CLI) and the MCP server both run in the same local environment.
Next- the basic MCP server is extended with Gemini CLI to add several new tools in standard code.
Setup the Basic Environment
At this point you should have a working C build environment, Lisp tools, and a working Gemini CLI installation. The next step is to clone the GitHub samples repository with support scripts:
cd ~
git clone https://github.com/xbill9/gemini-cli-codeassist
Then run init.sh from the cloned directory.
The script will attempt to determine your shell environment and set the correct variables:
cd gemini-cli-codeassist
source init.sh
If your session times out or you need to re-authenticate- you can run the set_env.sh script to reset your environment variables:
cd gemini-cli-codeassist
source set_env.sh
Variables like PROJECT_ID need to be setup for use in the various build scripts- so the set_env script can be used to reset the environment if you time-out.
Hello World with STDIO Transport
One of the key features that the standard MCP libraries provide is abstracting various transport methods.
The high level MCP tool implementation is the same no matter what low level transport channel/method that the MCP Client uses to connect to a MCP Server.
The simplest transport that the SDK supports is the stdio (stdio/stdout) transport — which connects a locally running process. Both the MCP client and MCP Server must be running in the same environment.
The connection over stdio will look similar to this:
(in-package :40ants-mcp/server/api/tools/list)
(defun make-tool-description-for-method (method-name method-info)
(multiple-value-bind (params required)
Lisp Package Information
The code depends on several standard libraries for MCP and logging:
(defpackage :mcp-server
(:use :cl)
(:import-from :40ants-mcp/tools
:define-tool)
(:import-from :40ants-mcp/server/definition
:start-server
:mcp-server)
(:export :main
:get-greeting))
Installing and Running the Code
Run the install make release target on the local system:
xbill@penguin:~/gemini-cli-codeassist/firestore-stdio-lisp$ make deps
2 dists to check.
You already have the latest version of "quicklisp": 2026-01-01.
You already have the latest version of "ultralisp": 20260125155000.
To load "jsonrpc":
Load 1 ASDF system:
jsonrpc
; Loading "jsonrpc"
.
To load "40ants-mcp":
Load 1 ASDF system:
40ants-mcp
; Loading "40ants-mcp"
..................................................
......
To load "serapeum":
Load 1 ASDF system:
serapeum
; Loading "serapeum"
To load "yason":
Load 1 ASDF system:
yason
; Loading "yason"
To load "local-time":
Load 1 ASDF system:
local-time
; Loading "local-time"
Dependencies installed successfully.
A binary is generated at the end of the process:
xbill@penguin:~/gemini-cli-codeassist/firestore-stdio-lisp$ make
Building mcp-server...
2 dists to check.
You already have the latest version of "quicklisp": 2026-01-01.
You already have the latest version of "ultralisp": 20260125155000.
To load "jsonrpc":
Load 1 ASDF system:
jsonrpc
; Loading "jsonrpc"
.
To load "40ants-mcp":
Load 1 ASDF system:
40ants-mcp
; Loading "40ants-mcp"
..................................................
......
To load "serapeum":
Load 1 ASDF system:
serapeum
; Loading "serapeum"
To load "yason":
Load 1 ASDF system:
yason
; Loading "yason"
To load "local-time":
Load 1 ASDF system:
local-time
; Loading "local-time"
Dependencies installed successfully.
To load "firestore-stdio-lisp":
Load 1 ASDF system:
firestore-stdio-lisp
; Loading "firestore-stdio-lisp"
Building binary mcp-server...
compressed 32768 bytes into 555 at level 9
compressed 59736064 bytes into 10258775 at level 9
compressed 23461888 bytes into 4568490 at level 9
compressed 2818048 bytes into 691821 at level 9
compressed 22839296 bytes into 5498432 at level 9
To test the code:
xbill@penguin:~/gemini-cli-codeassist/firestore-stdio-lisp$ make test
To load "firestore-stdio-lisp/tests":
Load 1 ASDF system:
firestore-stdio-lisp/tests
; Loading "firestore-stdio-lisp/tests"
..................................................
..................................................
[package mcp-server-tests].
Testing System firestore-stdio-lisp/tests
;; testing 'mcp-server-tests'
test-greeting
should return a valid greeting
✓ Expect (STRING= (GET-GREETING "World") "Hello, World!") to be true.
✓ Expect (STRING= (GET-GREETING "Lisp") "Hello, Lisp!") to be true.
✓ 1 test completed
Summary:
All 1 test passed.
Gemini CLI settings.json
In this example — the Lisp source code uses a compiled binary that can be called directly from Gemini CLI.
The default Gemini CLI settings.json has an entry for the source:
{
"mcpServers": {
"firestore-stdio-lisp": {
"command": "$HOME/gemini-cli-codeassist/firestore-stdio-lisp/mcp-server"
}
}
}
Validation with Gemini CLI
Finally- Gemini CLI is restarted and the MCP connection over stdio to the Code is validated, The full Gemini CLI Session will start:
> /mcp list
Configured MCP servers:
🟢 firestore-stdio-lisp - Ready (8 tools)
Tools:
- add
- check_db
- get_product_by_id
- get_products
- get_root
- greet
- reset
- seed
> get_products
✦ I will retrieve the list of products from the inventory database again to ensure you have the most up-to-date information.
⠋ Deciding on Execution (esc to cancel, 5s)
2 GEMINI.md files | 1 MCP server
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Type your message or @path/to/file │
✦ I will retrieve the list of products from the inventory database again to ensure you have the most up-to-date information.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ⊶ get_products (firestore-stdio-lisp MCP Server) {} │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ I've updated the product list. Is there anything specific you'd like to do with this information?
> is there coffee in inventory?
✦ Yes, there are Coffee Beans in the inventory (ID: 37kWbZHTwg5nbrSD13PB). There are currently 239 units available at a price of $1 each.
Extending the MCP Server with Gemini CLI
Now that the basic MCP functionality has been tested and verified with Gemini CLI- the C server code can be extended with new MCP tools:
> with the Lisp project add new MCP tools -
one that generates an inventory report
one that builds a suggested menu
Gemini CLI will get right to work:
│ 195 + (defun generate-inventory-report () │
│ 196 + (let* ((products (get-products)) │
│ 197 + (total-items (length products)) │
│ 198 + (total-quantity (reduce #'+ products :key (lambda (p) (gethash "quantity" p)))) │
│ 199 + (total-value (reduce #'+ products :key (lambda (p) (* (gethash "quantity" p) (gethash "price" p))))) │
│ 200 + (low-stock (remove-if-not (lambda (p) (and (> (gethash "quantity" p) 0) (< (gethash "quantity" p) 10))) products)) │
│ 201 + (out-of-stock (remove-if-not (lambda (p) (<= (gethash "quantity" p) 0)) products))) │
│ 202 + (with-output-to-string (s) │
│ 203 + (format s "Inventory Report:~%") │
│ 204 + (format s "Total Distinct Items: ~A~%" total-items) │
│ 205 + (format s "Total Quantity: ~A~%" total-quantity) │
│ 206 + (format s "Total Value: $~,2F~%~%" total-value) │
│ 207 + │
│ 208 + (when low-stock │
│ 209 + (format s "Low Stock Items (< 10):~%") │
│ 210 + (dolist (p low-stock) │
│ 211 + (format s "- ~A (Qty: ~A)~%" (gethash "name" p) (gethash "quantity" p))) │
│ 212 + (format s "~%")) │
│ 213 + │
│ 214 + (when out-of-stock │
│ 215 + (format s "Out of Stock Items:~%") │
│ 216 + (dolist (p out-of-stock) │
│ 217 + (format s "- ~A~%" (gethash "name" p))))))) │
│ 218 + │ │
Re-build the MCP server:
xbill@penguin:~/gemini-cli-codeassist/firestore-stdio-lisp$ make
Building mcp-server...
2 dists to check.
You already have the latest version of "quicklisp": 2026-01-01.
You already have the latest version of "ultralisp": 20260125155000.
To load "jsonrpc":
Load 1 ASDF system:
jsonrpc
; Loading "jsonrpc"
.
To load "40ants-mcp":
Load 1 ASDF system:
40ants-mcp
; Loading "40ants-mcp"
..................................................
......
To load "serapeum":
Load 1 ASDF system:
serapeum
; Loading "serapeum"
To load "yason":
Load 1 ASDF system:
yason
; Loading "yason"
To load "local-time":
Load 1 ASDF system:
local-time
; Loading "local-time"
Dependencies installed successfully.
To load "firestore-stdio-lisp":
Load 1 ASDF system:
firestore-stdio-lisp
; Loading "firestore-stdio-lisp"
then test the new tools:
> /mcp list
Configured MCP servers:
🟢 firestore-stdio-lisp - Ready (10 tools)
Tools:
- add
- check_db
- get_product_by_id
- get_products
- get_root
- greet
- inventory_report
- reset
- seed
- suggest_menu
> suggest_menu
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ? suggest_menu (firestore-stdio-lisp MCP Server) {} ← │
│ │
│ MCP Server: firestore-stdio-lisp │
│ Tool: suggest_menu │
│ │
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ⊷ suggest_menu (firestore-stdio-lisp MCP Server) {} │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ suggest_menu (firestore-stdio-lisp MCP Server) {} │
│ │
│ Suggested Menu: │
│ 1. Eggs - $9.00 │
│ 2. Green Tea - $5.18 │
│ 3. Rice - $5.00 │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ Here is the suggested menu based on the available inventory:
1. Eggs - $9.00
2. Green Tea - $5.18
3. Rice - $5.00
Gemini CLI Project Review
Gemini CLI can review and explain the project:
> what does this project do?
✦ This is a Common Lisp based Model Context Protocol (MCP) server.
It acts as a bridge between an MCP client (like this CLI or an IDE) and a Google Cloud Firestore database to manage a store inventory ("Cymbal
Superstore"). It runs over standard input/output (stdio) to receive commands and return results.
Core Capabilities
It exposes several "tools" that I can call directly:
* Inventory Management:
* get_products: List all items in the inventory.
* get_product_by_id: Find specific items.
* seed / reset: Populate or clear the database.
* inventory_report: Generate a summary of current stock.
* suggest_menu: Create meal ideas based on available ingredients.
* System/Utility:
* check_db: Verify database connectivity.
* greet: Simple hello world test.
* add: Basic arithmetic test.
Technical Stack
* Language: Common Lisp (SBCL)
* Framework: 40ants-mcp (for the MCP implementation)
* Data Source: Google Cloud Firestore (via src/firestore.lisp)
It is essentially a backend service that I can "talk" to in order to query or manipulate the store's data
Summary
The strategy for using Lisp with MCP development with Gemini CLI was validated with an incremental step by step approach.
A minimal stdio transport MCP Server was started from source code and validated with Gemini CLI running as a MCP client in the same local environment.
Gemini CLI was then used to extend the sample Lisp code with several MCP tools and use these tools inside the context for the underlying LLM.


Top comments (0)