# Usage Examples
This document provides practical examples of how to use the API Manager MCP Server with Claude Desktop and Claude Code.
## Basic Operations
### Adding API Keys
```
User: "Add my OpenAI API key"
Claude: I'll help you add your OpenAI API key. Please provide the key name and value.
User: "The key name is OPENAI_API_KEY and the value is sk-1234567890abcdef..."
Claude: ✅ Successfully added 'OPENAI_API_KEY'
📁 Category: OpenAI
🔐 Masked Value: sk-1***************cdef
```
### Listing API Keys
```
User: "Show me all my API keys"
Claude: 🔐 API Keys in /Users/username/.config/api_manager/.env
================================================================================
📁 Anthropic (Claude)
────────────────────────────────────────────────────────────────────────────────
ANTHROPIC_API_KEY: sk-a****************************5678
📁 OpenAI
────────────────────────────────────────────────────────────────────────────────
OPENAI_API_KEY: sk-1****************************cdef
📊 Total API Keys: 2
```
### Searching for Keys
```
User: "Find all my Discord related keys"
Claude: 🔍 Search Results for 'discord'
📁 Communication | DISCORD_BOT_TOKEN: ODc****************************NjAw
📁 Communication | DISCORD_WEBHOOK_URL: https://discord****************************
📊 Found 2 matching key(s)
```
## Advanced Operations
### Getting Statistics
```
User: "Show me statistics about my API keys"
Claude: 📊 API Manager Statistics
🔐 Total API Keys: 15
📁 Categories: 8
📈 Category Breakdown:
📂 Anthropic (Claude): 2 keys (13.3%)
📂 Communication: 3 keys (20.0%)
📂 Database & Storage: 4 keys (26.7%)
📂 Development Tools: 2 keys (13.3%)
📂 OpenAI: 2 keys (13.3%)
📂 Other: 1 keys (6.7%)
📂 Search & Data: 1 keys (6.7%)
📝 Environment File: /Users/username/.config/api_manager/.env
🕒 Last Modified: 2024-01-15 14:30:22
💾 Last Backup: .env.backup_20240115_143015
```
### Creating Backups
```
User: "Create a backup of my API keys"
Claude: ✅ Backup created successfully
📁 Location: /Users/username/.config/api_manager/.env.backup_20240115_143022
🕒 Timestamp: 2024-01-15 14:30:22
```
### Exporting Keys
```
User: "Export my API keys in JSON format without showing the actual values"
Claude: 📤 API Keys Export (JSON)
🔐 Keys are masked for security
```json
{
"ANTHROPIC_API_KEY": "sk-a****************************5678",
"OPENAI_API_KEY": "sk-1****************************cdef",
"DISCORD_BOT_TOKEN": "ODc****************************NjAw",
"SUPABASE_API_KEY": "eyJ****************************dCJ9"
}
```
```
## Security Examples
### Viewing Actual Values (Use with Caution)
```
User: "I need to see the actual value of my OpenAI API key"
Claude: 🔑 API Key Details
📝 Name: OPENAI_API_KEY
📁 Category: OpenAI
🔐 Value: sk-1234567890abcdef1234567890abcdef
⚠️ Security: Handle with care - this is the actual unmasked value!
```
### Safe Listing with Category Filter
```
User: "Show me only my AI service API keys"
Claude: 🔐 API Keys in /Users/username/.config/api_manager/.env
================================================================================
📁 Anthropic (Claude)
────────────────────────────────────────────────────────────────────────────────
ANTHROPIC_API_KEY: sk-a****************************5678
📁 OpenAI
────────────────────────────────────────────────────────────────────────────────
OPENAI_API_KEY: sk-1****************************cdef
OPENAI_ORG_ID: org-****************************5678
📁 Google AI
────────────────────────────────────────────────────────────────────────────────
GOOGLE_AI_API_KEY: AIz****************************xyz
📊 Total API Keys: 4 (filtered by: AI)
```
## Management Examples
### Updating an Existing Key
```
User: "Update my OpenAI API key with a new value"
Claude: I'll help you update your OpenAI API key.
User: "The new value is sk-9876543210fedcba9876543210fedcba"
Claude: ✅ Successfully updated 'OPENAI_API_KEY'
📁 Category: OpenAI
🔐 Masked Value: sk-9****************************dcba
```
### Deleting a Key
```
User: "Delete my old Discord webhook URL"
Claude: I'll delete the Discord webhook URL for you.
User: "The key name is DISCORD_WEBHOOK_OLD"
Claude: ✅ Successfully deleted 'DISCORD_WEBHOOK_OLD'
💾 Backup created: .env.backup_20240115_143525
```
## Error Handling Examples
### Invalid Key Name
```
User: "Add a key called 'my/invalid*key' with value 'test123'"
Claude: ❌ Error: Invalid key name. Names cannot contain special characters like \/*?:"<>|
```
### Key Not Found
```
User: "Get the value of NONEXISTENT_KEY"
Claude: ❌ Error: Key 'NONEXISTENT_KEY' not found
```
### Invalid Key Value
```
User: "Add a key called TEST_KEY with value 'test'"
Claude: ❌ Error: Invalid key value. Value seems too short, too long, or invalid.
```
## Integration Examples
### With Claude Desktop
Place this in your `claude_desktop_config.json`:
```json
{
"mcpServers": {
"api-manager": {
"command": "python",
"args": ["/path/to/API_Manager_MCPServer/api_manager.py"],
"env": {
"API_MANAGER_LOG_LEVEL": "INFO"
}
}
}
}
```
### With Claude Code
Add this to your MCP settings:
```json
{
"mcp": {
"servers": {
"api-manager": {
"command": "python",
"args": ["/path/to/API_Manager_MCPServer/api_manager.py"],
"env": {
"API_MANAGER_LOG_LEVEL": "INFO",
"API_MANAGER_ENV_FILE": "~/.config/api_manager/.env"
}
}
}
}
}
```
## Best Practices
### 1. Regular Backups
```
User: "Create a backup before I make changes"
Claude: [Creates backup automatically before any deletion]
```
### 2. Use Masked Values for Display
```
User: "List my keys" (without show_values=true)
Claude: [Shows masked values by default]
```
### 3. Organize by Categories
```
User: "Show me all my database keys"
Claude: [Filters by Database & Storage category]
```
### 4. Monitor with Statistics
```
User: "Show me my API key statistics monthly"
Claude: [Regular statistics monitoring]
```
### 5. Secure Environment File Location
Use the default secure location: `~/.config/api_manager/.env`
## Troubleshooting Examples
### Permission Issues
```bash
# Fix file permissions if needed
chmod 600 ~/.config/api_manager/.env
```
### Log Monitoring
```bash
# View recent activity
tail -f api_manager.log
# Search for errors
grep "ERROR" api_manager.log
```
### Configuration Issues
```bash
# Test the server manually
python api_manager.py --version
python api_manager.py --help
```