# NocoBase MCP Server - Documentation
Complete guides for using the MCP server.
## Quick Links
- [All Tools Reference](./ALL_TOOLS.md) - Complete list of 15 tools
- [Bulk Operations](#bulk-operations) - Batch data operations
- [Relationships](#relationships) - Managing relationships
- [Workflows](#workflows) - Automation workflows
---
## Bulk Operations
The server includes bulk data tools in `src/tools/data-tools.ts`:
### Functions Available
- `bulkCreateRecords()` - Batch insert with error handling
- `bulkUpdateRecords()` - Batch update
- `bulkDeleteRecords()` - Batch delete
- `loadSampleCRMData()` - Load 145 sample records
### Usage
These are **programmatic functions**, not MCP tools. Use them in your code:
```typescript
import { bulkCreateRecords } from './tools/data-tools.js';
await bulkCreateRecords(client, {
collectionName: 'leads',
records: [...],
batchSize: 10
});
```
### Features
- ✅ Automatic batching (default 10 per batch)
- ✅ Parallel processing within batch
- ✅ Error handling per record
- ✅ 500ms delay between batches (avoid rate limiting)
---
## Relationships
Create relationships between collections using `src/tools/relationship-tools.ts`:
### Functions Available
- `createRelationship()` - Create single relationship
- `createCRMRelationships()` - Create all 16 CRM relationships
### Standard CRM Relationships
1. accounts → contacts (hasMany)
2. accounts → opportunities (hasMany)
3. contacts → opportunities (hasMany)
4. leads → users (belongsTo, owner)
5. opportunities → users (belongsTo, owner)
6. opportunities → leads (belongsTo)
7. events → booth_packages (hasMany)
8. events → booth_inventory (hasMany)
9. booth_packages → booth_inventory (hasMany)
10. opportunities → events (belongsTo)
11. opportunities → opportunity_items (hasMany)
12. leads → lead_event_interests (hasMany)
13. events → lead_event_interests (hasMany)
14. opportunities → sows (hasMany)
15. accounts → sows (hasMany)
16. users → users (belongsTo, manager)
### Usage
```typescript
import { createCRMRelationships } from './tools/relationship-tools.js';
await createCRMRelationships(client);
```
---
## Workflows
Automate CRM processes using `src/tools/workflow-tools.ts`:
### Functions Available
- `createWorkflow()` - Create custom workflow
- `createCRMWorkflows()` - Create 5 standard workflows
### Standard CRM Workflows
1. **Lead Auto-Assignment** - Auto-assign new leads to sales reps
2. **Lead Conversion** - Convert qualified leads to accounts/contacts/opportunities
3. **Booth Hold** - Hold booths when opportunity moves to negotiation
4. **Booth Release** - Release booths when opportunity is lost
5. **SOW Creation** - Auto-create SOW when agency deal is won
### Usage
```typescript
import { createCRMWorkflows } from './tools/workflow-tools.js';
await createCRMWorkflows(client);
```
---
## Complete CRM Setup
Quick setup with all features:
```typescript
// 1. Create relationships
await createCRMRelationships(client);
// 2. Load sample data
await loadSampleCRMData(client);
// 3. Create workflows
await createCRMWorkflows(client);
```
**Result:** Fully functional CRM with 145 sample records and automation!
---
## Performance Tips
### Batch Sizes
- **Small datasets (<50):** batchSize = 10
- **Medium datasets (50-200):** batchSize = 20
- **Large datasets (>200):** batchSize = 50
### Error Handling
Always check the response:
```typescript
const result = await bulkCreateRecords(client, {...});
if (!result.success) {
console.log(`Failed: ${result.failed} records`);
result.errors.forEach(error => {
console.log(`Record ${error.index}: ${error.error}`);
});
}
```
---
## Troubleshooting
### Rate Limit Exceeded
**Solution:** Reduce batch size
```typescript
{ batchSize: 5 }
```
### Some Records Failed
Check the `errors` array in response for details.
### Timeout
Split into smaller batches or reduce batch size.
---
**Last Updated:** 2026-01-18
**Version:** 7.0.0