深夜提醒

现在是深夜,建议您注意休息,不要熬夜哦~

🏮 🏮 🏮

新年快乐

祝君万事如意心想事成!

share-image
中
ESC

When AI Learns to Order Coffee: The Full Record of Luckin CLI, from Installation to Avoiding Pitfalls

English 阅读中文版

In one sentence: Luckin Coffee has released a command-line tool that lets you order coffee in natural language. This post records the whole process — installation, login, model configuration and troubleshooting the pitfalls — with a special warning for Windows users about the .env file not taking effect.

clip_1781167061175_c2cncj.png

I. Foreword: The Ultimate Laziness Tool for Coffee People

As a developer who stays alive on coffee every day, I recently found something interesting — Luckin CLI, released officially by Luckin Coffee.

It isn’t an ordinary command-line tool but an AI assistant terminal built on MCP (Model Context Protocol). Put simply, you can say to it directly in the terminal:

luckin -p "帮我来一杯冰美式,少冰"

Then the AI automatically finds a store → picks the item → matches a coupon → places the order for you, stopping at key points to let you confirm. No more opening the app and tapping around.

Even more outrageous, it can also look up nearby stores, check your orders and cancel an order, all entirely through natural language.

Official site: https://open.lkcoffee.com/mcp

II. Installation and Login

1. Installation

After downloading luckin.exe, just run the install command:

luckin.exe install

This copies it into your user directory and adds it to PATH, so from then on you can use the luckin command directly.

2. Logging In to Get a Token

luckin.exe login

This launches a browser and lets you scan a QR code or log in with your phone number to your Luckin account. After a successful login it writes an MCP Token into your local config file, valid for one month, so you don’t have to log in frequently.

After logging in you can test whether the basic functions work with luckin.exe menu or luckin.exe store.

III. Configuring the LLM Model (The Core Step)

Luckin CLI doesn’t come with a large model built in; you need to hook up an OpenAI-compatible API yourself. I happened to have an Alibaba Cloud Model Studio (DashScope) key on hand, chose qwen-plus as the model, and the configuration went as follows.

My Configuration Details

Config item Value
Model name qwen (custom, used as an identifier)
Base URL https://dashscope.aliyuncs.com/compatible-mode/v1
Model ID qwen-plus
API Key sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The Command to Add a Model

# 方式一:明文写入 API Key(不推荐,会写入 config.json)
luckin.exe models add qwen `
--base-url "https://dashscope.aliyuncs.com/compatible-mode/v1" `
--model "qwen-plus" `
--api-key "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" `
--set-active

# 方式二:通过环境变量引用(推荐)
luckin.exe models add qwen `
--base-url "https://dashscope.aliyuncs.com/compatible-mode/v1" `
--model "qwen-plus" `
--api-key-env "DASHSCOPE_API_KEY" `
--set-active

I chose the second method — it’s safer.

Verifying the Configuration

luckin.exe models status

If you see output like the following, the configuration succeeded:

active: qwen
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
model: qwen-plus
profiles: 1
qwen: env:DASHSCOPE_API_KEY

IV. Major Pitfall Warning: the .env File Doesn’t Take Effect on Windows!

After finishing the configuration, I ran this full of confidence:

luckin.exe -p "你好"

And got an error:

当前模型 "qwen" 未就绪:未配置 API Key:请在 ~/.luckin/.env 写入 DASHSCOPE_API_KEY=你的密钥

I had clearly followed the prompt and written DASHSCOPE_API_KEY=... into C:\Users\<your username>\.luckin\.env — so why was it still erroring?

The Troubleshooting Process

  1. Check the file contents → no problem, the key really was written in.
  2. Check config.json → also fine, api_key_env pointed to the right thing.
  3. Suspect a path issue → on Windows, ~ should map to %USERPROFILE%, and the path was correct.
  4. Finally discovered it: on Windows, Luckin CLI does not automatically read the .env file! It relies on the system environment variable itself existing, rather than going and reading the .env file.

