DEV Community

xbill for Google Developer Experts

Posted on • Originally published at xbill999.Medium on

MCP Development with Lisp, Firestore, Cloud Run, and Gemini CLI

Leveraging Gemini CLI and the underlying Gemini LLM to build Model Context Protocol (MCP) AI applications with the Lisp language deployed to Google Cloud Run.

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 HTTP transport 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:

GitHub - 40ants/mcp: 40ANTS-MCP is a framework for building Model Context Protocol servers in Common Lisp

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:

Common Lisp

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:

Steel Bank Common Lisp

This tool comes standard in most Linux distributions. For a basic Debian 12 installation:

sudo apt-get update
sudo apt-get install sbcl
Enter fullscreen mode Exit fullscreen mode

Then check the installation:

xbill@penguin:~$ sbcl --version
SBCL 2.2.9.debian
Enter fullscreen mode Exit fullscreen mode

Lisp Eco-System

The main components of the Lisp eco-system include:

ASDF

ASDF provides a basic build manager for Lisp:

ASDF - Another System Definition Facility

Quicklisp

Quicklisp allows for automated setup and configuration for your Lisp packages:

Quicklisp beta

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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:

GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

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 HTTP 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 HTTP 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 HTTP transport allows the MCP client and server to be on the same machine or distributed over the Internet.

The connection over HTTP will look similar to this:

(in-package :40ants-mcp/http-transport)

(setf *sse-handler* (clack-sse:serve-sse 'sse-stream-writer))


(defmethod 40ants-mcp/transport/base:start-loop ((transport http-transport) message-handler)
  "Start the HTTP server and begin processing requests.
   Monkey-patched to listen on 0.0.0.0 for Cloud Run."
  (log:info "Starting HTTP transport on port" (transport-port transport))
  (setf (transport-message-handler transport) message-handler)

  ;; Start the server
  (setf (transport-server transport)
        (clack:clackup (transport-lack-app transport)
                       :server :hunchentoot
                       :address "0.0.0.0"
                       :port (transport-port transport)
                       :use-thread nil)))
Enter fullscreen mode Exit fullscreen mode

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))
Enter fullscreen mode Exit fullscreen mode

Installing and Running the Code

Run the install make release target on the local system:

xbill@penguin:~/gemini-cli-codeassist/firestore-https-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.

Enter fullscreen mode Exit fullscreen mode

A binary is generated at the end of the process:

xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp$ make
Building mcp-server...
To load "mcp-https-lisp":
  Load 1 ASDF system:
    mcp-https-lisp
; Loading "mcp-https-lisp"
..................................................
........
Enter fullscreen mode Exit fullscreen mode

To lint the code:

xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp$ make lint
To load "sblint":
  Load 1 ASDF system:
    sblint
; Loading "sblint"
Enter fullscreen mode Exit fullscreen mode

To test the code:


xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp$ make test
To load "mcp-https-lisp/tests":
  Load 1 ASDF system:
    mcp-https-lisp/tests
; Loading "mcp-https-lisp/tests"
..................................................
..................................................
[package mcp-server-tests].

Testing System mcp-https-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.
Enter fullscreen mode Exit fullscreen mode

Start the Local MCP Server

Open a terminal window and kick off the local MCP server:

xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp$ make run
To load "mcp-https-lisp":
  Load 1 ASDF system:
    mcp-https-lisp
; Loading "mcp-https-lisp"
..................................................
........
{"timestamp":"2026-1-25T12:27:54.375041EST","level":"INFO","message":"Metadata service not available or failed, checking GOOGLE_APPLICATION_CREDENTIALS"}
{"timestamp":"2026-1-25T12:27:54.376395EST","level":"DEBUG","message":"Attempting to get token from gcloud"}
{"timestamp":"2026-1-25T12:27:55.261112EST","level":"DEBUG","message":"Successfully got token from gcloud"}
{"timestamp":"2026-1-25T12:27:55.261215EST","level":"INFO","message":"Starting MCP server on port 8080..."}
 <INFO> [12:27:55] 40ants-mcp/server/definition definition.lisp (start-server) -
  Starting MCP server with 40ANTS-MCP/SERVER/DEFINITION::TRANSPORT: :HTTP
  transport and tools 40ANTS-MCP/SERVER/DEFINITION::TOOLS-COLLECTIONS: #<MCP-SERVER::USER-TOOLS {1008045563}>

{"timestamp":"2026-1-25T12:27:55.268663EST","level":"INFO","message":"Starting HTTP transport on port 8080"}
Hunchentoot server is going to start.
Listening on 0.0.0.0:8080.
NOTICE: Running in debug mode. Debugger will be invoked on errors.
  Specify ':debug nil' to turn it off on remote environments.
Enter fullscreen mode Exit fullscreen mode

