|
| 1 | +--- |
| 2 | +title: ArangoDB Model Context Protocol (MCP) Server |
| 3 | +menuTitle: MCP Server |
| 4 | +weight: 10 |
| 5 | +description: >- |
| 6 | + A Model Context Protocol server for generating and executing AQL queries using AI assistants like Claude and Cursor IDE |
| 7 | +--- |
| 8 | +The ArangoDB MCP Server is a focused [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) implementation that enables AI assistants to generate and execute AQL queries based on natural language questions. It includes lightweight schema discovery and manuals to ground queries in actual database structure. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +**AQL Generation & Execution:** |
| 13 | +- Generate AQL grounded in actual database structure |
| 14 | +- Execute AQL with optional bind variables and target database |
| 15 | + |
| 16 | +**Manuals for Guidance:** |
| 17 | +- AQL reference and optimization guides built-in |
| 18 | +- Context-aware query generation |
| 19 | + |
| 20 | +**Lightweight Schema Discovery:** |
| 21 | +- List collections within accessible databases |
| 22 | +- Sample documents via simple filters to learn fields |
| 23 | + |
| 24 | +## What You Can Do |
| 25 | + |
| 26 | +The server is purpose-built for safe, read-focused AQL operations: |
| 27 | +- Execute AQL queries with optional bind variables and target database |
| 28 | +- Access built-in manuals for syntax and optimization guidance |
| 29 | +- Discover database schemas and collection structures |
| 30 | +- Sample documents to understand field structures |
| 31 | + |
| 32 | +The following are not included: |
| 33 | +- Graph/view/index/analyzer management tools |
| 34 | +- Destructive admin operations (create/delete databases or collections) |
| 35 | + |
| 36 | +## Installation |
| 37 | + |
| 38 | +The ArangoDB MCP Server is available as a Docker image on Docker Hub: [arangodb/mcp-arangodb](https://hub.docker.com/r/arangodb/mcp-arangodb) |
| 39 | + |
| 40 | +See the Docker Hub page for installation and usage instructions. |
| 41 | + |
| 42 | +## Available Tools |
| 43 | + |
| 44 | +The MCP server exposes four main tools that AI assistants can use to interact with your ArangoDB database. |
| 45 | + |
| 46 | +### `get-aql-manual` |
| 47 | + |
| 48 | +Retrieves built-in documentation for AQL syntax and optimization. |
| 49 | + |
| 50 | +**Parameters:** |
| 51 | +- `manual_name` (required): Either `aql_ref` or `optimization`. |
| 52 | + |
| 53 | +**Use when:** You need reference documentation for writing AQL queries. |
| 54 | + |
| 55 | +### `fetch-schemas` |
| 56 | + |
| 57 | +Lists all collections in a database (non-system collections only). |
| 58 | + |
| 59 | +**Parameters:** |
| 60 | +- `database_name` (optional): Target database. Uses configured default if not specified. |
| 61 | + |
| 62 | +**Use when:** You need to discover what collections exist in your database. |
| 63 | + |
| 64 | +### `read-documents-with-filter` |
| 65 | + |
| 66 | +Samples documents from a collection using simple equality filters. |
| 67 | + |
| 68 | +**Parameters:** |
| 69 | +- `collection_name` (required): Name of the collection to query. |
| 70 | +- `filters` (required): Filter conditions as key-value pairs. |
| 71 | +- `limit` (optional, default: 100): Maximum documents to return. |
| 72 | +- `skip` (optional, default: 0): Number of documents to skip (pagination). |
| 73 | + |
| 74 | +**Use when:** You want to explore document structure or find specific documents by exact field matches. |
| 75 | + |
| 76 | +### `execute-aql-query` |
| 77 | + |
| 78 | +Executes AQL queries with optional bind variables. |
| 79 | + |
| 80 | +**Parameters:** |
| 81 | +- `aql_query` (required): The AQL query to execute. |
| 82 | +- `bind_vars` (optional): Bind variables for parameterized queries. |
| 83 | +- `database_name` (optional): Target database. |
| 84 | + |
| 85 | +**Use when:** You need to run complex queries, aggregations, or graph traversals. |
| 86 | + |
| 87 | +## Workflow |
| 88 | + |
| 89 | +When working with the MCP server, AI assistants typically follow this pattern: |
| 90 | + |
| 91 | +1. **Discover**: Call `fetch-schemas()` to understand available collections. |
| 92 | +2. **Explore**: Use `read-documents-with-filter()` to see document structures. |
| 93 | +3. **Reference**: Call `get-aql-manual()` if complex query syntax is needed. |
| 94 | +4. **Execute**: Run queries with `execute-aql-query()` using bind variables for safety. |
| 95 | + |
| 96 | +## Practical Examples |
| 97 | + |
| 98 | +**Example 1: Exploring Your Database** |
| 99 | + |
| 100 | +*Prompt:* "Show me all collections in the database" |
| 101 | + |
| 102 | +The AI will call `fetch-schemas()` and display the available collections with their types and document counts. |
| 103 | + |
| 104 | +**Example 2: Finding Specific Records** |
| 105 | + |
| 106 | +*Prompt:* "Find all active users who are verified" |
| 107 | + |
| 108 | +The AI will: |
| 109 | +1. Confirm the `users` collection exists with `fetch-schemas()` |
| 110 | +2. Sample the structure with `read-documents-with-filter()` |
| 111 | +3. Generate and execute an AQL query: |
| 112 | + ```aql |
| 113 | + FOR user IN users |
| 114 | + FILTER user.status == "active" AND user.verified == true |
| 115 | + RETURN user |
| 116 | + ``` |
| 117 | + |
| 118 | +**Example 3: Complex Graph Traversal** |
| 119 | + |
| 120 | +*Prompt:* "Find all friends of friends for user 'john' up to 3 levels deep" |
| 121 | + |
| 122 | +The AI will: |
| 123 | +1. Retrieve the AQL reference manual for graph traversal syntax |
| 124 | +2. Identify edge collections using `fetch-schemas()` |
| 125 | +3. Generate an optimized graph query: |
| 126 | + ```aql |
| 127 | + FOR v, e, p IN 1..3 OUTBOUND 'users/john' friends |
| 128 | + RETURN DISTINCT v |
| 129 | + ``` |
| 130 | +4. Execute with appropriate bind variables for safety |
| 131 | + |
| 132 | +**Example 4: Data Analysis** |
| 133 | + |
| 134 | +*Prompt:* "What's the average age of users by country?" |
| 135 | + |
| 136 | +The AI will generate and execute an aggregation query: |
| 137 | +```aql |
| 138 | +FOR user IN users |
| 139 | +COLLECT country = user.address.country |
| 140 | +AGGREGATE avgAge = AVG(user.age) |
| 141 | +RETURN { country, avgAge } |
| 142 | +``` |
| 143 | + |
0 commit comments