The Solution

Temporary, for the current window:

$env:DASHSCOPE_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
luckin.exe -p "你好"

Persistent solution (recommended): write it into the Windows user environment variables

[Environment]::SetEnvironmentVariable(
"DASHSCOPE_API_KEY",
"sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"User"
)

After setting it, close the current PowerShell and reopen a new window, and the environment variable will be loaded. From then on you never have to set it manually again.

Pitfall-avoidance summary: when using Luckin CLI on Windows, don’t count on the .env file — setting a system environment variable directly is the most reliable approach.

V. The Actual Experience

After a successful configuration, my first conversation:

luckin.exe -p "你好"

Output:

MCP 连接中…
MCP 列举工具中…
模型推理中…
你好,我是瑞幸咖啡 Luckin CLI 内置助手。我可以帮你:
- 查询附近门店
- 搜索并下单商品(支持一句话点单)
- 查看/取消当前订单
- 修改商品规格(如加冰、去糖等)
请告诉我你的需求,例如:
📍 "查一下附近的瑞幸"
☕ "我要买一杯生椰拿铁"
📦 "查看我的最新订单"

Of course, actually using it is more fun than the official examples. In WeChat I used ClawBot to place an order with a single sentence; the AI automatically matched me to the nearest Cangxing Street store, picked the Orange C Americano and its specs — list price ¥20.0, an automatic discount of ¥7.1, amount payable ¥12.9:

微信 ClawBot 下单对话

There are currently two small limitations: you can’t use the 9.9-yuan coupon, and you can’t actively claim coupons — the price is just the amount after the system’s direct discount. After confirming the order, the AI generates a payment QR code that you have to scan yourself to complete payment; it isn’t an automatic deduction. Once I’d paid and told it so, it immediately looked up my pickup code for me: 814. After the whole flow ran through, the experience was quite smooth — the AI calls the real Luckin API and doesn’t make results up, and it stops at key points to let you confirm.

Finally I went to the store, gave the pickup code, and this is what the cup I got looked like — the pickup code matched:

橙 C 美式实拍

VI. Quick Reference for Common Commands

# 基础
luckin login # 浏览器登录
luckin logout # 清除 Token
luckin version # 查看版本

# 门店与商品
luckin store # 查询附近门店
luckin menu # 查询门店饮品菜单
luckin product # 查询门店商品

# 模型管理
luckin models list # 列出所有模型
luckin models status # 查看当前模型状态
luckin models add <name> # 添加模型
luckin models set <name> # 切换模型

# 订单
luckin order # 订单相关操作

# 一句话交互
luckin -p "来一杯生椰拿铁"

VII. In Closing

Luckin CLI is a very interesting attempt — it brings the MCP protocol down from “AI development tooling” into “everyday consumer scenarios.” For developers, being able to order coffee or check orders in natural language from the terminal is both cool and practical.

Of course, the Windows version’s experience still has room for polish (the .env issue, for example), but overall the flaws don’t obscure the merits. If you’re also a developer who drinks a cup of coffee every day, it’s worth a try.

Reference links:

文章作者:阿文
文章链接: https://www.awen.me/post/9cb0598.html
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 阿文的博客!

评论

0 条评论
😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️✋ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐⛎ ♈♉♊ ♋♌♍ ♎♏♐ ♑♒♓ 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘❌⭕ 🛑⛔📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭❗ ❕❓❔ ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️✅ 🈯💹❇️ ✳️❎🌐 💠Ⓜ️🌀 💤🏧🚾 ♿🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️
加载中...

留言反馈

😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️✋ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐⛎ ♈♉♊ ♋♌♍ ♎♏♐ ♑♒♓ 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘❌⭕ 🛑⛔📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭❗ ❕❓❔ ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️✅ 🈯💹❇️ ✳️❎🌐 💠Ⓜ️🌀 💤🏧🚾 ♿🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️