Skip to main content
Use MCP when you want the MKA1 API to answer from a PostgreSQL database you already run. The model queries the database when a question needs it, so answers use current data and PostgreSQL computes the filters, joins and totals. You do three things:
  1. Create a read-only database role for the model.
  2. Run an MCP server in front of the database.
  3. Register the server on the MKA1 API and reference it from a response or an agent.
API Reference:

1. Create a read-only database role

The database role decides what the model can read. Grant it SELECT on the schemas the model may query, and nothing else.
SQL
Use views to expose some columns of a table and not others.

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
server.mjs
Save both files on a host that can reach the database, then start the server:
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.
The response includes the server ID, such as mcp_srv_.... Store the server’s token as a credential. The vault encrypts it and never returns it.
The response includes the credential ID, such as mcp_cred_....

4. Test the connection

Ask the MKA1 API to connect to your server and discover its tools.
A successful test lists the three tools:
Response
A failed connection returns HTTP 502. Check the URL, the public address and the token.

5. Ask a question

Reference the registered server in the tools of a response. Tell the model what the database holds in instructions.
The model calls 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_approval to "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.