I paint digitally, and every finished piece leaves behind a palette I can never find again. It might be trapped in a swatch panel, a screenshot named Screenshot 2026-11-14 at 23.41.09.png, or a note saying ‘warm dusk, maybe more teal?’ That is why I built a small MCP server for palette memory. It saves palettes to Firestore, runs on Cloud Run, and talks to Gemini CLI. If you paint with an AI-assisted app such as Halsion Paint, you can pull hex codes from your canvas and hand them to the server. Then you can type things like ‘save these five colors as harbor at dusk and tag them warm-shadows’ or ‘find everything tagged dusk.’ It also checks whether a palette’s values are too flat to read across the room.

The goal: my palettes live somewhere I can search them, not in a folder of screenshots.
What MCP gives you in painter terms
An LLM can discuss color theory, but it cannot open your palette library. MCP is an open protocol where a client, Gemini CLI here, calls tools you define. Each tool has a name, typed arguments, and a description the model can read.
For this project the pieces are:
- Gemini CLI: the terminal chat interface and MCP client.
- MCP server in Python: exposes save, search, and analyze tools.
- Firestore: stores palettes as documents.
- Cloud Run: hosts the server without you managing a machine.
One limit up front: the model does not see your canvas. You give it hex codes from an eyedropper or palette export. Everything below works from those.
Prerequisites
- A Google Cloud project with billing enabled.
- gcloud installed and authenticated.
- Python 3.11 or newer.
- Gemini CLI installed.
Enable the APIs and create a Firestore database:
gcloud services enable run.googleapis.com firestore.googleapis.com cloudbuild.googleapis.com artifactregistry.googleapis.com
gcloud firestore databases create --location=nam5
Pick the nearest location; nam5 is just an example.
The server
Create a folder with two files. First, requirements.txt:
fastmcp
google-cloud-firestore
Then server.py. It has three parts: setup, storage tools, and the analysis tool.
Setup and validation
import colorsys
import os
import re
from datetime import datetime, timezone
from fastmcp import FastMCP
from google.cloud import firestore
from google.cloud.firestore_v1.base_query import FieldFilter
mcp = FastMCP('palette-keeper')
db = firestore.Client()
HEX = re.compile(r'^#?[0-9a-fA-F]{6}$')
def normalize(colors: list[str]) -> list[str]:
cleaned = []
for c in colors:
if not HEX.match(c):
raise ValueError(f'Not a 6-digit hex color: {c}')
cleaned.append('#' + c.lstrip('#').upper())
return cleaned
Validation matters. The model may pass along what it thinks you meant. Clear errors let it correct itself and retry.
Saving and finding palettes
@mcp.tool
def save_palette(name: str, colors: list[str], tags: list[str] | None = None, notes: str = '') -> dict:
'''Save a color palette. Colors are 6-digit hex codes.'''
doc = db.collection('palettes').document()
doc.set({
'name': name,
'colors': normalize(colors),
'tags': [t.lower() for t in (tags or [])],
'notes': notes,
'created_at': datetime.now(timezone.utc),
})
return {'id': doc.id, 'saved': name}
@mcp.tool
def find_palettes(tag: str, limit: int = 10) -> list[dict]:
'''Find saved palettes that have a given tag, newest first.'''
query = db.collection('palettes').where(
filter=FieldFilter('tags', 'array_contains', tag.lower())
)
results = []
for snap in query.stream():
data = snap.to_dict()
data['id'] = snap.id
data['created_at'] = data['created_at'].isoformat()
results.append(data)
results.sort(key=lambda d: d['created_at'], reverse=True)
return results[:limit]
I sort in Python on purpose. Mixing array_contains with order_by on another field needs a composite index. For a personal library of a few hundred palettes, sorting in memory is fine and avoids setup.
The values check I actually use
Value structure, meaning how light or dark each color reads, is what makes a painting legible. A palette can look lovely as swatches and turn muddy when desaturated. This tool does a rough version of that check:
@mcp.tool
def analyze_palette(colors: list[str]) -> dict:
'''Report value range, warm/cool balance, and a complement accent.'''
colors = normalize(colors)
rows = []
for c in colors:
r, g, b = (int(c[i:i + 2], 16) / 255 for i in (1, 3, 5))
h, s, v = colorsys.rgb_to_hsv(r, g, b)
luma = 0.299 * r + 0.587 * g + 0.114 * b
rows.append({'hex': c, 'hue': h * 360, 'sat': s, 'luma': luma})
lumas = [x['luma'] for x in rows]
value_range = max(lumas) - min(lumas)
def is_warm(x):
return x['sat'] > 0.1 and (x['hue'] < 70 or x['hue'] >= 330)
warm = sum(is_warm(x) for x in rows)
boldest = max(rows, key=lambda x: x['sat'])
comp_h = ((boldest['hue'] + 180) % 360) / 360
cr, cg, cb = colorsys.hsv_to_rgb(comp_h, boldest['sat'], 0.9)
complement = '#{:02X}{:02X}{:02X}'.format(round(cr * 255), round(cg * 255), round(cb * 255))
return {
'darkest': min(rows, key=lambda x: x['luma'])['hex'],
'lightest': max(rows, key=lambda x: x['luma'])['hex'],
'value_range': round(value_range, 2),
'flat_values': value_range < 0.35,
'warm_count': warm,
'cool_or_neutral_count': len(rows) - warm,
'suggested_accent': complement,
'accent_based_on': boldest['hex'],
}
if __name__ == '__main__':
mcp.run(
transport='http',
host='0.0.0.0',
port=int(os.environ.get('PORT', 8080)),
)
The thresholds are my rules of thumb, not science. A value range under about 0.35 means the squint test may fail; the warm/cool split is a crude hue cutoff. Change them to match how you paint. Because the tool returns plain numbers, the LLM can turn them into advice in your own vocabulary.

