Skip to content

Commit af5ef65

Browse files
committed
add local mcp notes + example tool query and response.
1 parent f905bde commit af5ef65

File tree

1 file changed

+346
-0
lines changed

1 file changed

+346
-0
lines changed

graphs/graph-mcp.mdx

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ usage requirements:
9696

9797
## Setup guide
9898

99+
### Running with Hypermode Graphs
100+
99101
When using Hypermode Graphs, the MCP configuration is available on the graph
100102
details screen in the console:
101103

@@ -130,6 +132,68 @@ Add the configuration to your AI assistant's settings:
130132
</Step>
131133
</Steps>
132134

135+
### Running with local Dgraph
136+
137+
You can also run MCP with your local Dgraph instance by starting the Alpha
138+
server with the `--mcp` flag:
139+
140+
#### Starting Dgraph Alpha with MCP
141+
142+
```bash
143+
# Start Dgraph Zero
144+
dgraph zero --my=localhost:5080
145+
146+
# Start Dgraph Alpha with MCP enabled
147+
dgraph alpha --my=localhost:7080 --zero=localhost:5080 --mcp
148+
```
149+
150+
This enables two MCP endpoints on your Alpha server:
151+
152+
- **Full access**: `http://localhost:8080/mcp/sse`
153+
- **Read-only**: `http://localhost:8080/mcp-ro/sse`
154+
155+
#### Configure AI assistant for local Dgraph
156+
157+
```json
158+
{
159+
"mcpServers": {
160+
"dgraph-local": {
161+
"command": "npx",
162+
"args": ["mcp-remote", "http://localhost:8080/mcp/sse"]
163+
},
164+
"dgraph-local-readonly": {
165+
"command": "npx",
166+
"args": ["mcp-remote", "http://localhost:8080/mcp-ro/sse"]
167+
}
168+
}
169+
}
170+
```
171+
172+
#### Standalone MCP server
173+
174+
For development or testing, you can also run a standalone MCP server:
175+
176+
```bash
177+
# Run standalone MCP server
178+
dgraph mcp --conn-str="dgraph://localhost:9080"
179+
180+
# Run in read-only mode
181+
dgraph mcp --conn-str="dgraph://localhost:9080" --read-only
182+
```
183+
184+
For standalone servers, configure your AI assistant with:
185+
186+
```json
187+
{
188+
"mcpServers": {
189+
"dgraph-standalone": {
190+
"command": "dgraph",
191+
"args": ["mcp", "--conn-str=dgraph://localhost:9080"]
192+
}
193+
}
194+
}
195+
```
196+
133197
## Available capabilities
134198

