Skip to content

Commit a1db112

Browse files
committed
#3536 doc: add mcp JSON examples
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent f8468e8 commit a1db112

1 file changed

Lines changed: 124 additions & 0 deletions

File tree

webpage/src/editor/ai.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,127 @@ All requests must include the header:
6363
```
6464
Authorization: Bearer <your-security-token>
6565
```
66+
67+
### Example `curl` Requests
68+
69+
Set the token and port first:
70+
71+
```bash
72+
export TOKEN="your-mcp-token"
73+
export PORT=22226
74+
```
75+
76+
Open the SSE stream in one terminal:
77+
78+
```bash
79+
curl -N \
80+
-H "Accept: text/event-stream" \
81+
-H "Authorization: Bearer $TOKEN" \
82+
"http://localhost:$PORT/sse"
83+
```
84+
85+
The server will send an `endpoint` event containing a URL like:
86+
87+
```text
88+
event: endpoint
89+
data: http://localhost:22226/message?sessionId=3d8c7b0e-...
90+
```
91+
92+
Use the `sessionId` from that event in the following requests. The `POST` request itself returns
93+
`202 Accepted`; the JSON-RPC response is delivered over the SSE stream.
94+
95+
Initialize the MCP session:
96+
97+
```bash
98+
curl \
99+
-X POST \
100+
-H "Content-Type: application/json" \
101+
-H "Authorization: Bearer $TOKEN" \
102+
--data '{
103+
"jsonrpc": "2.0",
104+
"id": 1,
105+
"method": "initialize",
106+
"params": {}
107+
}' \
108+
"http://localhost:$PORT/message?sessionId=3d8c7b0e-..."
109+
```
110+
111+
List the available MCP tools:
112+
113+
```bash
114+
curl \
115+
-X POST \
116+
-H "Content-Type: application/json" \
117+
-H "Authorization: Bearer $TOKEN" \
118+
--data '{
119+
"jsonrpc": "2.0",
120+
"id": 2,
121+
"method": "tools/list",
122+
"params": {}
123+
}' \
124+
"http://localhost:$PORT/message?sessionId=3d8c7b0e-..."
125+
```
126+
127+
Search notes:
128+
129+
```bash
130+
curl \
131+
-X POST \
132+
-H "Content-Type: application/json" \
133+
-H "Authorization: Bearer $TOKEN" \
134+
--data '{
135+
"jsonrpc": "2.0",
136+
"id": 3,
137+
"method": "tools/call",
138+
"params": {
139+
"name": "search_notes",
140+
"arguments": {
141+
"query": "meeting notes",
142+
"limit": 5
143+
}
144+
}
145+
}' \
146+
"http://localhost:$PORT/message?sessionId=3d8c7b0e-..."
147+
```
148+
149+
Fetch a note by name:
150+
151+
```bash
152+
curl \
153+
-X POST \
154+
-H "Content-Type: application/json" \
155+
-H "Authorization: Bearer $TOKEN" \
156+
--data '{
157+
"jsonrpc": "2.0",
158+
"id": 4,
159+
"method": "tools/call",
160+
"params": {
161+
"name": "fetch_note",
162+
"arguments": {
163+
"name": "Daily Journal"
164+
}
165+
}
166+
}' \
167+
"http://localhost:$PORT/message?sessionId=3d8c7b0e-..."
168+
```
169+
170+
Fetch a note by ID:
171+
172+
```bash
173+
curl \
174+
-X POST \
175+
-H "Content-Type: application/json" \
176+
-H "Authorization: Bearer $TOKEN" \
177+
--data '{
178+
"jsonrpc": "2.0",
179+
"id": 5,
180+
"method": "tools/call",
181+
"params": {
182+
"name": "fetch_note",
183+
"arguments": {
184+
"id": 123
185+
}
186+
}
187+
}' \
188+
"http://localhost:$PORT/message?sessionId=3d8c7b0e-..."
189+
```

0 commit comments

Comments
 (0)