Using the API with AI

Using the API with AI

AI tools can connect to your Lunch Money data in two ways: through an MCP server that lets you ask natural-language questions in a chat interface, or through an AI coding assistant that helps you write scripts against the API. This page explains both approaches and how to handle your access token safely in each.

Lunch Money never shares your data with AI automatically. AI only gets access to your data when you choose to connect it.

Option 1: Connect an AI assistant via MCP

MCP (Model Context Protocol) is a standard that lets AI assistants use external tools. A Lunch Money MCP server acts as a bridge between your AI chat app and the Lunch Money API, letting you ask questions like:

The Lunch Money developers page lists community-built MCP servers. Pick one whose setup instructions and permission model you're comfortable with, and follow its documentation carefully. If you're not sure where to start, lunchmoney-mcp is a popular choice — it works well with Claude Desktop (including a one-click .mcpb bundle install), covers the full v2 API, and has straightforward setup instructions.

With MCP, your access token usually lives in a local configuration file on your computer — not in the chat window — which is safer than pasting it directly into a conversation.

When an AI assistant answers a question using MCP, the relevant Lunch Money data may be sent through the AI provider to generate the response. Review the MCP server's documentation and your AI provider's data-handling policy before connecting.

Option 2: Use an AI coding assistant to build your own tools

If you're comfortable writing code, another approach is to point an AI coding assistant at the Lunch Money OpenAPI spec and ask it to help you build exactly what you need. For example:

This is a useful middle path: the AI helps write code against the public API docs, while your actual financial data stays between your computer and Lunch Money unless you explicitly share it.

If an AI coding assistant is only helping you write code from the public API docs, it may not need to see any of your financial data at all. Keep data out of the chat and run the resulting scripts locally.

Keeping your token out of the conversation

The safest way to supply your access token to a local script is to keep it out of the prompt entirely — let the program read it at runtime instead:

# Set once in your shell or add to your shell config file
export LUNCH_MONEY_ACCESS_TOKEN="your_token_here"

# Scripts and curl commands read it automatically
curl https://api.lunchmoney.dev/v2/me \
  -H "Authorization: Bearer $LUNCH_MONEY_ACCESS_TOKEN"
# .env file (add to .gitignore — do not commit to source control)
# LUNCH_MONEY_ACCESS_TOKEN=your_token_here

import os
from dotenv import load_dotenv

load_dotenv()
token = os.environ["LUNCH_MONEY_ACCESS_TOKEN"]
// .env file (add to .gitignore — do not commit to source control)
// LUNCH_MONEY_ACCESS_TOKEN=your_token_here

import 'dotenv/config';
const token = process.env.LUNCH_MONEY_ACCESS_TOKEN;
Avoid pasting your access token directly into an AI chat window. Treat it like a password — store it in an environment variable, a .env file excluded from source control, or your operating system's secret store.

Best Practices

  1. Start with a test budget — API changes are permanent. Use a test budget while you're learning so your real data stays safe. See the Getting Started guide for instructions.

  2. Prefer read-only workflows — A workflow that only reads data is lower risk than one that can create, update, or delete records.

  3. Give tokens descriptive names — Label each token clearly on the Developers page so you can identify and revoke them easily later.

  4. Create one token per tool — That way you can revoke a specific integration without affecting others. You cannot unsend data that has already been shared, but you can always cut off future access.

  5. Understand what you're sharing — The more data you send to a third-party service, the more carefully you should review that service's privacy and data-retention policies.

Starter ideas

If you want to experiment, here are a few low-risk starting points:

  1. Ask an MCP-connected assistant to summarize your spending by category for the current month.
  2. Use an AI coding assistant to help write a script that lists all uncategorized transactions.
  3. Generate a simple monthly cash-flow report from your API data.
  4. Ask for patterns in merchant names that might deserve new rules or categories.
  5. Build a reusable "money questions" notebook with prompts you revisit each month.

Start small, and use a test budget while you're learning.

Need Help?