Gemini CLI Settings for the Local HTTP server

The sample .gemini/settings.json.https has been pre-built with a local connection:

{
  "mcpServers": {
    "firestore-https-lisp": {
      "url": "http://127.0.0.1:8080/mcp"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

MCP Client Connection Test

Next- open another window and start Gemini CLI. The local MCP connection over HTTP to the Lisp Code is validated and the full Gemini CLI session will start:

> /mcp list

Configured MCP servers:

🟢 firestore-https-lisp - Ready (8 tools)
  Tools:
  - add
  - check_db
  - get_product_by_id
  - get_products
  - get_root
  - greet
  - reset
  - seed

✦ I will execute the get_products tool to retrieve the list of products from the inventory database.
│ ✓ get_products (firestore-https-lisp MCP Server) {} │

✦ I have retrieved the list of products from the inventory database. The results include a variety of items such as Green Tea, Jasmine Rice, Coffee
  Beans, and many others, with their current prices and quantities.
Enter fullscreen mode Exit fullscreen mode

This information can be used in the current Gemin CLI context:

> can I make lattes with my inventory

✦ Yes, you have the core ingredients needed to make lattes in your inventory:

   * Coffee Beans: 239 units
   * Milk: 204 units

  You also have Cinnamon (399 units) which could be used as a topping!

Enter fullscreen mode Exit fullscreen mode

Deploying to Cloud Run

After the HTTP version of the MCP server has been tested locally — it can be deployed remotely to Google Cloud Run.

First- switch to the directory with the HTTP MCP sample code:

cd ~/gemini-cli-codeassist/firestore-https-lisp
Enter fullscreen mode Exit fullscreen mode

Deploy the project to Google Cloud Run with the pre-built cloudbuild.yaml and Dockerfile:

cd ~/gemini-cli-codeassist/firestore-https-lisp
xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp$ make deploy
Enter fullscreen mode Exit fullscreen mode

The Cloud Build will start:

xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp$ make deploy
echo "Submitting build to Google Cloud Build..."
Submitting build to Google Cloud Build...
gcloud builds submit . --config cloudbuild.yaml
Creating temporary archive of 26 file(s) totalling 100.5 KiB before compression.
Some files were not included in the source upload.

Check the gcloud log [/home/xbill/.config/gcloud/logs/2026.01.25/12.38.25.373745.log] to see which files and the contents of the
default gcloudignore file used (see `$ gcloud topic gcloudignore` to learn
more).

Uploading tarball of [.] to [gs://comglitn_cloudbuild/source/1769362705.521381-4d9a6ab6dbb14ef792948c02f4ffff89.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/comglitn/locations/global/builds/ebfe162d-beed-4817-94b2-5fc8c0ff1bfd].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/ebfe162d-beed-4817-94b2-5fc8c0ff1bfd?project=1056842563084].
Waiting for build to complete. Polling interval: 1 second(s).
---------------------------------------------------------------- REMOTE BUILD OUTPUT ----------------------------------------------------------------
starting build "ebfe162d-beed-4817-94b2-5fc8c0ff1bfd"

FETCHSOURCE
Fetching storage object: gs://comglitn_cloudbuild/source/1769362705.521381-4d9a6ab6dbb14ef792948c02f4ffff89.tgz#1769362705948687
Enter fullscreen mode Exit fullscreen mode

It can take 15–30 minutes to complete the build.

The cloud build needs to pull in all the Lisp libraries in the build environment and generate the entire package from scratch.

When the build is complete- an endpoint will be returned:

Starting Step #1
Step #1: Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1: Deploying container to Cloud Run service [firestore-https-lisp] in project [comglitn] region [us-central1]
Step #1: Deploying new service...
Step #1: Setting IAM Policy..............done
Step #1: Creating Revision.........................................................................done
Step #1: Routing traffic.....done
Step #1: Done.
Step #1: Service [firestore-https-lisp] revision [firestore-https-lisp-00001-vh7] has been deployed and is serving 100 percent of traffic.
Step #1: Service URL: https://firestore-https-lisp-1056842563084.us-central1.run.app
Finished Step #1 │
Enter fullscreen mode Exit fullscreen mode

The service endpoint in this example is :

https://firestore-https-lisp-1056842563084.us-central1.run.app
Enter fullscreen mode Exit fullscreen mode

The actual endpoint will vary based on your project settings.

Review The Service in Cloud Run

Navigate to the Google Cloud console and search for Cloud Run -

and then you can detailed information on the Cloud Run Service:

Cloud Logging

The remote server writes logs to stderr in standard JSON format. These logs are available from the deployed Cloud Run Service:

Validate HTTP connection

Once you have the Endpoint — you can attempt a connection- navigate to in your browser:

https://firestore-https-lisp-1056842563084.us-central1.run.app
Enter fullscreen mode Exit fullscreen mode

You will need to adjust the exact URL to match the URL returned from Cloud Build.

You will get an error- this connection is expecting a message in the MCP format:

Page Not Found
Enter fullscreen mode Exit fullscreen mode

Gemini CLI settings.json.cloudrun

Replace the default Gemini CLI configuration file —  settings.json with a pre-configured sample- settings.json.cloudrun to use the Cloud Run version of the connection:

{
  "mcpServers": {
    "firestore-cloudrun-lisp": {
      "url": "https://firestore-https-lisp-1056842563084.us-central1.run.app/mcp"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Copy the Cloud Run version of the Gemini CLI configuration file:

xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp$ cd .gemini
cp settings.json.cloudrun settings.json
xbill@penguin:~/gemini-cli-codeassist/firestore-https-lisp/.gemini$
Enter fullscreen mode Exit fullscreen mode

Validation with Gemini CLI

The final connection test uses Gemini CLI as a MCP client with the deployed Cloud Run Service in C providing the MCP server. Startup Gemini CLI with the updated settings :

gemini
> /mcp list

Configured MCP servers:

🟢 firestore-cloudrun-lisp - Ready (8 tools)
  Tools:
  - add
  - check_db
  - get_product_by_id
  - get_products
  - get_root
  - greet
  - reset
  - seed

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ? get_products (firestore-cloudrun-lisp MCP Server) {} ← │
│ │
│ MCP Server: firestore-cloudrun-lisp │
│ Tool: get_products │
│ │
│ Allow execution of MCP tool "get_products" from server "firestore-cloudrun-lisp"? │
│ │
│ 1. Allow once │
│ 2. Allow tool for this session │
│ ● 3. Allow all server tools for this session │
│ 4. Allow tool for all future sessions │
│ 5. No, suggest changes (esc) │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯✦ I found "Coffee Beans" in the inventory.

  Product Details:
   - Name: Coffee Beans
   - Price: $1
   - Quantity: 239
   - ID: 37kWbZHTwg5nbrSD13PB

Enter fullscreen mode Exit fullscreen mode

You can also validate the deployed code base:

> review the project

✦ I have reviewed the project using the codebase_investigator. Here is a summary of the project structure and key components:

  Project Overview
  This is a Common Lisp application that implements a Model Context Protocol (MCP) server. Its primary function is to manage an inventory database
  backed by Google Cloud Firestore. It exposes this functionality as "tools" that can be used by MCP clients (like Claude Desktop or other AI
  agents).

  Key Components

   1. MCP Server Implementation (`src/main.lisp`):
       * Library: Uses 40ants/mcp as the base framework.
       * Customization: Contains significant "monkey patches" to 40ants/mcp (specifically in src/main.lisp) to ensure protocol compliance (e.g., JSON
         field naming conventions like isError vs is-error) and to support Google Cloud Run deployment (listening on 0.0.0.0 instead of localhost).
       * Transport: Uses clack-sse for Server-Sent Events (SSE) over HTTPS.
       * Tools: Defines a user-tools API exposing functions like greet, get_products, seed, etc.

   2. Firestore Integration (`src/firestore.lisp`):
       * Method: Interacts with Firestore via its REST API using the dexador HTTP client.
       * Auth: Handles authentication using Google Application Default Credentials (ADC). It smartly switches between using gcloud (local dev) and
         the metadata service (Cloud Run).
       * Data Mapping: Manually maps between Lisp data structures and Firestore's specific JSON format (handling types like integers, strings, etc.).

   3. Build System:
       * Definition: The project is defined in mcp-https-lisp.asd.
       * Automation: A Makefile orchestrates tasks:
           * make deps: Installs dependencies (Quicklisp/Ultralisp).
           * make build: Compiles the project into a binary (mcp-server) using SBCL's save-lisp-and-die.
       * Containerization: A Dockerfile is present for containerizing the application, likely for Cloud Run deployment.

   4. Testing:
       * Framework: Uses rove for testing.
       * Location: Tests are found in tests/main.lisp and tests/packages.lisp.
Enter fullscreen mode Exit fullscreen mode

Summary

MCP development with Lisp using Gemini CLI was validated with an incremental step by step approach.

A minimal streaming HTTP transport MCP Server was built from source code and validated with Gemini CLI running as a MCP client in the same local environment.

Then — the MCP server was wrapped in a container and submitted to Google Cloud Build for deployment to Google Cloud Run. The remote MCP server was validated with a standard browser, and Gemini CLI.

Finally- remote MCP operations were performed from the local Gemini CLI installation to the Lisp MCP server hosted in Google Cloud Run.

This approach can be extended to more complex deployments and Cloud based options.

Top comments (0)