# Story 1.2: Documentation Updates (CORRECTED)
<!-- Powered by BMAD™ Core -->
## Status
Ready for QA
## Story Points
8 points (High volume, low complexity)
**Estimation Rationale:**
- 4 documentation files to update (README.md, multi-instance-architecture.md, CLAUDE.md, setup_with_claude.md)
- 18+ URL occurrences to update across files
- New sections to write (Configuration Best Practices, Troubleshooting)
- CHANGELOG.md update required
- Visual examples creation (✅/❌ format comparisons)
- Low technical complexity but high volume of careful edits
- Requires attention to consistency across all documentation
## Story
**As a** developer setting up the n8n MCP server for the first time,
**I want** clear and accurate documentation showing the correct URL format,
**so that** I can configure my n8n instances properly without trial and error.
## Acceptance Criteria
1. All configuration examples in README.md use base URLs without `/api/v1`
2. CLAUDE.md integration examples updated with correct URL format ✅ **ALREADY COMPLETED**
3. All files in `examples/` directory updated with correct URLs
4. New "Configuration Best Practices" section in README.md explains proper URL format
5. Migration guidance added for users with existing `/api/v1` configurations
6. Troubleshooting section includes URL configuration issues
7. CHANGELOG.md updated with version 0.9.1 and change description
8. Clear visual examples showing ✅ correct vs ❌ incorrect URL formats
9. Both self-hosted and n8n Cloud URL formats documented
10. All documentation references official n8n API documentation
## Tasks / Subtasks
- [x] ~~Update README.md (AC: 1, 4, 6, 8, 9, 10)~~ ✅ **ALREADY COMPLETED** (Previous session)
- [x] ~~Find and replace all `"n8n_host"` examples~~ ✅ All URLs correct
- [x] ~~Update multi-instance configuration example~~ ✅ Lines 80, 84, 88 correct
- [x] ~~Update single-instance .env example~~ ✅ Correct format
- [x] ~~Add "Configuration Best Practices" section~~ ✅ Line 107
- [x] ~~Add visual examples (✅/❌)~~ ✅ Present in Configuration Best Practices
- [x] ~~Update troubleshooting section~~ ✅ Line 572: URL Configuration Issues
- [x] ~~Add reference to official n8n API docs~~ ✅ Lines 164-165
- [x] ~~Update CLAUDE.md (AC: 2, 8, 9)~~ ✅ **ALREADY COMPLETED** (Previous session)
- [x] ~~Update integration examples~~ ✅ Line 72: correct format
- [x] ~~Fix environment variable examples~~ ✅ Line 321: correct format
- [x] ~~Add note about proper URL format~~ ✅ Line 81: explanatory note added
- [x] ~~Update docs/multi-instance-architecture.md (AC: 3, 8)~~ ✅ **COMPLETED** (This session)
- [x] ~~Update first example (lines 28, 32)~~ ✅ URLs corrected
- [x] ~~Update second example (lines 79, 83, 87)~~ ✅ URLs corrected
- [x] ~~Update .env fallback example (line 98)~~ ✅ URL corrected
- [x] ~~Update migration example (line 107)~~ ✅ URL corrected
- [x] ~~**Total: 7 occurrences**~~ ✅ All corrected
- [x] ~~Update examples/ directory files (AC: 3, 8)~~ ✅ **ALREADY COMPLETED** (Previous session)
- [x] ~~`examples/setup_with_claude.md`~~ ✅ Lines 33, 53, 83 all correct
- [x] ~~Verify `examples/workflow_examples.md`~~ ✅ No config examples found
- [x] ~~Verify `examples/complex_workflow.md`~~ ✅ No config examples found
- [x] ~~Verify `examples/using_prompts.md`~~ ✅ No config examples found
- [x] ~~Skip `examples/n8n-openapi-markdown.md`~~ ✅ OpenAPI spec reference, correct as-is
- [x] ~~Add migration guide section (AC: 5)~~ ✅ **ALREADY COMPLETED** (Previous session)
- [x] ~~Create "Migrating from Old URL Configuration Format" section~~ ✅ README.md line 167
- [x] ~~Explain backward compatibility~~ ✅ Documented
- [x] ~~Recommend updating to new format~~ ✅ Documented
- [x] ~~Provide before/after examples~~ ✅ Complete examples included
- [x] ~~Update CHANGELOG.md (AC: 7)~~ ✅ **ALREADY COMPLETED** (Previous session)
- [x] ~~Add version 0.9.1 entry~~ ✅ Comprehensive entry present
- [x] ~~Document URL normalization bug fix~~ ✅ Documented
- [x] ~~Note backward compatibility~~ ✅ Documented
- [x] ~~Credit user bug report~~ ✅ Credit included
- [x] ~~Review and verify all changes (AC: 1-10)~~ ✅ **COMPLETED**
- [x] ~~Double-check all URL examples~~ ✅ All verified
- [x] ~~Ensure consistency~~ ✅ Consistent across all files
- [x] ~~Verify no broken links~~ ✅ All links valid
- [x] ~~Validate JSON examples~~ ✅ All JSON valid
- [x] ~~Cross-reference with Story 1.1~~ ✅ Aligned with code changes
## Dev Notes
### Files to Update
**Primary Documentation:**
- `README.md` - Main project documentation (~6 occurrences in lines 80, 84, 88, 335, 348, 352)
- ~~`CLAUDE.md`~~ ✅ **ALREADY COMPLETED** - Claude Code integration guide (2 occurrences already correct)
- `CHANGELOG.md` - Version history (add 0.9.1 entry)
**Architecture Documentation:**
- `docs/multi-instance-architecture.md` - **7 occurrences** (lines 28, 32, 79, 83, 87, 98, 107)
**Examples Directory:**
- `examples/setup_with_claude.md` - **3 occurrences** (lines 33, 51, 81)
**Verification Only (No Changes Expected):**
- `examples/workflow_examples.md` ✅
- `examples/complex_workflow.md` ✅
- `examples/using_prompts.md` ✅
**Do Not Modify:**
- `examples/n8n-openapi-markdown.md` - OpenAPI specification (correct as-is)
**Total Files Requiring Updates:** 4 (README.md, CHANGELOG.md, multi-instance-architecture.md, setup_with_claude.md)
**Total URL Occurrences to Fix:** ~16 occurrences
- README.md: 6 occurrences
- multi-instance-architecture.md: 7 occurrences
- setup_with_claude.md: 3 occurrences
### Current Incorrect Examples
**README.md - Lines to Fix:**
Line 80:
```json
"n8n_host": "https://n8n.example.com/api/v1/",
```
Line 84:
```json
"n8n_host": "https://staging-n8n.example.com/api/v1/",
```
Line 88:
```json
"n8n_host": "http://localhost:5678/api/v1/",
```
Lines 335, 348, 352 - Similar patterns in migration examples
**docs/multi-instance-architecture.md - Lines to Fix:**
Lines 28, 32:
```json
"n8n_host": "https://n8n.example.com/api/v1/",
"n8n_host": "https://staging.example.com/api/v1/",
```
Lines 79, 83, 87:
```json
"n8n_host": "https://n8n.company.com/api/v1/",
"n8n_host": "https://staging-n8n.company.com/api/v1/",
"n8n_host": "http://localhost:5678/api/v1/",
```
Line 98:
```env
N8N_HOST=https://your-n8n-instance.com/api/v1/
```
Line 107:
```json
"n8n_host": "https://your-n8n-instance.com/api/v1/",
```
**examples/setup_with_claude.md - Lines to Fix:**
Line 33:
```env
N8N_HOST=https://your-n8n-instance.com/api/v1/
```
Line 51:
```json
"N8N_HOST": "https://your-n8n-instance.com/api/v1/"
```
Line 81:
```json
"N8N_HOST": "https://your-n8n-instance.com/api/v1/"
```
### Correct Format Examples
**Multi-Instance Configuration (`.config.json`):**
```json
{
"environments": {
"production": {
"n8n_host": "https://n8n.example.com",
"n8n_api_key": "n8n_api_key_for_production"
},
"staging": {
"n8n_host": "https://staging-n8n.example.com",
"n8n_api_key": "n8n_api_key_for_staging"
},
"development": {
"n8n_host": "http://localhost:5678",
"n8n_api_key": "n8n_api_key_for_development"
}
},
"defaultEnv": "development"
}
```
**Single-Instance Configuration (`.env`):**
```env
N8N_HOST=https://your-n8n-instance.com
N8N_API_KEY=your_api_key_here
```
**n8n Cloud:**
```json
{
"n8n_host": "https://your-instance.app.n8n.cloud",
"n8n_api_key": "your_cloud_api_key"
}
```
### Configuration Best Practices Section
Add this new section to README.md after "Installation Guide":
````markdown
## Configuration Best Practices
### Correct URL Format
The n8n MCP server automatically appends `/api/v1` to your configured base URL. Always provide the **base URL without `/api/v1`**:
**✅ Correct Examples:**
```json
{
"n8n_host": "https://n8n.example.com",
"n8n_api_key": "your_api_key"
}
```
```json
{
"n8n_host": "http://localhost:5678",
"n8n_api_key": "your_api_key"
}
```
```json
{
"n8n_host": "https://your-instance.app.n8n.cloud",
"n8n_api_key": "your_api_key"
}
```
**❌ Incorrect Examples (will cause duplicate paths):**
```json
{
"n8n_host": "https://n8n.example.com/api/v1/", // ❌ Don't include /api/v1
"n8n_api_key": "your_api_key"
}
```
### Why This Matters
The server constructs the full API URL by appending `/api/v1` to your base URL:
```
Base URL: https://n8n.example.com
Final URL: https://n8n.example.com/api/v1/workflows ✅
Base URL: https://n8n.example.com/api/v1/
Final URL: https://n8n.example.com/api/v1/api/v1/workflows ❌
```
### Backward Compatibility
**Note for Existing Users:** If you have an existing configuration with `/api/v1` in the URL, it will continue to work. The server now automatically detects and removes duplicate `/api/v1` paths. However, we recommend updating to the correct format for clarity.
### Official n8n API Documentation
For more information about n8n API endpoints and URL structure, refer to:
- [n8n API Documentation](https://docs.n8n.io/api/)
- [n8n REST API Reference](https://docs.n8n.io/api/api-reference/)
````
### Migration Guide Section
Add this section to README.md:
````markdown
## Migrating from Old Configuration Format
If you have an existing configuration that includes `/api/v1` in the URL, you have two options:
### Option 1: Continue Using Current Configuration (Recommended for Quick Start)
Your existing configuration will continue to work due to backward compatibility:
```json
{
"n8n_host": "https://n8n.example.com/api/v1/", // Still works!
"n8n_api_key": "your_api_key"
}
```
The server automatically normalizes the URL internally.
### Option 2: Update to New Format (Recommended for Clarity)
Update your configuration to match the official n8n API documentation:
**Before:**
```json
{
"environments": {
"production": {
"n8n_host": "https://n8n.example.com/api/v1/",
"n8n_api_key": "your_api_key"
}
}
}
```
**After:**
```json
{
"environments": {
"production": {
"n8n_host": "https://n8n.example.com",
"n8n_api_key": "your_api_key"
}
}
}
```
**Steps:**
1. Open your `.config.json` or `.env` file
2. Remove `/api/v1` and any trailing slashes from `n8n_host` values
3. Save the file
4. Restart the MCP server
No code changes or additional configuration needed!
````
### Troubleshooting Section Addition
Add to existing Troubleshooting section in README.md:
````markdown
#### URL Configuration Issues
**Symptom:** API calls fail with 404 errors or "not found" messages
**Possible Cause:** Incorrect URL format causing duplicate `/api/v1` paths
**Solution:**
1. **Check your configuration file** (`.config.json` or `.env`)
Ensure your `n8n_host` does NOT include `/api/v1`:
```json
{
"n8n_host": "https://n8n.example.com" // ✅ Correct
}
```
NOT:
```json
{
"n8n_host": "https://n8n.example.com/api/v1/" // ❌ Will be auto-normalized
}
```
2. **Enable debug logging** to see URL construction:
```bash
DEBUG=true npm start
```
Look for lines like:
```
[EnvironmentManager] Original URL: https://n8n.example.com/api/v1/
[EnvironmentManager] Normalized baseURL: https://n8n.example.com/api/v1
```
3. **Verify n8n instance is accessible:**
```bash
curl https://your-n8n-host/api/v1/workflows \
-H "X-N8N-API-KEY: your_api_key"
```
4. **Check trailing slashes:**
Both of these are acceptable and will be normalized:
- `https://n8n.example.com` ✅
- `https://n8n.example.com/` ✅
````
### CHANGELOG.md Entry
Add this entry at the top of CHANGELOG.md:
````markdown
### 0.9.1
**🐛 Bug Fixes:**
- **URL Configuration Normalization** - Fixed URL path duplication issue where user configurations containing `/api/v1` resulted in duplicate path segments (`/api/v1/api/v1/`)
- Server now intelligently detects and normalizes URLs regardless of format
- Maintains full backward compatibility with existing configurations
- Thanks to user bug report: "The Host URL should not be appended with /api/v1 as the URL Builder will append that automatically"
**📚 Documentation:**
- **Configuration Best Practices** - Added comprehensive guide on correct URL format
- **Updated All Examples** - Corrected all configuration examples to match official n8n API documentation
- **Migration Guide** - Added guidance for users with existing configurations
- **Troubleshooting** - Enhanced troubleshooting section with URL configuration issues
- All examples now align with official n8n API documentation format
**✨ Features:**
- **Smart URL Detection** - Automatic normalization of user-provided URLs for maximum compatibility
- **Enhanced Debug Logging** - Shows both original and normalized URLs when `DEBUG=true`
**🔧 Technical Changes:**
- Updated `src/services/environmentManager.ts` to include URL normalization logic
- Added inline documentation explaining normalization process
- Improved error handling transparency
````
### Testing
**Test Documentation Changes:**
1. Read through all updated documentation files
2. Verify all code examples are syntactically correct
3. Check all markdown formatting renders correctly
4. Verify all internal links work
5. Ensure consistency across all files
6. Spell-check and grammar check
**Documentation Validation Checklist:**
- [ ] All JSON examples are valid JSON (use online validator)
- [ ] All bash/shell examples have correct syntax
- [ ] All markdown headers are properly formatted
- [ ] All URLs are correct and accessible
- [ ] Examples are consistent with code changes in Story 1.1
- [ ] No broken internal links
- [ ] Changelog version number (0.9.1) matches package.json update
### Testing Standards
**Documentation Testing:**
- Render markdown locally to verify formatting
- Validate JSON examples with online JSON validator: https://jsonlint.com/
- Test shell commands actually work
- Cross-reference with official n8n documentation
- Ensure examples work with code from Story 1.1
**Validation Commands:**
```bash
# Verify JSON syntax
cat .config.json | jq .
# Check for remaining /api/v1 in config examples (should find none)
grep -r "n8n_host.*api/v1" README.md docs/ examples/
# Verify markdown renders correctly
npx markdown-link-check README.md
```
## Implementation Notes
### Order of Updates
1. **First:** README.md (most visible, highest priority)
2. **Second:** docs/multi-instance-architecture.md (technical documentation)
3. **Third:** examples/setup_with_claude.md (user onboarding)
4. **Fourth:** CHANGELOG.md (version documentation)
5. **Last:** Final verification pass
### Search/Replace Strategy
**Safe Search/Replace Patterns:**
For `.json` examples:
```
Find: "n8n_host": "https://n8n.example.com/api/v1/"
Replace: "n8n_host": "https://n8n.example.com"
```
For `.env` examples:
```
Find: N8N_HOST=https://your-n8n-instance.com/api/v1/
Replace: N8N_HOST=https://your-n8n-instance.com
```
**⚠️ Important:** Be careful with OpenAPI spec files - do NOT change `/api/v1` in API path definitions!
## Change Log
| Date | Version | Description | Author |
|------|---------|-------------|--------|
| 2025-12-25 | 1.0 | Story created from Epic 1 | James (Dev Agent) |
| 2025-12-25 | 1.1 | Corrected after file scan - added multi-instance-architecture.md, noted CLAUDE.md already completed | Sarah (PO) |
| 2025-12-26 | 1.2 | Implementation completed - all URL corrections applied | James (Dev Agent) |
| 2025-12-26 | 1.2 | Status updated to Ready for QA | James (Dev Agent) |
## Dev Agent Record
### Agent Model Used
Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)
### Implementation Date
2025-12-26
### Debug Log References
No errors encountered during implementation. All file updates completed successfully.
### Completion Notes List
**Pre-Implementation Discovery (2025-12-26):**
- README.md: Already contained all required sections (Configuration Best Practices, Migration Guide, Troubleshooting)
- CHANGELOG.md: Already contained version 0.9.1 entry with comprehensive changelog
- CLAUDE.md: Already updated in previous session (verified no /api/v1 occurrences)
- examples/setup_with_claude.md: Already updated in previous session (verified correct URLs)
**Files Requiring Updates:**
- ✅ docs/multi-instance-architecture.md: 7 URL occurrences corrected (lines 28, 32, 79, 83, 87, 98, 107)
**Implementation Summary:**
- Total files updated in this session: 1 (docs/multi-instance-architecture.md)
- Total files already correct: 3 (README.md, CHANGELOG.md, CLAUDE.md, setup_with_claude.md)
- Total URL occurrences corrected in this session: 7
- Total URL occurrences already correct from previous work: ~9
**Verification:**
- All JSON examples validated for correct syntax
- All markdown formatting verified
- No /api/v1 found in configuration examples (except in ❌ incorrect examples)
- Cross-referenced with Story 1.1 implementation
### File List
**Modified in This Session:**
1. `docs/multi-instance-architecture.md` - 7 URL corrections
2. `docs/stories/1.2.documentation-updates.CORRECTED.md` - Status updated to Ready for QA
**Already Correct from Previous Work:**
3. `README.md` - All sections and URLs already correct
4. `CHANGELOG.md` - Version 0.9.1 already present
5. `CLAUDE.md` - URLs already correct
6. `examples/setup_with_claude.md` - URLs already correct
**Total Documentation Updated for Epic 1:** 6 files
## QA Results
_To be filled by QA Agent after implementation_