- Create a read-only database role for the model.
- Run an MCP server in front of the database.
- Register the server on the MKA1 API and reference it from a response or an agent.
1. Create a read-only database role
The database role decides what the model can read. Grant itSELECT on the schemas the model may query, and nothing else.
SQL
2. Run the MCP server
The MCP server sits between the MKA1 API and your database. It connects with the read-only role and offers the model three tools:
You can run any MCP server that speaks Streamable HTTP.
This one is a complete example in a single file. It needs Node.js 20 or later.
package.json
package.json
package.json
server.mjs
server.mjs
server.mjs
Bash
MCP_AUTH_TOKEN is a secret you generate. The MKA1 API presents it on every call.
The server also accepts PORT (default 3000), MAX_ROWS (default 200) and QUERY_TIMEOUT_MS (default 10000).
The server only reads: every statement runs in a read-only transaction, query accepts a single SELECT, and results are capped and timed.
The MKA1 API calls your server over the internet, so publish it this way:
- Serve it over HTTPS, behind your load balancer or reverse proxy.
- Give it a hostname that resolves to a public address. The MKA1 API does not connect to private addresses.
- Keep the path
/mcp.
3. Register the server
Register the server once in the MCP vault.mcp_srv_....
Store the server’s token as a credential.
The vault encrypts it and never returns it.
mcp_cred_....
4. Test the connection
Ask the MKA1 API to connect to your server and discover its tools.Response
5. Ask a question
Reference the registered server in thetools of a response.
Tell the model what the database holds in instructions.
list_tables and describe_table to learn the schema, then calls query with the SQL it wrote.
Each call and its result appear in the response output, followed by the model’s answer.
The query tool returns the rows with the name and PostgreSQL type of every column:
Query result
bigint and numeric values arrive as strings, so large and decimal numbers keep their exact value.
truncated is true when more rows matched than MAX_ROWS.
You can also pass
server_url and headers in the tool definition without registering the server. See Use MCP tools.Next steps
- Use the same tool definition in a saved agent. See Build an agent with MCP tools.
- Set
require_approvalto"always"when a person should confirm each query before it runs. See Require end-user approval. - Give each end user their own access by storing one credential per end user with
X-On-Behalf-Of. See Store the MCP credential. - Rotate the token by starting the server with a new
MCP_AUTH_TOKEN, creating a new credential, and deleting the old one.