Skip to main content

DocuMCP Environment Setup Guide

This guide will help you set up DocuMCP in your own environment, from basic installation to advanced configuration for team collaboration.

๐Ÿš€ Quick Setupโ€‹

Prerequisites Checkโ€‹

Before installing DocuMCP, ensure you have the required software:

# Check Node.js version (requires 20.0.0+)
node --version

# Check npm version (requires 8.0.0+)
npm --version

# Check Git version
git --version

# Check GitHub CLI (optional but recommended)
gh --version

Installation Methodsโ€‹

# Install DocuMCP globally
npm install -g documcp

# Verify installation
documcp --version
# Should output: DocuMCP v0.5.0

Method 2: Local Project Installationโ€‹

# Navigate to your project directory
cd /path/to/your/project

# Install DocuMCP as a dev dependency
npm install documcp --save-dev

# Add to package.json scripts
npm pkg set scripts.docs="documcp"
npm pkg set scripts.docs:analyze="documcp analyze-repository --path ."
npm pkg set scripts.docs:deploy="documcp deploy-pages --repository $(git remote get-url origin | sed 's/.*github.com[:/]\([^.]*\).*/\1/')"

Method 3: Docker Installationโ€‹

# Pull the official DocuMCP Docker image
docker pull documcp/documcp:latest

# Run DocuMCP in a container
docker run -it --rm -v $(pwd):/workspace documcp/documcp:latest

๐Ÿ”ง Basic Configurationโ€‹

Environment Variablesโ€‹

Create a .env file in your project root:

# DocuMCP Configuration
export DOCUMCP_STORAGE_DIR="./.documcp"
export DOCUMCP_LOG_LEVEL="info"
export DOCUMCP_CACHE_ENABLED="true"

# GitHub Integration
export GITHUB_TOKEN="your_github_token_here"
export GITHUB_USERNAME="your_username"

# Optional: Custom configuration
export DOCUMCP_DEFAULT_SSG="docusaurus"
export DOCUMCP_DEFAULT_DEPTH="standard"

Configuration Fileโ€‹

Create a documcp.config.json file:

{
"storage": {
"directory": "./.documcp",
"enableCache": true,
"maxCacheSize": "100MB"
},
"github": {
"token": "${GITHUB_TOKEN}",
"username": "${GITHUB_USERNAME}",
"defaultBranch": "main"
},
"defaults": {
"ssg": "docusaurus",
"analysisDepth": "standard",
"includeExamples": true,
"targetAudience": "community_contributors"
},
"memory": {
"enableLearning": true,
"retentionDays": 90,
"enableAnalytics": true
}
}

๐Ÿ—๏ธ Project Structure Setupโ€‹

your-project/
โ”œโ”€โ”€ .documcp/ # DocuMCP storage and cache
โ”‚ โ”œโ”€โ”€ memory/ # Memory system data
โ”‚ โ”œโ”€โ”€ cache/ # Analysis cache
โ”‚ โ””โ”€โ”€ config/ # Local configuration
โ”œโ”€โ”€ docs/ # Generated documentation
โ”‚ โ”œโ”€โ”€ api/ # API documentation
โ”‚ โ”œโ”€โ”€ tutorials/ # Tutorial content
โ”‚ โ”œโ”€โ”€ how-to/ # How-to guides
โ”‚ โ”œโ”€โ”€ reference/ # Reference documentation
โ”‚ โ””โ”€โ”€ explanation/ # Explanatory content
โ”œโ”€โ”€ src/ # Source code
โ”œโ”€โ”€ README.md # Project README
โ”œโ”€โ”€ documcp.config.json # DocuMCP configuration
โ”œโ”€โ”€ .env # Environment variables
โ””โ”€โ”€ package.json # Node.js dependencies

Initialize DocuMCP in Your Projectโ€‹

# Initialize DocuMCP in your project
documcp init

# This creates:
# - .documcp/ directory
# - documcp.config.json
# - .env template
# - .gitignore entries

๐Ÿ” GitHub Integration Setupโ€‹

