Skip to main content
Glama
ai-chan-meme

ai-chan-meme

by nervouna
README.md
# ai-chan-meme

English | [简体中文](README.zh-CN.md)

[![Release](https://img.shields.io/github/v/release/nervouna/ai-chan-meme)](https://github.com/nervouna/ai-chan-meme/releases/latest)
![Cloudflare Workers](https://img.shields.io/badge/runs%20on-Cloudflare%20Workers-F38020)
[![Code: MIT](https://img.shields.io/badge/code-MIT-blue.svg)](LICENSE)
[![Stickers: CC BY-NC-SA 4.0](https://img.shields.io/badge/stickers-CC%20BY--NC--SA%204.0-lightgrey.svg)](LICENSE-ART.md)

![ai-chan-meme](docs/images/banner.jpg)

A remote MCP server on Cloudflare Workers that lets Claude and ChatGPT reply with chibi Claude娘 and GPT娘 stickers. The sticker appears inline in the chat through an MCP Apps view, which draws a Chinese caption under the image.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/nervouna/ai-chan-meme)

<img src="docs/images/demo.jpg" width="988" alt="Three stickers as the view renders them: Claude娘 laughing with the caption 能做!上云就完事, GPT娘 smirking with 早说了吧, and Claude娘 collapsed with 上下文要爆了">

## Status

- For people who want Claude娘 and GPT娘 stickers in their Claude or ChatGPT chats and are willing to deploy their own instance. The author's instance is private: every MCP endpoint needs a token.
- Early, used daily by its author in Claude and ChatGPT.
- Running it takes a Cloudflare account. The Deploy to Cloudflare button needs nothing else; deploying from the command line needs Node.js 22.12 or later. A custom domain is optional.
- Captions are in Chinese. The tool description the model reads is in English.
- Releases are source only: deploy with the button, or from a release tag or `main`, as described in [Deploying your own](#deploying-your-own).
- [CONTRIBUTING.md](CONTRIBUTING.md) covers bug reports and fixes; [SECURITY.md](SECURITY.md) covers reporting a vulnerability.

## What it does

The server exposes one read-only tool, `show_sticker`:

| Argument | Meaning |
| --- | --- |
| `expression` | One of 12: `happy`, `deadpan`, `doubt`, `shocked`, `crying`, `salute`, `thumbsup`, `facepalm`, `angry`, `smug`, `idea`, `exhausted` |
| `caption` | Chinese caption, 1 to 40 characters; `\n` starts a new line |
| `character` | Optional, `claude` or `gpt`; defaults to the character of the endpoint |

The tool description asks the model to send a sticker in most conversational replies that carry an opinion, an emotion or a reaction, and to skip it for errors, confirmations of risky actions, serious or personal topics, and users who are frustrated or in a hurry.

Each call returns a short text result and a signed image URL. The view `ui://ai-chan-meme/sticker-v1.html` loads the image and draws the caption on a canvas; if that fails, it shows the image with the caption as HTML text.

All stickers: [Claude娘](stickers/overview-claude.jpg), [GPT娘](stickers/overview-gpt.jpg).

## Endpoints

| Path | Auth | Purpose |
| --- | --- | --- |
| `/mcp/claude` | `Authorization: Bearer <MEME_TOKEN>` | MCP, default character Claude娘 |
| `/mcp/gpt` | `Authorization: Bearer <MEME_TOKEN>` | MCP, default character GPT娘 |
| `/mcp/claude/<MEME_TOKEN>`, `/mcp/gpt/<MEME_TOKEN>` | Token in the path | Same, for clients that cannot send request headers |
| `/i/<signature>/<file>.jpg` | HMAC signature from `IMAGE_KEY` | Sticker images loaded by the view |

Every other path returns 404. The Worker runs before the static assets, so the stickers and the view are reachable only through these routes. Until `MEME_TOKEN` and `IMAGE_KEY` are both set to at least 32 characters, the MCP and image routes answer 503.

Image URLs and the view's content security policy use the origin the client connected to, so the same code works on `workers.dev` and on a custom domain.

## Connecting

Replace `meme.agents.damao.io` with your Worker's hostname, such as `ai-chan-meme.<your-subdomain>.workers.dev`.

- **Claude** (web, desktop, mobile): Settings → Connectors → Add custom connector. URL `https://meme.agents.damao.io/mcp/claude`, request header `Authorization: Bearer <MEME_TOKEN>`. If your client has no field for request headers, use `https://meme.agents.damao.io/mcp/claude/<MEME_TOKEN>` instead.
- **ChatGPT** (web): Plugins → Add custom MCP server. URL `https://meme.agents.damao.io/mcp/gpt/<MEME_TOKEN>`, authentication "No authentication".

The tool is marked read-only, so ChatGPT does not ask for confirmation on each call. In Claude, set the tool to always allowed in the connector settings to skip the approval prompt.

## Privacy

- The Worker stores nothing. It has no database or storage binding, and a tool call carries only its arguments (expression, caption, character).
- Workers observability is on in `wrangler.jsonc`, so Cloudflare keeps request logs for the account owner. They include request URLs, and with them the token of the `/mcp/<character>/<MEME_TOKEN>` form. Turn `observability` off if you do not want those logs.
- The chat client loads sticker images from the Worker's domain, so the Worker sees the IP address of whoever views a sticker.

## Deploying your own

### With the button

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/nervouna/ai-chan-meme)

1. Generate the two secrets, one for `MEME_TOKEN` and one for `IMAGE_KEY`, and keep them somewhere safe:

   ```bash
   openssl rand -hex 32
   openssl rand -hex 32
   ```

2. Select **Deploy to Cloudflare**, sign in, and connect GitHub or GitLab. Cloudflare copies this repository into your account, then builds and deploys it with Workers Builds.
3. On the setup page, paste the two values into `MEME_TOKEN` and `IMAGE_KEY`. Both must be at least 32 characters; with a shorter value the Worker answers every MCP and image request with 503.
4. When the deploy finishes, the Worker runs at `https://ai-chan-meme.<your-subdomain>.workers.dev`. Connect it as described above.

### From the command line

```bash
git clone https://github.com/nervouna/ai-chan-meme.git
cd ai-chan-meme
npm install
mkdir -p ~/.config/ai-chan-meme
(umask 077; printf '{"MEME_TOKEN":"%s","IMAGE_KEY":"%s"}\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > ~/.config/ai-chan-meme/secrets.json)
npx wrangler deploy --secrets-file ~/.config/ai-chan-meme/secrets.json
```

This keeps the secrets outside the repository and deploys to your `workers.dev` subdomain. Secrets persist, so later deploys need only `npm run deploy`.

### On your own domain

Add a custom domain to `wrangler.jsonc`, either as `routes` at the top level or in an environment like `env.damao`, which is the author's instance at `meme.agents.damao.io` (`npm run deploy:damao`). Copy that block with your hostname and deploy with `npx wrangler deploy --env <name>`. It keeps `"name": "ai-chan-meme"`, so it is the same Worker and keeps its secrets.

Rotating `IMAGE_KEY` breaks the stickers already shown in past chats; rotating `MEME_TOKEN` only means updating the connectors.

## Development

```bash
printf 'MEME_TOKEN=%s\nIMAGE_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .dev.vars
npm run dev      # wrangler dev on http://localhost:8787
npm run check    # TypeScript, Biome, and Vitest in the Workers runtime
```

| Path | Contents |
| --- | --- |
| `src/index.ts` | Routing, token checks, signed image responses |
| `src/server.ts` | The `show_sticker` tool, its description, and the view resource |
| `src/catalog.ts` | Characters and expressions |
| `assets/view.html` | The MCP Apps view |
| `assets/s/` | The served 600 px stickers |
| `stickers/` | 1254 px originals, overview sheets, and the generation prompts |

The prompts in `stickers/prompts/` refer to reference crops (`ref/*.png`) cut from the ai-chan-sheets character sheets and from approved trial stickers; the crops are not included.

## Art and license

The code is licensed under the [MIT license](LICENSE). The sticker art (`stickers/`, `assets/s/`, and the images in `docs/images/`) is licensed under [CC BY-NC-SA 4.0](LICENSE-ART.md) and must not be used commercially.

The stickers were generated with an image model, using these character sheets from [lmy414/ai-chan-sheets](https://github.com/lmy414/ai-chan-sheets) as references:

- 11 Claude娘 and 02 GPT娘: original character designs by [ZipZipPipe (胖次狐)](https://space.bilibili.com/4168597)
- 13 GPT娘 (chibi): original author not credited upstream

Rights to the original character designs stay with their authors. If you hold the rights to an original design and object to these stickers, open an issue and they will be removed.