|
| 1 | +--- |
| 2 | +name: forest-mcp |
| 3 | +description: Query Forest Admin data through MCP tools. Use when the user wants to search, filter, or explore data from their Forest Admin database. Triggers on questions like "find all users", "show orders from last week", "how many products", or any data exploration request. |
| 4 | +--- |
| 5 | + |
| 6 | +# Forest Admin MCP |
| 7 | + |
| 8 | +Query Forest Admin data as if it were a database, with an abstraction layer that handles authentication, filtering, and relationships. |
| 9 | + |
| 10 | +## Available Tools |
| 11 | + |
| 12 | +| Tool | Purpose | |
| 13 | +|------|---------| |
| 14 | +| `describeCollection` | Get collection schema (fields, types, operators, relations) | |
| 15 | +| `list` | Query records from a collection | |
| 16 | +| `listRelated` | Query records from a one-to-many or many-to-many relation | |
| 17 | + |
| 18 | +## Workflow |
| 19 | + |
| 20 | +1. **Always start with `describeCollection`** to understand the collection structure before querying |
| 21 | +2. Use `list` for direct collection queries |
| 22 | +3. Use `listRelated` to traverse relationships (e.g., "orders of user 123") |
| 23 | + |
| 24 | +## Filter Syntax |
| 25 | + |
| 26 | +```json |
| 27 | +// Simple condition |
| 28 | +{ "field": "status", "operator": "Equal", "value": "active" } |
| 29 | + |
| 30 | +// Combined conditions |
| 31 | +{ |
| 32 | + "aggregator": "And", |
| 33 | + "conditions": [ |
| 34 | + { "field": "status", "operator": "Equal", "value": "active" }, |
| 35 | + { "field": "age", "operator": "GreaterThan", "value": 18 } |
| 36 | + ] |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +### Common Operators |
| 41 | + |
| 42 | +| Category | Operators | |
| 43 | +|----------|-----------| |
| 44 | +| Comparison | `Equal`, `NotEqual`, `LessThan`, `GreaterThan`, `LessThanOrEqual`, `GreaterThanOrEqual` | |
| 45 | +| String | `Contains`, `StartsWith`, `EndsWith`, `IContains` (case-insensitive) | |
| 46 | +| Array | `In`, `NotIn`, `IncludesAll` | |
| 47 | +| Null | `Present`, `Blank`, `Missing` | |
| 48 | +| Date | `Today`, `Yesterday`, `Before`, `After`, `PreviousWeek`, `PreviousMonth` | |
| 49 | + |
| 50 | +### Nested Fields |
| 51 | + |
| 52 | +Use `@@@` separator for relation fields: |
| 53 | +```json |
| 54 | +{ "field": "customer@@@email", "operator": "Contains", "value": "@gmail.com" } |
| 55 | +``` |
| 56 | + |
| 57 | +## Examples |
| 58 | + |
| 59 | +**"Find active users created this month"** |
| 60 | +``` |
| 61 | +1. describeCollection({ collectionName: "users" }) |
| 62 | +2. list({ |
| 63 | + collectionName: "users", |
| 64 | + filters: { |
| 65 | + aggregator: "And", |
| 66 | + conditions: [ |
| 67 | + { field: "status", operator: "Equal", value: "active" }, |
| 68 | + { field: "createdAt", operator: "PreviousMonth" } |
| 69 | + ] |
| 70 | + } |
| 71 | + }) |
| 72 | +``` |
| 73 | + |
| 74 | +**"Show orders for user 42"** |
| 75 | +``` |
| 76 | +1. describeCollection({ collectionName: "users" }) // to find relation name |
| 77 | +2. listRelated({ |
| 78 | + collectionName: "users", |
| 79 | + relationName: "orders", |
| 80 | + parentRecordId: 42 |
| 81 | + }) |
| 82 | +``` |
| 83 | + |
| 84 | +**"Count pending orders over $100"** |
| 85 | +``` |
| 86 | +list({ |
| 87 | + collectionName: "orders", |
| 88 | + filters: { |
| 89 | + aggregator: "And", |
| 90 | + conditions: [ |
| 91 | + { field: "status", operator: "Equal", value: "pending" }, |
| 92 | + { field: "total", operator: "GreaterThan", value: 100 } |
| 93 | + ] |
| 94 | + }, |
| 95 | + enableCount: true |
| 96 | +}) |
| 97 | +``` |
| 98 | + |
| 99 | +## Tips |
| 100 | + |
| 101 | +- Use `enableCount: true` when user asks "how many" or needs totals |
| 102 | +- Use `fields: ["id", "name"]` to reduce payload when only specific fields needed |
| 103 | +- Use `search` parameter for full-text search across searchable fields |
| 104 | +- Check `isSortable` from describeCollection before using sort |
0 commit comments