KIRO_USAGE_EXAMPLES.md•5.11 kB
# Kiro File System MCP Server - Usage Examples
## 🚀 How to Use File Operations Through Kiro Chat
Once the MCP server is set up, you can use natural language to interact with files:
### 📖 Reading Files
**Chat with Kiro:**
- "Read the contents of README.md"
- "Show me what's in the todo_list.txt file"
- "Can you read the config_example.json file?"
**What happens:** Kiro uses the `read_file` tool to get file contents and metadata.
### 📝 Creating Files
**Chat with Kiro:**
- "Create a new file called 'my_notes.txt' with the content 'Hello World'"
- "Make a Python script called 'test.py' with a simple hello world function"
- "Create a JSON config file with basic settings"
**What happens:** Kiro uses the `write_file` tool to create new files safely.
### 🔄 Updating Files
**Chat with Kiro:**
- "Add a new task to my todo_list.txt file"
- "Update the Python script to include error handling"
- "Modify the JSON config to enable debug mode"
**What happens:** Kiro uses the `update_file` tool with automatic backup creation.
### 📋 Listing Files
**Chat with Kiro:**
- "List all Python files in this directory"
- "Show me all markdown files recursively"
- "What files are in the src directory?"
**What happens:** Kiro uses the `list_directory` tool with pattern matching.
### 🗑️ Deleting Files
**Chat with Kiro:**
- "Delete the temporary file temp.txt"
- "Remove the old backup directory"
**What happens:** Kiro uses the `delete_file` tool (files moved to backup, not permanently deleted).
### ℹ️ Getting File Information
**Chat with Kiro:**
- "What's the size of my README.md file?"
- "When was the config file last modified?"
- "Show me details about the Python script"
**What happens:** Kiro uses the `get_file_info` tool to get comprehensive metadata.
## 🎯 Example Conversations
### Example 1: Creating and Editing a Note File
**You:** "Create a new file called 'project_ideas.md' with a heading and a few bullet points about project ideas"
**Kiro:** *Uses write_file tool to create the file with structured content*
**You:** "Now add a new section about AI projects to that file"
**Kiro:** *Uses read_file to get current content, then update_file to add the new section*
### Example 2: Working with Code Files
**You:** "Read the python_script.py file and tell me what it does"
**Kiro:** *Uses read_file to analyze the code and explains its functionality*
**You:** "Add error handling and logging to that script"
**Kiro:** *Uses update_file to enhance the script with proper error handling*
### Example 3: Project Organization
**You:** "List all Python files in this project and tell me their sizes"
**Kiro:** *Uses list_directory with *.py pattern to find and analyze Python files*
**You:** "Create a summary file listing all the main components of this project"
**Kiro:** *Uses multiple list_directory calls and write_file to create a project summary*
## 🛠️ Available MCP Tools
1. **read_file** - Read any text file with metadata
2. **write_file** - Create new files with content
3. **update_file** - Modify existing files (with backup)
4. **list_directory** - Browse directories with filtering
5. **delete_file** - Safe deletion (moves to backup)
6. **get_file_info** - Get detailed file information
## 📁 Test Files Created
The following test files are available in `/Users/chidvilasdasaradhi/Desktop/Project-MCP/kiro_test_files`:
- **empty_file.txt** - Empty file for testing
- **sample_note.md** - # Sample Note...
- **config_example.json** - {...
- **todo_list.txt** - TODO List - Edit me through Kiro!...
- **python_script.py** - #!/usr/bin/env python3...
## 🔒 Safety Features
- **Automatic Backups**: All file changes create timestamped backups
- **Protected Paths**: System directories are protected from modification
- **File Size Limits**: Large files are handled safely
- **Path Validation**: Prevents directory traversal attacks
- **Rollback on Failure**: Failed operations restore from backup
## 🚀 Getting Started
1. **Restart Kiro** to load the new MCP server
2. **Test the connection**: "List files in the current directory"
3. **Try file operations**: "Read the sample_note.md file"
4. **Create something new**: "Create a file called 'test.txt' with hello world"
## 💡 Pro Tips
- **Be specific**: "Add a function called 'calculate_sum' to math_utils.py"
- **Use natural language**: "Make the JSON config more readable with better formatting"
- **Ask for explanations**: "Read this code file and explain what it does"
- **Combine operations**: "List all Python files, then read the largest one"
## 🔧 Troubleshooting
If tools aren't working:
1. Check that the MCP server is running: Look for "file-system-operations" in Kiro's MCP panel
2. Verify configuration: The server should be enabled and not disabled
3. Check logs: Look for any error messages in Kiro's output
4. Test manually: Run `python3 test_real_filesystem.py` to verify core functionality
## 🎊 Have Fun!
You can now edit files, create projects, and manage your file system entirely through natural language conversation with Kiro!