Skip to content

Commit 1391e6a

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

File tree

2 files changed

+98
-18
lines changed

2 files changed

+98
-18
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: 97 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ 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

@@ -118,7 +113,7 @@ 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

@@ -194,6 +189,23 @@ Discover all available data products. Returns a list of names and descriptions.
194189

195190
**Parameters:** None.
196191

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

199211
Get the full schema (columns, types, index keys) for a specific data product.
@@ -202,6 +214,23 @@ Get the full schema (columns, types, index keys) for a specific data product.
202214
|-----------|------|----------|-------------|
203215
| `name` | string | Yes | Exact name from the `get_data_products` list. |
204216

217+
**Example response:**
218+
219+
```json
220+
{
221+
"jsonrpc": "2.0",
222+
"id": 1,
223+
"result": {
224+
"content": [
225+
{
226+
"type": "text",
227+
"text": "[\n [\n \"order_id\",\n \"integer\",\n true\n ],\n [\n \"status\",\n \"text\",\n false\n ]\n]"
228+
}
229+
]
230+
}
231+
}
232+
```
233+
205234
### `read_data_product`
206235

207236
Read rows from a data product.
@@ -212,6 +241,23 @@ Read rows from a data product.
212241
| `limit` | integer | No | Maximum rows to return. Default: 500, max: 1000. |
213242
| `cluster` | string | No | Cluster override. If omitted, uses the cluster from the catalog. |
214243

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

217263
{{< note >}}
@@ -226,6 +272,23 @@ Execute a SQL `SELECT` statement against your data products.
226272
| `cluster` | string | Yes | Exact cluster name from the data product details. |
227273
| `sql_query` | string | Yes | PostgreSQL-compatible `SELECT` statement. |
228274

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

231294
**`POST /api/mcp/observatory`**
@@ -241,6 +304,23 @@ Execute a SQL query restricted to `mz_*` system tables.
241304
|-----------|------|----------|-------------|
242305
| `sql_query` | string | Yes | `SELECT` query using only `mz_*` system tables. |
243306

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

246326
Replace `<host>` with your Materialize hostname (or region host for Cloud) and
@@ -465,7 +545,7 @@ When an endpoint is disabled, requests return HTTP 503 (Service Unavailable).
465545

466546
## Related Pages
467547

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

0 commit comments

Comments
 (0)