Let an AI agent use your app safely with MCP
Giving an AI agent a database connection is the quick way to connect it to business data, and the risky one. This walkthrough connects an agent to an Evlet app through MCP, where it acts as one signed-in user and passes the same permission checks as the browser.
What the agent can and cannot do
- It calls a fixed set of tools: discover models, list and read records, totals, reports, and, if you allow it, create, update, move and delete.
- Every call goes through the same authenticated HTTP routes the browser uses. Row scopes, field rules and state rules apply.
- It has no SQL, no file system, no shell and no Python execution.
1. Start with a running site
This article uses the invoicing app from Build a small business app in Python with SQLite, running with evlet dev --instance acme on http://127.0.0.1:8000.
2. Sign in from the shell
mkdir -p ~/.evlet
chmod 700 ~/.evlet
evlet login --url http://127.0.0.1:8000 --username admin --session ~/.evlet/acme.session.jsonThe command asks for the password and saves a session file with private permissions. The password is not stored. The session follows the same expiry and revocation rules as a browser session.
Check what this account can see:
evlet describe --session ~/.evlet/acme.session.jsonYou get the models this user may reach, with the operations allowed on each. For the invoicing app that is customer and invoice.
3. See what happens before you allow MCP
MCP access is off for every user by default. If you connect a client now, each tool call is refused:
Your administrator hasn't allowed you to connect AI assistants.
Ask them to turn on Allow MCP for you in Controls.Open Controls, then Users, and turn on Allow MCP for the account. The setting grants no access to records. It only lets this person connect an assistant.
4. Add the server to your MCP client
Use your client's configuration for a local stdio server. The command and arguments are:
{
"command": "/absolute/path/to/.venv/bin/evlet",
"args": ["mcp", "--session", "/absolute/path/to/.evlet/acme.session.json"]
}Use absolute paths. The surrounding format depends on the client.
5. Ask a question
With the default settings, the tools the client receives are read tools:
discover_models, describe_model, list_records, get_record,
aggregate_records, record_history, job_statusAsk the assistant something like "Which invoices are still in draft?". It calls list_records on the invoice model and gets back only rows this user can read, with only the fields this user can read:
{
"items": [
{"number": "INV-2026-0004", "issued_on": "2026-11-17", "total": "454.00", "docstate": "draft"},
{"number": "INV-2026-0003", "issued_on": "2026-11-12", "total": "1118.00", "docstate": "issued"}
],
"total": 4, "limit": 2, "offset": 0
}6. Allowing changes, on purpose
Write tools appear only when an admin turns on writes for MCP in Controls. Even then:
- A change the user's role cannot make is refused at once.
- Moving a document, running an app action and deleting wait for the person's approval in Evlet, under Settings, AI assistants. The approval covers that one call, with those arguments, on that revision of the record.
- Only a signed-in browser session can approve. An assistant cannot approve its own request.
Every call, allowed or refused, is written to the Tool log in Controls with the user, the client, the tool and the outcome.
Remote MCP
For a hosted site, people add https://your-host/_/mcp as a custom connector in their assistant and sign in with their Evlet account. That endpoint uses OAuth 2.1 with PKCE, asks for consent each time, and is read-only unless both the instance and the person allow changes. The connector guide has the details.
Why this design
An agent that reads business records will meet text it should not trust: a customer name, a note, an uploaded file. If that text persuades the agent to do something, the damage is limited to what one user could do by hand, minus the steps that need a human approval. That is the reason the tools sit behind the same checks as the browser.
Read more on the AI and MCP page or in the Tool Engine guide.
Last updated . Checked against Evlet 0.4.3.