Skip to content

Latest commit

 

History

History
151 lines (110 loc) · 4.1 KB

claude-code.md

File metadata and controls

151 lines (110 loc) · 4.1 KB

Claude Code Configuration

This guide shows how to configure the MCP Document Converter (PDF and Word support) with Claude Code CLI.

Important: Python Execution in This Project

ALWAYS use this pattern to run Python scripts in this project:

# From project root (/Users/wadearnold/Documents/GitHub/wadearnold/mcp-document-markdown):
cd /Users/wadearnold/Documents/GitHub/wadearnold/mcp-document-markdown && venv/bin/python python/<script_name>.py <args>

# Example:
cd /Users/wadearnold/Documents/GitHub/wadearnold/mcp-document-markdown && venv/bin/python python/debug_pdf_extraction.py sample_document.pdf

DO NOT try these incorrect variations:

  • ❌ source venv/bin/activate && python ... (shell builtin issues)
  • ❌ ./venv/bin/python ... (path resolution issues)
  • ❌ python3 ... (wrong Python environment)
  • ❌ Changing directories then running (path confusion)

Prerequisites

  1. Install Claude Code CLI (if not already installed)

  2. Setup the MCP server:

    cd /path/to/mcp-document-markdown
    make setup
  3. Get configuration details:

    make run

    This will show you the exact command and args paths to use in the next step. Copy these values for configuration.

Configuration

Method 1: Using Claude Code CLI (Recommended)

Copy the Command and Args values from make run output and use them like this:

# Template (replace with your actual paths from 'make run'):
claude mcp add document-markdown -- "COMMAND_PATH" "ARGS_PATH"

# Real example:
claude mcp add document-markdown -- "/Users/username/Documents/mcp-document-markdown/venv/bin/python" "/Users/username/Documents/mcp-document-markdown/mcp_document_markdown.py"

📋 Copy-Paste Steps:

  1. Run make run and copy the Command path
  2. Copy the Args path
  3. Use both in quotes as shown above

⚠️ Important: Use quotes around the paths to handle spaces correctly.

With Environment Variables

claude mcp add document-markdown --env OUTPUT_DIR=./docs -- "COMMAND_PATH" "ARGS_PATH"

Method 2: Manual Configuration

Create or edit your MCP configuration file using the paths from make run:

{
  "mcpServers": {
    "document-markdown": {
      "command": "[COMMAND_FROM_MAKE_RUN]",
      "args": ["[ARGS_FROM_MAKE_RUN]"],
      "env": {
        "OUTPUT_DIR": "./docs"
      }
    }
  }
}

Management Commands

# List configured MCP servers
claude mcp list

# Get server details
claude mcp get document-markdown

# Remove the server
claude mcp remove document-markdown

Configuration Scopes

  • Local: Private to current project
  • Project: Shared via .mcp.json file
  • User: Available across all projects

Usage

Once configured, you can use these prompts in Claude Code:

PDF Examples:

Convert the PDF at ./documents/manual.pdf to markdown
Analyze the structure of ./pdfs/research-paper.pdf

Word Document Examples:

Convert the Word document at ./documents/report.docx to markdown
Analyze the structure of ./proposals/project-plan.docx

Multi-format:

Convert ./reports/quarterly.pdf and save to ./analysis/

How It Works

  • Claude Code automatically starts the Python MCP server when needed
  • Files are saved relative to your current working directory (defaults to ./docs)
  • You can override the output directory in prompts: "Convert PDF to ./my-project/docs/"
  • Multiple projects can use the same MCP server with different output locations

Troubleshooting

Server not found?

  • Verify the Python script exists: ls -la /path/to/mcp-document-markdown/mcp_document_markdown.py
  • Always use absolute paths - relative paths will fail
  • Check the exact path with pwd when in the repository directory

Python errors?

  • Verify Python dependencies: make setup
  • Test the server directly: make run

Virtual environment errors?

  • Recreate virtual environment: make clean && make setup
  • Test imports: ./venv/bin/python -c "import pypdf, pdfplumber, fitz, mcp"

For more details, see the Claude Code MCP documentation.