GitHub Token Setupโ€‹

  1. Create a GitHub Personal Access Token:

    Go to GitHub โ†’ Settings โ†’ Developer settings โ†’ Personal access tokens โ†’ Tokens (classic)

    Required permissions:

    • repo (Full control of private repositories)
    • pages (Write access to GitHub Pages)
    • workflow (Update GitHub Action workflows)
    • read:org (Read organization membership)
  2. Set the token in your environment:

    # Add to your shell profile (.bashrc, .zshrc, etc.)
    export GITHUB_TOKEN="ghp_your_token_here"

    # Or add to .env file
    echo "GITHUB_TOKEN=ghp_your_token_here" >> .env
  3. Verify GitHub integration:

    # Test GitHub connection
    documcp github test

    # Should output: โœ… GitHub connection successful

GitHub Pages Setupโ€‹

  1. Enable GitHub Pages in your repository:

    Go to your repository โ†’ Settings โ†’ Pages

    • Source: GitHub Actions
    • Branch: main (or your preferred branch)
  2. Configure deployment:

    # Configure GitHub Pages deployment
    documcp github configure-pages --repository "username/repository"

๐Ÿง  Memory System Setupโ€‹

Initialize Memory Systemโ€‹

# Initialize memory system with custom storage
documcp memory init --storage-dir ./.documcp/memory

# Initialize with specific configuration
documcp memory init --storage-dir ./.documcp/memory --enable-learning --retention-days 90

Memory System Configurationโ€‹

Create a memory configuration file:

{
"storage": {
"directory": "./.documcp/memory",
"enableCompression": true,
"maxSize": "500MB"
},
"learning": {
"enabled": true,
"retentionDays": 90,
"enableAnalytics": true,
"enablePatternRecognition": true
},
"userPreferences": {
"enablePersonalization": true,
"defaultUserId": "developer123"
}
}

Memory System Testingโ€‹

# Test memory system
documcp memory test

# Check memory statistics
documcp memory stats

# Export memories for backup
documcp memory export --format json --output ./documcp-memories-backup.json

๐Ÿ”ง Advanced Configurationโ€‹

Custom SSG Configurationโ€‹

# Configure custom SSG settings
documcp config set --key "ssg.docusaurus.theme" --value "classic"
documcp config set --key "ssg.hugo.baseURL" --value "https://docs.example.com"
documcp config set --key "ssg.mkdocs.theme" --value "material"

User Preferences Setupโ€‹

# Set user preferences
documcp preferences set --user-id "developer123" --priority performance --ecosystem javascript

# Set team preferences
documcp preferences set --user-id "team" --priority simplicity --ecosystem any

# Export preferences
documcp preferences export --user-id "developer123" --output ./preferences.json

Cache Configurationโ€‹

# Configure caching
documcp cache config --enable --max-size "200MB" --ttl "24h"

# Clear cache
documcp cache clear

# Cache statistics
documcp cache stats

๐Ÿณ Docker Setupโ€‹

Docker Compose Configurationโ€‹

Create a docker-compose.yml file:

version: "3.8"

services:
documcp:
image: documcp/documcp:latest
container_name: documcp
volumes:
- ./:/workspace
- ./documcp-data:/app/.documcp
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
- DOCUMCP_STORAGE_DIR=/app/.documcp
working_dir: /workspace
command: ["documcp", "serve", "--port", "3000", "--host", "0.0.0.0"]
ports:
- "3000:3000"

Docker Usageโ€‹

# Start DocuMCP with Docker Compose
docker-compose up -d

# Run specific commands
docker-compose exec documcp documcp analyze-repository --path .

# Stop services
docker-compose down

๐Ÿ”„ CI/CD Integrationโ€‹

GitHub Actions Setupโ€‹

Create .github/workflows/docs.yml:

name: Documentation Deployment

on:
push:
branches: [main]
paths: ["docs/**", "src/**", "README.md"]
pull_request:
branches: [main]

jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install DocuMCP
run: npm install -g documcp

- name: Analyze Repository
run: |
ANALYSIS_ID=$(documcp analyze-repository --path . --depth standard | jq -r '.data.id')
echo "analysis_id=$ANALYSIS_ID" >> $GITHUB_OUTPUT
id: analyze

- name: Validate Documentation
run: |
documcp validate-content --docs-path ./docs

deploy:
needs: analyze
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install DocuMCP
run: npm install -g documcp

- name: Deploy Documentation
run: |
documcp deploy-pages --repository ${{ github.repository }} --ssg docusaurus
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GitLab CI Setupโ€‹

Create .gitlab-ci.yml:

stages:
- analyze
- deploy

variables:
NODE_VERSION: "20"