A dusk palette plus the suggested complement accent returned by analyze_palette.
Containerize and deploy
Add a Dockerfile:
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY server.py .
CMD ["python", "server.py"]
Deploy from source. Note --no-allow-unauthenticated: your palette library is private, so the service should not be public.
gcloud run deploy palette-keeper --source . --region us-central1 --no-allow-unauthenticated
The Cloud Run service account needs permission to read and write Firestore. Grant it the Datastore User role:
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID --member='serviceAccount:YOUR_SERVICE_ACCOUNT' --role='roles/datastore.user'
Connect Gemini CLI
Because the service is private, use the Cloud Run proxy. It handles authentication and exposes the service on localhost:
gcloud run services proxy palette-keeper --region us-central1 --port 3000
Leave that running. Then add the server to ~/.gemini/settings.json:
{
"mcpServers": {
"palette-keeper": {
"httpUrl": "http://localhost:3000/mcp"
}
}
}
Start gemini and run /mcp. You should see palette-keeper listed with its three tools.
Try it
Here are prompts I actually use:
Save these as 'harbor at dusk', tagged dusk and warm-shadows:
#1B2A41 #324A5F #C96F4A #F2A65A #FCE1B8
Note: rim light on the boats is the orange.
Analyze that palette. Are my values too flat? What accent would make the boat sails pop?
Show me everything I have tagged dusk. Which one has the widest value range?
The third prompt shows why this beats a notes app. Gemini calls find_palettes, then calls analyze_palette on each result, and compares them. You never asked for that sequence. The tool descriptions were enough for the model to plan it.

Gemini CLI chaining tool calls: saving a palette, then analyzing it.
Lessons from building this
- Tool descriptions are the interface. The docstrings on each function are what the model reads. Vague ones lead to wrong tool choices.
- Return data, not prose. Let the tool give numbers and let the model explain them. You can change the tone of feedback without redeploying.
- Keep it private by default. --no-allow-unauthenticated plus the proxy costs one extra terminal tab and keeps strangers out of your library.
- Start small. Three tools covered nearly everything I wanted. Resist adding twenty.
Where to take it next
- Store a thumbnail of the finished piece in Cloud Storage and save its URL on the palette document. If you paint in a program with an AI agent, like Halsion Paint on Halsion, you could export a version of your finished work and link it straight to the palette that made it.
- Add a link_reference tool for saving reference photos and their source credits.
- Add a tool that logs brush and blending-mode notes per project, so ‘what did I use for that foggy glow?’ has an answer.
- Export a palette as an .ase or .gpl file you can import into your painting app.
The satisfying part is that none of this changed how I paint. I still use the same tablet and the same brushes. What changed is that the choices I make mid-painting stop disappearing, and I can ask questions about my own habits and get answers.
If you build your own version, I would like to hear which tools you end up adding.
Top comments (0)