# Deta Space MCP

> Deta Space API manages your personal cloud storage directly from any AI agent. It gives you full conversational control over structured data in Deta Base and files in Deta Drive. You can query NoSQL records, upload backups, list file contents, or perform atomic updates—all without opening a dashboard.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** nosql, serverless, personal-cloud, data-storage, file-management

## Description

This connector lets your agent manage all aspects of your personal serverless infrastructure through natural conversation. Think of it as getting an API gateway for your private cloud data and files, accessible right from your chat client. You can treat structured JSON records like notes in Deta Base—querying specific fields or even using tools like `base_get_item` to pull up a single user profile instantly. It's the same conversation flow you use to ask about project status that lets you upload a new compliance document via `drive_upload_file`. Whether you're working in your IDE or just chatting with your agent, this gives you full access to your data and files. When you connect through Vinkius, you get all these capabilities rolled into one place, letting your AI client handle the plumbing for both structured records and actual file storage.

## Tools

### base_delete_item
Removes a specific item from Deta Base using its unique key.

### base_get_item
Retrieves and displays all attributes for one record in Deta Base, given the item's key.

### base_insert_item
Adds a new item to Deta Base only if no other item shares the same unique key.

### base_put_items
Writes one or more structured items into Deta Base from a JSON array input.

### base_query_items
Searches through Deta Base using complex query logic to find matching records.

### base_update_item
Changes specific fields of an existing item in Deta Base without affecting other attributes.

### drive_delete_files
Deletes one or more files from your personal cloud drive storage.

### drive_download_file
Downloads a specified file from Deta Drive by its name.

### drive_list_files
Returns a list of all files and folders currently stored in your Deta Drive.

### drive_upload_file
Transfers a new file from your local machine into the Deta Drive storage.

## Prompt Examples

**Prompt:** 
```
List all files in my 'backups' drive on Deta.
```

**Response:** 
```
I've listed the files in 'backups'. I found 3 files: 'db_dump.json', 'config.yaml', and 'logs.txt'. Would you like to download any of them?
```

**Prompt:** 
```
Get the item with key 'user_88' from the 'profiles' base.
```

**Response:** 
```
Retrieved profile for 'user_88': { "name": "Alice", "role": "admin", "status": "active" }. Do you need to update any of these fields?
```

**Prompt:** 
```
Increment the 'login_count' by 1 for key 'user_88' in 'profiles'.
```

**Response:** 
```
Successfully updated 'user_88'. The 'login_count' attribute has been incremented by 1.
```

## Capabilities

### Querying Structured Data
Search Deta Base using complex criteria to pull specific JSON items without knowing their exact keys.

### Managing Files
Upload, download, list, and delete files stored in your personal cloud drives conversationally.

### Atomic Data Updates
Modify only a specific attribute of an existing database record, preventing you from accidentally overwriting the whole object.

### Data Insertion and Retrieval
Store new records in Deta Base or pull up any single item by its unique identifier.

## Use Cases

### Need to update a user record.
The system admin needs to change a team member's 'role' and 'status' in the profiles collection. Instead of pulling the whole item, manually modifying it in an editor, and then pushing it back, they just ask their agent: 'Update user_102 role to manager and status to active.' The agent uses `base_update_item`.

### Auditing old project files.
A compliance officer needs all the expense reports from Q3. They ask their agent, 'List all files in my finance folder for 2024.' The agent uses `drive_list_files` and then proceeds to `drive_download_file` for any file matching the required extension.

### Logging a new incident.
An operations team member discovers an issue. They first ask the agent to 'Create a new incident log entry with key INC-9001.' The agent uses `base_insert_item`. Then, they use `drive_upload_file` to attach the error dump file and complete the record.

### Finding related data points.
A data scientist wants all records where 'project' is Alpha AND 'status' is pending. They ask their agent, 'Query Deta Base for items matching project=Alpha and status=pending.' The agent executes `base_query_items`.

## Benefits

- Avoid overwriting data. Instead of using `base_put_items` which can replace an entire record, use `base_update_item`. This lets you target just the 'status' field for example, leaving all other metadata untouched.
- Streamline file auditing. If you need to check what backups are available, run `drive_list_files` and get a clean list of everything in your drive without navigating folder structures.
- Handle data lifecycle completely from chat. You can use `base_insert_item` to log a new event and then immediately follow up with `drive_upload_file` to attach the relevant supporting document.
- Get fast read access. Need one user's profile? Use `base_get_item` by key. It bypasses complex querying and gives you the record instantly, which is faster than writing a dedicated search query.
- Improve data integrity. If an item doesn't exist, use `base_insert_item`. This tool prevents accidental duplicates, ensuring your records are unique from day one.

## How It Works

The bottom line is that your AI client routes complex data and file operations through a single, simple conversation prompt.

1. First, subscribe to the MCP using your Deta Space App Key and Project ID credentials.
2. Your AI client then recognizes both data (Base) and file system (Drive) operations as available tools.
3. You simply ask your agent to perform an action—like 'Find my user profile from last week' or 'Upload this new report'—and the agent executes the required tool calls.

## Frequently Asked Questions

**How do I update a record without losing data? (using base_update_item)**
You use `base_update_item`. This tool only modifies the attributes you specify, leaving all other existing fields in the item untouched. You don't have to retrieve and rewrite the whole object.

**Can I search my files using base_query_items?**
No, `base_query_items` is for structured JSON data only. To find files or folders in your personal cloud drive, you must use `drive_list_files`.

**What's the difference between base_insert_item and base_put_items?**
Use `base_insert_item` when you want to ensure the item key is unique before writing. If you use `base_put_items`, it will attempt to write multiple items in a single batch operation.

**How do I delete files from Deta Drive?**
Use `drive_delete_files`. You tell the agent which file names or groups of files you want gone, and it handles the deletion across your drive storage.

**If I use `base_get_item`, what happens if the key doesn't exist?**
The system returns an explicit error or null value. This means your AI client gets immediate feedback that no item was found by that specific key, so you can handle it in your workflow.

**What information must I provide when using `drive_upload_file`?**
You need the file content, a unique name for the file, and optionally a descriptive category. The AI agent handles packaging these inputs so you can upload any type of file successfully.

**Are there rate limits when I use `base_put_items` to store many records?**
Yes, while the MCP manages throughput, keep an eye on API response headers for usage quotas. If you hit a limit, your agent can retry the batch upload after waiting a short interval.

**Does `base_delete_item` perform any kind of soft delete or confirmation?**
The tool performs an immediate, hard deletion by key. Use it only when you are absolutely certain that data should be permanently removed from Deta Base.

**How can I search for specific records in a Deta Base?**
Use the `base_query_items` tool. You can provide a JSON array of query objects to filter items by their attributes, and even handle pagination using the `limit` and `last` parameters.

**Can I update just one field in a database item without sending the whole object?**
Yes! The `base_update_item` tool allows you to perform atomic updates. You can use the `set` parameter to update fields, `increment` for numbers, or `append` for arrays.

**How do I upload a text file or document to Deta Drive?**
Use the `drive_upload_file` tool. Provide the `drive_name`, the desired file `name` (path), and the `content` of the file. The agent will handle the storage process for you.