135199
```mermaid
@@ -202,6 +266,60 @@ The Hypermode Graph MCP server provide the following tools:
202266

203267
Retrieve the current schema of your graph database.
204268

269+
##### Example schema query
270+
271+
**User request:**
272+
273+
```text
274+
"What's the current schema for our financial data model?"
275+
```
276+
277+
**Tool call:**
278+
279+
```json
280+
{
281+
"name": "get_schema",
282+
"arguments": {}
283+
}
284+
```
285+
286+
**Response:**
287+
288+
```json
289+
{
290+
"schema": [
291+
{
292+
"predicate": "account_number",
293+
"type": "string",
294+
"index": true,
295+
"tokenizer": ["exact"]
296+
},
297+
{
298+
"predicate": "balance",
299+
"type": "float"
300+
},
301+
{
302+
"predicate": "amount",
303+
"type": "float"
304+
},
305+
{
306+
"predicate": "status",
307+
"type": "string",
308+
"index": true,
309+
"tokenizer": ["exact"]
310+
},
311+
{
312+
"predicate": "from_account",
313+
"type": "uid"
314+
},
315+
{
316+
"predicate": "to_account",
317+
"type": "uid"
318+
}
319+
]
320+
}
321+
```
322+
205323
#### `run_query`
206324

207325
Run a DQL query on your graph database.
@@ -210,6 +328,63 @@ Run a DQL query on your graph database.
210328

211329
- `query` (string): DQL query to execute
212330

331+
##### Example query
332+
333+
**User request:**
334+
335+
```text
336+
"Show me all pending transactions and their amounts"
337+
```
338+
339+
**Tool call:**
340+
341+
```json
342+
{
343+
"name": "run_query",
344+
"arguments": {
345+
"query": "{
346+
transactions(func: eq(status, \"pending\")) {
347+
uid
348+
amount
349+
status
350+
timestamp
351+
from_account {
352+
account_number
353+
balance
354+
}
355+
to_account {
356+
account_number
357+
balance
358+
}
359+
}
360+
}"
361+
}
362+
}
363+
```
364+
365+
**Response:**
366+
367+
```json
368+
{
369+
"transactions": [
370+
{
371+
"uid": "0x1a",
372+
"amount": 150.5,
373+
"status": "pending",
374+
"timestamp": "2024-06-06T10:30:00Z",
375+
"from_account": {
376+
"account_number": "ACC001",
377+
"balance": 2500.0
378+
},
379+
"to_account": {
380+
"account_number": "ACC002",
381+
"balance": 1800.0
382+
}
383+
}
384+
]
385+
}
386+
```
387+
213388
#### `run_mutation`
214389

215390
Run a DQL mutation on your graph database.
@@ -218,6 +393,47 @@ Run a DQL mutation on your graph database.
218393

219394
- `mutation` (string): DQL mutation to execute
220395

396+
##### Example mutation
397+
398+
**User request:**
399+
400+
```text
401+
"Process a $500 transfer from account ACC001 to account ACC003"
402+
```
403+
404+
**Tool call:**
405+
406+
```json
407+
{
408+
"name": "run_mutation",
409+
"arguments": {
410+
"mutation": "{
411+
\"set\": [
412+
{
413+
\"uid\": \"_:txn\",
414+
\"dgraph.type\": \"Transaction\",
415+
\"amount\": 500.00,
416+
\"status\": \"pending\",
417+
\"timestamp\": \"2024-06-06T11:15:00Z\",
418+
\"from_account\": {
419+
\"uid\": \"0x10\"
420+
},
421+
\"to_account\": {
422+
\"uid\": \"0x11\"
423+
}
424+
}
425+
]
426+
}"
427+
}
428+
}
429+
```
430+
431+
**Response:**
432+
433+
```text
434+
Mutation completed, 1 UIDs created
435+
```
436+
221437
#### `alter_schema`
222438

223439
Modify the DQL schema of your graph database.
@@ -226,6 +442,34 @@ Modify the DQL schema of your graph database.
226442

227443
- `schema` (string): DQL schema to apply
228444

445+
##### Example schema update
446+
447+
**User request:**
448+
449+
```text
450+
"Add support for transaction fees and currency types to our payment system"
451+
```
452+
453+
**Tool call:**
454+
455+
```json
456+
{
457+
"name": "alter_schema",
458+
"arguments": {
459+
"schema": "transaction_fee: float .
460+
currency: string @index(exact) .
461+
exchange_rate: float .
462+
fee_type: string @index(term) ."
463+
}
464+
}
465+
```
466+
467+
**Response:**
468+
469+
```text
470+
Schema updated successfully
471+
```
472+
229473
#### `get_common_queries`
230474

231475
Provides reference queries to aid in query syntax.
@@ -255,6 +499,108 @@ Pre-configured prompt templates for common graph operations:
255499

256500
A quickstart prompt for getting started with graph MCP.
257501

502+
## Example tool interactions
503+
504+
Here are additional examples of AI assistant interactions with the MCP tools
505+
using a financial transaction theme:
506+
507+
### Complex transaction analysis
508+
509+
**User request:**
510+
511+
```text
512+
"Find all high-value transactions over $1000 from the last week and show
513+
which accounts were involved"
514+
```
515+
516+
**Tool call:**
517+
518+
```json
519+
{
520+
"name": "run_query",
521+
"arguments": {
522+
"query": "{
523+
high_value_txns(func: ge(amount, 1000.0))
524+
@filter(ge(timestamp, \"2024-05-30T00:00:00Z\")) {
525+
uid
526+
amount
527+
timestamp
528+
status
529+
from_account {
530+
account_number
531+
account_holder
532+
balance
533+
}
534+
to_account {
535+
account_number
536+
account_holder
537+
balance
538+
}
539+
}
540+
}"
541+
}
542+
}
543+
```
544+
545+
**Response:**
546+
547+
```json
548+
{
549+
"high_value_txns": [
550+
{
551+
"uid": "0x2b",
552+
"amount": 2500.0,
553+
"timestamp": "2024-06-05T14:22:00Z",
554+
"status": "completed",
555+
"from_account": {
556+
"account_number": "ACC005",
557+
"account_holder": "Tech Corp Ltd",
558+
"balance": 45000.0
559+
},
560+
"to_account": {
561+
"account_number": "ACC007",
562+
"account_holder": "Supplier Inc",
563+
"balance": 12000.0
564+
}
565+
}
566+
]
567+
}
568+
```
569+
570+
### Account balance updates
571+
572+
**User request:**
573+
574+
```text
575+
"Update account ACC001's balance to $3000 after processing pending
576+
transactions"
577+
```
578+
579+
**Tool call:**
580+
581+
```json
582+
{
583+
"name": "run_mutation",
584+
"arguments": {
585+
"mutation": "{
586+
\"set\": [
587+
{
588+
\"uid\": \"0x10\",
589+
\"balance\": 3000.00,
590+
\"last_updated\": \"2024-06-06T11:30:00Z\"
591+
}
592+
]
593+
}"
594+
}
595+
}
596+
```
597+
598+
**Response:**
599+
600+
```text
601+
Mutation completed, 1 UIDs created
602+
```
603+
258604
## Example workflows
259605

260606
### Exploratory data analysis

0 commit comments

Comments
 (0)