.. MCP Send Mail
Create an MCP service with NL
In this demo, we will use Natural Language (NL) to create an MCP service (send email):
-
Create From Existing DB: a CLI command creates an MCP-enabled API and an Admin App
- Verify MCP: using your AI Assistant
-
Declare Business Logic: no-bypass governance using natural language logic and rules
- Create an email service: add logic to create an audited email service
- MCP Client: enable business users to invoke services with natural language, here via the automatically created Admin App (or, use your own app):

Please load `.github/.copilot-instructions.md`
Important: be sure CoPilot is in "Agent" Mode. "Ask" will not work. Also, we get consistently good results with
Claude Sonnet 4.6.
How to Use This Demo
This demo teaches AI-assisted development patterns. Each step is a natural language prompt you copy/paste into Copilot chat. The prompts are self-documenting - they explain what they do.
You may prefer to view this guide in the browser; click here.
Vibe Philosophy: AI makes errors. That's expected. When something fails, tell Copilot: "Error X occurred, fix it". Copilot is exceptionally good at finding and correcting its own mistakes.
Recommended Path: If you're new to GenAI-Logic, start with the Standard Demo (creates basic_demo with guided tutor) to learn platform fundamentals. Then return here to explore AI-assisted development with basic_demo_vibe.
1. Create From Existing DB
Create the Customer, Orders, and Product Project [typically already done using Manager]
Create a database project named basic_demo_vibe from samples/dbs/basic_demo.sqlite
Your project includes a data model diagram

1a. Project Opens: Run
The project should automatically open a new window in VSCode.
Please load `.github/.copilot-instructions.md`.
Run it as follows:
- Start the Server: F5
- Start the Admin App: browse to http://localhost:5656/. The Admin App screen shown below should appear in your Browser.
- Verify as shown below
API: filtering, sorting, pagination, optimistic locking,related data access... see Swagger
Your API is MCP enabled, and ready for custom app dev. For more information, click here.

Admin App: multi-page, multi-table, automatic joins, lookups, cascade add - collaboration-ready
For more information, click here.
The Admin App is ready for business user agile collaboration, and back office data maintenance. This complements custom UIs created with the API.
Explore the app - click Customer Alice, and see their Orders, and Items.

1a. Verify MCP
Project creation builds an MDA-enabled API. To verify it, paste into your AI Assistant:
you should see:
| ID | Name | Balance | Credit Limit |
|---|---|---|---|
| 3 | Charlie | $220.00 | $2,000.00 |
| 5 | Silent | $220.00 | $1,000.00 |
| 1 | Alice | $90.00 | $5,000.00 |
2. Declare Business Logic
Since MCP Access include update operations, is is critical to provide governance: business logic that cannot be by-passed.
Such logic (multi-table derivations and constraints) is a significant portion of a system, typically nearly half. GenAI-Logic provides spreadsheet-like rules that dramatically simplify and accelerate logic development.
You can declare such logic in 2 ways:
- Use Natural Language, as shown in the code sample below. The screenshot shows the 5 rules for Check Credit Logic.
- Or, declare rules directly in Python, simplified with IDE code completion.
To declare logic:
1. Stop the Server (Red Stop button, or Shift-F5 -- see Appendix)
2. Add Business Logic: paste the following into your AI Assistant:
on Placing Orders, Check Credit
1. The Customer's balance is less than the credit limit
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
3. The Order's amount_total is the sum of the Item amount
4. The Item amount is the quantity * unit_price
5. The Item unit_price is copied from the Product unit_price
Use case: App Integration
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
In either case, the result is the same:

To test the logic:
1. Use the Admin App to access the first order for Customer Alice
2. Edit its first item to a very high quantity
The update is properly rejected because it exceeds the credit limit. Observe the rules firing in the console log - see Logic In Action, below.
Logic is critical - half the effort; Declarative is 40X More Concise, Maintainable
Logic is critical to your system - it represents nearly half the effort. Instead of procedural code, declare logic with WebGenAI, or in your IDE using code completion or Natural Language as shown above.
a. 40X More Concise
The 5 spreadsheet-like rules represent the same logic as 200 lines of code, shown here. That's a remarkable 40X decrease in the backend half of the system.
💡 No FrankenCode
Note the rules look like syntactically correct requirements. They are not turned into piles of unmanageable "frankencode" - see models not frankencode.
b. Maintainable: Debugging, Logging
The screenshot below shows our logic declarations, and the logging for inserting an Item. Each line represents a rule firing, and shows the complete state of the row.
Note that it's a Multi-Table Transaction, as indicated by the indentation. This is because - like a spreadsheet - rules automatically chain, including across tables.

3. Create the email Service
The server is automatically mcp-enabled, but we also require a user-interface to enable business users to send email, subject to business logic for customer email opt-outs. Build it with Natural Language as follows:
1. Stop the Server: click the red stop icon 🟥 or press Shift+F5.
We use the Request Pattern to send emails, via Copilot (in conjunction with substantial Context Engineering in your project at .github/.copilot-instructions.md and docs/training):
Create a table SysEmail in `database/db.sqlite` as a child of customer,
with columns id, message, subject, customer_id and CreatedOn.
Follow the suggestions to update the admin app.
Ask it to do so if it fails to offer the suggestion.
Request objects are a common rule pattern - for more information, click here.
Add an after_flush event on SysEmail to produce a log message "email sent",
unless the customer has opted out.
Inserts into SysEmail will now send mails (stubbed here with a log message).
4. MCP Client Executor
Your project is pre-created with integration/mcp/mcp_client_executor.py, which processes MCP requests.
MCP Clients accept MCP Requests, invoke the LLM to obtain a series of API calls to run, and runs them. For more on MCP, click here.
To activate the MCP Client Executor:
Context Engineering has trained Copilot to use (again) the Request Pattern:
- Creates the
SysMcprequest object (new table, also added to Admin App) -
Creates Request Implementation:
logic/logic_discovery/send_email.py, which provides anafter_flush_row_eventonSysMcpto invokeintegration/mcp/mcp_client_executor.py.
Creates logic like this
When sending email, we require business rules to ensure it respects the opt-out policy:

5. Test in the Admin App
1. Restart the Server and Start the Admin App
List the orders date_shipped is null and CreatedOn before 2023-07-14,
and send a discount email (subject: 'Discount Offer')
to the customer for each one.

