# Schema Enhancements Summary
**Date**: 2025-10-08
**Status**: In Progress - Phase 1 Complete
## Overview
Systematic enhancement of MCP-GAS tool schemas to improve discoverability, usability, and error recovery through comprehensive metadata.
---
## Completed Work
### Phase 1: Script Type Compatibility & Limitations (15/63 tools)
Added `scriptTypeCompatibility` and `limitations` sections to document:
- Standalone vs container-bound script support
- API constraints and quotas
- Performance characteristics
- File type restrictions
#### Tools Updated
**Execution Tools (2):**
- ✅ gas_run (execution.ts:276-347)
- ✅ gas_exec (execution.ts:844-1010)
**File Operations (3):**
- ✅ cat (filesystem.ts:80-104)
- ✅ write (filesystem.ts:544-575)
- ✅ ls (filesystem.ts:1390-1411)
**Search Tools (3):**
- ✅ grep (grep.ts:41-72)
- ✅ ripgrep (ripgrep.ts:1027-1068)
- ✅ find (find.ts:112-132)
**Logging Tools (4):**
- ✅ logs_list (logs.ts:93-137) - *from previous session*
- ✅ logs_get (logs.ts) - *from previous session*
- ✅ process_list (processes.ts) - *from previous session*
- ✅ process_list (processes.ts) - Consolidated, removed separate process_list_script tool
**Project Management (2):**
- ✅ project_create (deployments.ts:806-842)
- ✅ project_init (deployments.ts:1034-1073)
**Versioning (2):**
- ✅ version_get (versions.ts:48-80)
- ✅ version_list (versions.ts:156-190)
### Phase 2: Cross-Tool References (5 high-priority tools)
Added `prerequisites`, `nextSteps`, `alternatives`, `errorRecovery`, and `relatedTools` sections.
#### Tools Enhanced
**gas_run** (execution.ts:278-309):
- Prerequisites: gas_auth, project existence
- Next steps: version_create on success, error diagnostics on failure
- Alternatives: exec_api for API deployments, Apps Script Editor for debugging
- Error recovery: Specific actions for __defineModule__, auth, timeout, not found errors
**logs_list** (logs.ts:94-121):
- Alternatives: gas_run for container-bound logging (detailed with usage examples)
- Next steps: logs_get for details, gas_run on container-bound failure
- Clear guidance on when tool fails and what to use instead
**project_create** (deployments.ts:831-844):
- Next steps: Complete workflow from creation → code → test → deploy
- Related tools: Comprehensive mapping to container-bound alternatives, management, code, execution
**grep** (grep.ts:53-65) - **WITH RIPGREP PREFERENCE**:
- ⚡ **STRONGLY RECOMMENDS ripgrep** over grep for all searches
- Tool description updated to highlight ripgrep as preferred
- whenToUse updated to prefer ripgrep for most searches
- relatedTools updated with "preferred" category for ripgrep
- Next steps: cat → sed → write → gas_run workflow
**CROSS_TOOL_REFERENCES.md**:
- Updated search workflow to emphasize ripgrep as PREFERRED for all searches
- Added warning that grep is for simple searches only
- Restructured search tool recommendations with ripgrep first
---
## Key Improvements
### 1. Script Type Compatibility
**Before:**
- No indication whether tools work with container-bound scripts
- Users had to trial-and-error to discover limitations
- No alternatives suggested when tools fail
**After:**
```typescript
scriptTypeCompatibility: {
standalone: '✅ Full Support - Works identically',
containerBound: '✅ Full Support - Works identically',
notes: 'Works universally for both script types'
}
```
### 2. Clear Limitations
**Before:**
- Limitations scattered across documentation
- No visibility into quotas, constraints, timeouts
**After:**
```typescript
limitations: {
executionTime: 'Free tier: 6 minutes, Workspace: 30 minutes',
fileTypes: 'Only reads SERVER_JS (.gs), HTML (.html), and JSON (appsscript.json)',
maxResults: 'Hard limit of 200 matches to prevent token overflow'
}
```
### 3. Error Recovery
**Before:**
- Generic error messages with no guidance
- Users left to figure out solutions
**After:**
```typescript
errorRecovery: {
'__defineModule__ not defined': {
action: 'project_init({scriptId})',
reason: 'CommonJS infrastructure missing'
},
'Authentication required': {
action: 'gas_auth({mode: "start"})',
reason: 'OAuth token expired'
}
}
```
### 4. Workflow Chaining
**Before:**
- Tools existed in isolation
- No guidance on what to do next
**After:**
```typescript
nextSteps: [
'AFTER SEARCH: Use cat to read full context',
'TO MODIFY: Use sed for find/replace',
'TO UPDATE: Use write after changes',
'TO VERIFY: Use gas_run to test'
]
```
### 5. Alternative Tools
**Before:**
- No cross-referencing between tools
- Hard to discover better tools for specific use cases
**After:**
```typescript
relatedTools: {
moreAdvanced: 'ripgrep - For multi-pattern search',
semanticSearch: 'context - For natural language queries',
fileDiscovery: 'find - For finding files by name'
}
```
---
## Benefits
### For LLMs
1. **Error Recovery**: Immediate actionable guidance when tools fail
2. **Workflow Discovery**: Natural progression through related tools
3. **Alternative Discovery**: Know when to switch to better tool for the job
4. **Constraint Awareness**: Understand limitations before execution
### For Users
1. **Reduced Trial-and-Error**: Clear documentation of what works where
2. **Faster Problem Resolution**: Error messages lead directly to solutions
3. **Better Tool Utilization**: Discover advanced tools through recommendations
4. **Transparent Limitations**: Know constraints upfront, not after failures
### For Development
1. **Self-Documenting System**: Schemas contain comprehensive guidance
2. **Natural Workflows**: Tool relationships emerge from documentation
3. **Reduced Support Burden**: Users find answers in schemas
4. **Systematic Coverage**: Template ensures consistent documentation
---
## Documentation Created
### CROSS_TOOL_REFERENCES.md (8.6 KB)
Comprehensive strategy document covering:
- 7 tool relationship categories
- Implementation strategy with priorities
- 3 detailed examples of excellent cross-referencing
- Maintenance guidelines for future tools
### REFERENCE.md (18 KB)
Complete reference guide with:
- Script type compatibility matrix (63 tools)
- Critical limitations with technical explanations
- Common workflows and quick start examples
- Troubleshooting guide
### SCHEMA_ENHANCEMENTS_SUMMARY.md (This Document)
Progress tracking and benefits analysis
---
## Remaining Work
### High Priority (Core Workflows)
**File Operations (6 remaining):**
- raw_cat, raw_write - System file variants
- rm, mv, cp, raw_cp - File manipulation
**Search Tools (2 remaining):**
- sed - Find/replace operations
- raw_grep, raw_ripgrep, raw_sed - System variants
**Deployment Tools (5 remaining):**
- deploy_create, deploy_list, deploy_get_details
- deploy_update, deploy_delete
### Medium Priority
**Git Integration (5 tools):**
- git_init, git_sync, git_status
- config (action: set, type: sync_folder), config (action: get, type: sync_folder)
**Local Sync (7 tools):**
- pull, push, status
- project_set, project_get, project_add, project_list
**Analysis Tools (4 tools):**
- context, summary, deps, tree
### Lower Priority
**Triggers (3 tools):**
- trigger_list, trigger_create, trigger_delete
**Drive Container (3 tools):**
- find_drive_script, bind_script, create_script
**Utilities (2 tools):**
- proxy_setup, info, reorder
**Sheets Integration (1 tool):**
- sheet_sql
---
## Implementation Pattern
### Template for Adding Metadata
```typescript
llmGuidance: {
whenToUse: '...',
// Phase 1: Compatibility & Limitations
scriptTypeCompatibility: {
standalone: '✅ Full Support - Works identically',
containerBound: '✅ Full Support - Works identically',
notes: 'Universal support across all script types'
},
limitations: {
constraint1: 'Description with specifics',
constraint2: 'Description with workaround'
},
// Phase 2: Cross-Tool References
prerequisites: [
'tool_name - What must run first and why'
],
nextSteps: [
'CONTEXT: tool_name - What to do after this action'
],
alternatives: {
useCase: 'tool_name - When to use instead and why'
},
relatedTools: {
category: 'tool_name - Related functionality'
},
errorRecovery: {
'Error pattern': {
action: 'tool_name({params})',
reason: 'Why this fixes the error'
}
}
}
```
### Validation Checklist
- [ ] Script type compatibility documented
- [ ] All limitations listed with specifics
- [ ] Prerequisites clear and ordered
- [ ] Next steps provide context
- [ ] Alternatives suggest when/why
- [ ] Error recovery provides action + reason
- [ ] All mentioned tools exist
- [ ] Sequences make logical sense
---
## Next Steps
### Immediate (Phase 2 Continuation)
1. **Add cross-tool references to high-priority tools**:
- write → gas_run workflow
- sed → write → gas_run workflow
- version_create → deploy_create workflow
2. **Enhance error recovery for common failures**:
- Deployment failures → version/deploy tools
- File operation failures → raw_ variants
- Search failures → alternative search tools
### Short-term (Complete Phase 1)
3. **Add scriptTypeCompatibility + limitations to remaining 48 tools**
- Focus on file operations (rm, mv, cp)
- Then search tools (sed, raw_ variants)
- Then deployment tools
### Medium-term (Phase 3)
4. **Implement advanced cross-referencing**:
- Analysis tool relationships (tree ↔ deps ↔ summary ↔ context)
- Git workflow chains (git_init → git_sync → git_status)
- Local sync patterns (project_set → pull → write → push)
---
## Success Metrics
### Quantitative
- **Schema Coverage**: 15/63 tools (24%) have scriptTypeCompatibility + limitations
- **Cross-References**: 5/63 tools (8%) have comprehensive cross-tool guidance
- **Error Recovery**: 2/63 tools (3%) have detailed error recovery paths
- **Search Tool Guidance**: grep now strongly recommends ripgrep for all searches
### Qualitative
- ✅ Container-bound logging limitation clearly documented with alternative
- ✅ Execution errors have actionable recovery steps
- ✅ Search → edit → test workflow discoverable
- ✅ Project creation leads to complete workflow chain
- ✅ **ripgrep strongly recommended** over grep in all documentation and schemas
- ✅ README updated with enhanced schema documentation and ripgrep preference
### Target (End of Week)
- Schema Coverage: 63/63 tools (100%)
- Cross-References: 20+ high-priority tools (32%)
- Error Recovery: 10+ common error patterns
---
## Conclusion
The schema enhancements significantly improve MCP-GAS usability by:
1. **Making limitations transparent** - Users know what works where before trying
2. **Providing clear error recovery** - Failures lead directly to solutions
3. **Enabling workflow discovery** - Natural progression through related tools
4. **Maximizing tool utilization** - Better tools suggested for each use case
This systematic approach ensures:
- Consistent documentation patterns
- Self-documenting system
- Reduced learning curve
- Better user experience
The investment in comprehensive schemas pays dividends in reduced support burden, faster onboarding, and better tool adoption.