Smart Invoice Generator
How to create a smart invoice generator with n8n, AI, and MCP

In the world of business automation, invoicing remains one of the most repetitive and error-prone tasks. That’s why I’ve developed a complete system that combines the power of n8n, artificial intelligence, and the MCP (Model Context Protocol) to create a fully automated invoice generator.
The problem it solves
Imagine having to manually generate invoices for each client: looking up their data, filling in fields, creating the PDF… A tedious process that consumes valuable time. My solution lets you simply enter a client's name and automatically receive a professional invoice in PDF format.
System architecture
Smart intent classifier
At the heart of the system is a classifier that uses the Gemini model to interpret what the user wants to do. This component analyzes the initial query and categorizes it into three types:
- CHAT: When the user has no clear intention to generate an invoice
- DATA: To create invoices for existing clients in the database
- MULTIUSER: When multiple clients need to be processed simultaneously
This initial classification is crucial because it determines the flow that the workflow will follow, optimizing the user experience.
Conversational agent
If the intent is CHAT, the system activates a specialized AI agent that naturally guides the user to get the client’s name. This agent is specifically trained for this task, making the interaction smooth and professional.
Custom MCP server
This is where things get interesting. I’ve developed an MCP server that acts as a bridge between the AI agent and the client database. This server:
- Connects directly to Google Sheets where I store client information
- Manages a table with structured columns: “name”, “Phone”, “Amount”, and “Service”
- Is configured to work seamlessly with Claude
The MCP protocol allows the language model to access external data securely and efficiently, which is revolutionary for this type of application.
Structured data processing
Once the agent retrieves the client’s data through the MCP server, a custom JSON parser comes into play. This component transforms the information into a structured format like this:
This structure ensures that all the necessary data is available for generating the invoice.
Automatic PDF generation
The final step is pure automation magic. The system:
-
Creates a copy of the predefined invoice template in Google Drive
-
Automatically replaces placeholder values with real client data
-
Converts the document into PDF format
-
Delivers the invoice ready to send
System advantages
-
Efficiency: What used to take hours is now done in seconds
-
Accuracy: Eliminates human errors in data transcription
-
Scalability: Can handle multiple clients at once
-
Flexibility: The intent classifier allows for different types of interactions
Technologies used
-
n8n: As the main automation platform
-
Gemini: For intent classification
-
MCP (Model Context Protocol): For secure connection with external data
-
Claude: As the main language model
-
Google Sheets: As the client database
-
Google Drive: For template storage and processing
Practical use cases
This system is perfect for freelancers, small businesses, and professionals who need to generate invoices regularly but don’t want to invest in expensive software. From masonry services to digital consulting, the system’s flexibility allows it to adapt to any industry.
Final conclusions
The combination of AI, automation, and modern protocols like MCP opens up a world of possibilities to optimize business processes. This invoice generator is just the beginning: the same techniques can be applied to quotes, reports, contracts, and any document that requires structured data. Smart automation is no longer the future — it’s the present. And with tools like n8n and MCP, it’s within reach of any developer eager to innovate.