analyze:
stage: analyze
image: node:${NODE_VERSION}-alpine
before_script:
- npm install -g documcp
script:
- documcp analyze-repository --path . --depth standard
- documcp validate-content --docs-path ./docs
artifacts:
reports:
junit: documcp-results.xml
paths:
- .documcp/
expire_in: 1 hour

deploy:
stage: deploy
image: node:${NODE_VERSION}-alpine
before_script:
- npm install -g documcp
script:
- documcp deploy-pages --repository $CI_PROJECT_PATH --ssg docusaurus
only:
- main
environment:
name: production
url: https://$CI_PROJECT_NAMESPACE.gitlab.io/$CI_PROJECT_NAME

๐Ÿ” Development Setupโ€‹

Local Developmentโ€‹

# Clone DocuMCP repository
git clone https://github.com/tosin2013/documcp.git
cd documcp

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Run tests
npm test

# Run linting
npm run lint

IDE Configurationโ€‹

VS Code Configurationโ€‹

Create .vscode/settings.json:

{
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.suggest.autoImports": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"files.associations": {
"*.mcp": "json"
}
}

VS Code Extensionsโ€‹

Recommended extensions:

  • TypeScript and JavaScript Language Features
  • ESLint
  • Prettier
  • GitLens
  • REST Client (for testing API endpoints)

๐Ÿงช Testing Setupโ€‹

Unit Testingโ€‹

# Install testing dependencies
npm install --save-dev jest @types/jest ts-jest

# Create jest.config.js
cat > jest.config.js << EOF
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.test.ts'],
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html']
};
EOF

# Run tests
npm test

Integration Testingโ€‹

# Create test repository
mkdir test-repo
cd test-repo
git init
echo "# Test Repository" > README.md
git add README.md
git commit -m "Initial commit"

# Test DocuMCP with test repository
cd ..
documcp analyze-repository --path ./test-repo --depth quick

Performance Testingโ€‹

# Run performance benchmarks
documcp benchmark run --repository ./test-repo --iterations 10

# Check performance metrics
documcp benchmark current

๐Ÿ”ง Troubleshootingโ€‹

Common Issuesโ€‹

Issue 1: Permission Deniedโ€‹

Problem: Permission denied: Cannot read directory

Solution:

# Check permissions
ls -la /path/to/repository

# Fix permissions
chmod -R 755 /path/to/repository

# Or run with sudo (not recommended for production)
sudo documcp analyze-repository --path /path/to/repository

Issue 2: GitHub Token Invalidโ€‹

Problem: GitHub authentication failed

Solution:

# Check token validity
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user

# Regenerate token with correct permissions
# Go to GitHub โ†’ Settings โ†’ Developer settings โ†’ Personal access tokens

# Update environment variable
export GITHUB_TOKEN="new_token_here"

Issue 3: Memory System Errorsโ€‹

Problem: Memory system initialization failed

Solution:

# Clear memory storage
rm -rf ./.documcp/memory

# Reinitialize memory system
documcp memory init --storage-dir ./.documcp/memory

# Check memory system status
documcp memory status

Issue 4: Build Failuresโ€‹

Problem: Documentation build failed

Solution:

# Check for syntax errors
documcp validate-content --docs-path ./docs

# Test local build
documcp test-local --docs-path ./docs --ssg docusaurus

# Check SSG configuration
cat ./docs/docusaurus.config.js

Debug Modeโ€‹

# Enable debug logging
export DOCUMCP_LOG_LEVEL="debug"

# Run with verbose output
documcp analyze-repository --path . --depth standard --verbose

# Check logs
tail -f ./.documcp/logs/documcp.log

Health Checkโ€‹

# Run comprehensive health check
documcp health-check

# Should output:
# โœ… Node.js version: v20.0.0
# โœ… npm version: 8.0.0
# โœ… Git version: 2.30.0
# โœ… GitHub token: valid
# โœ… Memory system: healthy
# โœ… Cache system: healthy

๐Ÿ“š Next Stepsโ€‹

After completing the environment setup:

  1. Read the User Onboarding Guide for usage patterns
  2. Explore Usage Examples for practical examples
  3. Check the API Reference for complete function documentation
  4. Join the GitHub Issues for community support and feature requests

๐Ÿ†˜ Getting Helpโ€‹

  • Documentation: Check the comprehensive documentation
  • GitHub Issues: Report bugs and request features
  • GitHub Discussions: Ask questions and share ideas
  • Community: Join the DocuMCP community for support

Your DocuMCP environment is now ready! ๐ŸŽ‰