Uploading Documentation
The upload_docs tool uploads documentation files to the Cyborg backend for processing and indexing.
Basic Usage
Upload my documentation files from ./cyborg-docsOr with explicit parameters:
json
upload_docs({
"filePaths": ["./cyborg-docs/**/*.md"],
"docsDir": "./cyborg-docs",
"documentType": "markdown"
})Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
publishableKey | string | No | env var | Cyborg publishable key |
filePaths | string[] | Yes | - | Glob patterns for files to upload |
docsDir | string | No | ./cyborg-docs | Base directory for state file |
documentType | 'markdown' | 'text' | No | markdown | Document type for processing |
What Happens
- Files are read and content hashes calculated (SHA-256)
- Batch upload to Cyborg API
- Backend processes files: chunking, embedding, indexing
- State file updated with document IDs and hashes
State File
After upload, .cyborg-state.json is created/updated:
json
{
"apiUrl": "https://api.cyborgsdk.dev/api/v1",
"lastSyncedAt": "2025-01-15T10:30:00Z",
"files": {
"getting-started.md": {
"documentId": "doc_abc123",
"contentHash": "sha256:e3b0c44298fc...",
"syncedAt": "2025-01-15T10:30:00Z"
}
}
}Response
json
{
"success": true,
"uploaded": [
{ "path": "getting-started.md", "documentId": "doc_abc123" },
{ "path": "api/useChat.md", "documentId": "doc_def456" }
],
"failed": []
}Examples
Upload All Markdown Files
json
upload_docs({
"filePaths": ["./docs/**/*.md"]
})Upload Specific Files
json
upload_docs({
"filePaths": [
"./README.md",
"./docs/getting-started.md",
"./docs/api-reference.md"
]
})Upload with Custom Directory
json
upload_docs({
"filePaths": ["./documentation/**/*.md"],
"docsDir": "./documentation"
})Error Handling
If some files fail to upload:
json
{
"success": false,
"uploaded": [
{ "path": "getting-started.md", "documentId": "doc_abc123" }
],
"failed": [
{ "path": "api/useChat.md", "error": "File too large" }
]
}Best Practices
- Use glob patterns for bulk uploads:
./docs/**/*.md - Commit the state file to version control
- Review before uploading - check generated docs first
- Use consistent structure - helps the AI understand your docs
Next Steps
- Sync Docs - Keep docs updated
- Tools Reference - All upload options