Skip to content

Commit fbd039e

Browse files
committed
mcp docs: add example responses
1 parent 8d87f45 commit fbd039e

File tree

2 files changed

+111
-28
lines changed

2 files changed

+111
-28
lines changed

doc/user/content/integrations/llm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: MCP Server
2+
title: MCP Server (Python)
33
description: "Learn how to integrate Materialize with Large Language Models (LLMs) using MCP"
44
make_table_row_headers_searchable: true
55
menu:

doc/user/content/integrations/mcp.md

Lines changed: 110 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ menu:
1111
Materialize includes built-in [Model Context Protocol
1212
(MCP)](https://modelcontextprotocol.io/) endpoints that let AI agents discover
1313
and query your real-time data products over HTTP. No sidecar process or external
14-
server is required — the MCP interface is served directly by the database.
14+
server is required. The MCP interface is served directly by the database.
1515

1616
Two endpoints are available:
1717

18-
| Endpoint | Path | Purpose |
19-
|----------|------|---------|
20-
| **Agents** | `/api/mcp/agents` | Discover and read data products (indexed views with comments). Designed for customer-facing AI agents. |
21-
| **Observatory** | `/api/mcp/observatory` | Query `mz_*` system catalog tables for troubleshooting and observability. |
18+
| Endpoint | Path | Description |
19+
|----------|------|-------------|
20+
| **Agents** | `/api/mcp/agents` | Discover and read data products (indexed views with comments). Designed for customer-facing AI agents. Available on the HTTP port (default `6876`). |
21+
| **Observatory** | `/api/mcp/observatory` | Query `mz_*` system catalog tables for troubleshooting and observability. Available on the HTTP port (default `6876`). |
2222

2323
Both endpoints speak [JSON-RPC 2.0](https://www.jsonrpc.org/specification) over
2424
HTTP POST and support the MCP `initialize`, `tools/list`, and `tools/call`
@@ -40,28 +40,23 @@ Use the credentials of a Materialize user or
4040
* **User ID:** Your email address or service account name.
4141
* **Password:** An [app password](/security/cloud/users-service-accounts/create-service-accounts/).
4242

43-
```
44-
https://<region-host>/api/mcp/agents
45-
```
46-
4743
For production use, we recommend creating a dedicated service account and
4844
granting it a role with [limited privileges](#rbac).
4945

5046
{{< /tab >}}
5147

5248
{{< tab "Self-Managed" >}}
5349

54-
Use the credentials of a Materialize role with `LOGIN`:
50+
Create a functional role for MCP privileges, then assign it to a login role:
5551

5652
```mzsql
57-
CREATE ROLE mcp_agent LOGIN PASSWORD 'secret';
53+
CREATE ROLE mcp_agent;
54+
CREATE ROLE my_agent LOGIN PASSWORD 'secret';
55+
GRANT mcp_agent TO my_agent;
5856
```
5957

60-
The MCP endpoints are available on the HTTP listener port (default `6876`):
61-
62-
```
63-
http://<host>:6876/api/mcp/agents
64-
```
58+
Authenticate using the login role credentials (`my_agent`). You can create
59+
additional login roles and grant them the same `mcp_agent` role as needed.
6560

6661
{{< /tab >}}
6762

@@ -100,25 +95,25 @@ CREATE MATERIALIZED VIEW mcp_schema.payment_status AS
10095
FROM orders
10196
JOIN payments USING (order_id);
10297
103-
CREATE INDEX ON mcp_schema.payment_status (order_id);
98+
CREATE INDEX payment_status_order_id_idx ON mcp_schema.payment_status (order_id);
10499
```
105100

106101
### 3. Add a comment
107102

108-
The top-level comment becomes the tool's description. Column comments become
109-
parameter descriptions. Write comments that help a language model understand
110-
**when** and **how** to use the tool.
103+
The comment on the **index** becomes the data product's description. Column
104+
comments on the underlying view become parameter descriptions. Write comments
105+
that help a language model understand **when** and **how** to use the tool.
111106

112107
```mzsql
113-
COMMENT ON MATERIALIZED VIEW mcp_schema.payment_status IS
108+
COMMENT ON INDEX mcp_schema.payment_status_order_id_idx IS
114109
'Given an order ID, return the current payment status and last update time.
115110
Use this tool to drive user-facing payment tracking.';
116111
117112
COMMENT ON COLUMN mcp_schema.payment_status.order_id IS
118113
'The unique identifier for the order';
119114
```
120115

121-
### 4. Create a role and permissions for your agent {#rbac}
116+
## Create a role and permissions for your agent {#rbac}
122117

123118
The role used to authenticate with the MCP endpoint must have:
124119

@@ -190,18 +185,54 @@ following tools:
190185

191186
### `get_data_products`
192187

193-
Discover all available data products. Returns a list of names and descriptions.
188+
Discover all available data products. Returns a lightweight list with name,
189+
cluster, and description for each product.
194190

195191
**Parameters:** None.
196192

193+
**Example response:**
194+
195+
```json
196+
{
197+
"jsonrpc": "2.0",
198+
"id": 1,
199+
"result": {
200+
"content": [
201+
{
202+
"type": "text",
203+
"text": "[\n [\n \"\\\"materialize\\\".\\\"mcp_schema\\\".\\\"payment_status\\\"\",\n \"mcp_cluster\",\n \"Given an order ID, return the current payment status.\"\n ]\n]"
204+
}
205+
]
206+
}
207+
}
208+
```
209+
197210
### `get_data_product_details`
198211

199-
Get the full schema (columns, types, index keys) for a specific data product.
212+
Get the full details for a specific data product, including its JSON schema
213+
with column names, types, and descriptions.
200214

201215
| Parameter | Type | Required | Description |
202216
|-----------|------|----------|-------------|
203217
| `name` | string | Yes | Exact name from the `get_data_products` list. |
204218

219+
**Example response:**
220+
221+
```json
222+
{
223+
"jsonrpc": "2.0",
224+
"id": 1,
225+
"result": {
226+
"content": [
227+
{
228+
"type": "text",
229+
"text": "[\n [\n \"\\\"materialize\\\".\\\"mcp_schema\\\".\\\"payment_status\\\"\",\n \"mcp_cluster\",\n \"Given an order ID, return the current payment status.\",\n \"{\\\"order_id\\\": {\\\"type\\\": \\\"integer\\\", \\\"position\\\": 1}, \\\"status\\\": {\\\"type\\\": \\\"text\\\", \\\"position\\\": 3}}\"\n ]\n]"
230+
}
231+
]
232+
}
233+
}
234+
```
235+
205236
### `read_data_product`
206237

207238
Read rows from a data product.
@@ -212,6 +243,23 @@ Read rows from a data product.
212243
| `limit` | integer | No | Maximum rows to return. Default: 500, max: 1000. |
213244
| `cluster` | string | No | Cluster override. If omitted, uses the cluster from the catalog. |
214245

246+
**Example response:**
247+
248+
```json
249+
{
250+
"jsonrpc": "2.0",
251+
"id": 1,
252+
"result": {
253+
"content": [
254+
{
255+
"type": "text",
256+
"text": "[\n [\n 1001,\n 42,\n \"shipped\",\n \"2026-03-26T10:30:00Z\"\n ]\n]"
257+
}
258+
]
259+
}
260+
}
261+
```
262+
215263
### `query`
216264

217265
{{< note >}}
@@ -226,6 +274,23 @@ Execute a SQL `SELECT` statement against your data products.
226274
| `cluster` | string | Yes | Exact cluster name from the data product details. |
227275
| `sql_query` | string | Yes | PostgreSQL-compatible `SELECT` statement. |
228276

277+
**Example response:**
278+
279+
```json
280+
{
281+
"jsonrpc": "2.0",
282+
"id": 1,
283+
"result": {
284+
"content": [
285+
{
286+
"type": "text",
287+
"text": "[\n [\n 42,\n \"shipped\"\n ]\n]"
288+
}
289+
]
290+
}
291+
}
292+
```
293+
229294
## Observatory endpoint
230295

231296
**`POST /api/mcp/observatory`**
@@ -241,6 +306,23 @@ Execute a SQL query restricted to `mz_*` system tables.
241306
|-----------|------|----------|-------------|
242307
| `sql_query` | string | Yes | `SELECT` query using only `mz_*` system tables. |
243308

309+
**Example response:**
310+
311+
```json
312+
{
313+
"jsonrpc": "2.0",
314+
"id": 1,
315+
"result": {
316+
"content": [
317+
{
318+
"type": "text",
319+
"text": "[\n [\n \"quickstart\",\n \"ready\"\n ],\n [\n \"mcp_cluster\",\n \"ready\"\n ]\n]"
320+
}
321+
]
322+
}
323+
}
324+
```
325+
244326
## Client configuration
245327

246328
Replace `<host>` with your Materialize hostname (or region host for Cloud) and
@@ -449,9 +531,10 @@ MCP endpoints can be toggled at runtime using system parameters:
449531

450532
| Parameter | Default | Description |
451533
|-----------|---------|-------------|
452-
| `enable_mcp_agents` | `true` | Enable or disable the `/api/mcp/agents` endpoint. |
453-
| `enable_mcp_observatory` | `true` | Enable or disable the `/api/mcp/observatory` endpoint. |
534+
| `enable_mcp_agents` | `false` | Enable or disable the `/api/mcp/agents` endpoint. |
535+
| `enable_mcp_observatory` | `false` | Enable or disable the `/api/mcp/observatory` endpoint. |
454536
| `enable_mcp_agents_query_tool` | `false` | Show or hide the `query` tool on the agents endpoint. |
537+
| `mcp_max_response_size` | `1000000` | Maximum response size in bytes. Queries exceeding this limit return an error. |
455538

456539
```mzsql
457540
-- Disable the agents endpoint
@@ -465,7 +548,7 @@ When an endpoint is disabled, requests return HTTP 503 (Service Unavailable).
465548

466549
## Related Pages
467550

468-
- [MCP Server (Python)](/integrations/llm/) standalone Python MCP server
551+
- [MCP Server (Python)](/integrations/llm/): standalone Python MCP server
469552
for `stdio` and `sse` transports
470553
- [Coding Agent Skills](/integrations/coding-agent-skills/)
471554
- [CREATE INDEX](/sql/create-index)

0 commit comments

Comments
 (0)