Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (99 loc) · 4.45 KB
/
Copy pathMakefile
File metadata and controls
114 lines (99 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.PHONY: run test clean install-python-deps setup venv test-pdf check-deps help
# Default target
all: setup
# Show configuration info for Claude Code
config: venv
@echo "📋 MCP Server Configuration for Claude Code:"
@echo " Command: $(PWD)/venv/bin/python"
@echo " Args: $(PWD)/mcp_document_markdown.py"
@echo
@echo "To add this server to Claude Code, run:"
@echo " claude mcp add document-markdown -- \"$(PWD)/venv/bin/python\" \"$(PWD)/mcp_document_markdown.py\""
# Test/Debug the MCP server (NOT needed for normal operation)
# IMPORTANT: This is NOT starting a daemon server! MCP stdio servers are spawned
# on-demand by Claude Code. This command is for:
# 1. Smoke testing that the server starts without errors
# 2. Displaying the configuration paths you need for Claude Code
# 3. Debugging import/dependency issues before using with Claude Code
# The server will wait for JSON-RPC input on stdin (which won't come when run manually).
# Use Ctrl+C to exit - this is expected behavior.
run: venv
@echo "🧪 Testing MCP Document-to-Markdown server (stdio mode)..."
@echo
@echo "📋 MCP Server Configuration:"
@echo " Command: $(PWD)/venv/bin/python"
@echo " Args: $(PWD)/mcp_document_markdown.py"
@echo
@echo "To add this server to Claude Code, use:"
@echo " claude mcp add document-markdown -- \"$(PWD)/venv/bin/python\" \"$(PWD)/mcp_document_markdown.py\""
@echo
@echo "ℹ️ This is a stdio server - Claude Code starts it on-demand"
@echo "💡 You don't need to keep this running. Use Ctrl+C to exit."
@echo
./venv/bin/python mcp_document_markdown.py
# Run the server in development mode (same as run for Python)
dev: run
# Create Python virtual environment if it doesn't exist
venv:
@if [ ! -d "venv" ]; then \
echo "Creating Python virtual environment..."; \
python3 -m venv venv; \
fi
# Install Python dependencies
install-python-deps: venv
@echo "Installing Python packages..."
@./venv/bin/pip install --upgrade pip
@./venv/bin/pip install -r requirements.txt || echo "Warning: Some optional packages may have failed to install"
# Clean build artifacts
clean:
rm -rf bin/
rm -rf docs/
rm -rf test_output/
rm -rf venv/
# Run Python unit tests
test: venv
@echo "Running Python tests..."
@cd python && ../venv/bin/python -m unittest discover tests -v 2>&1 | grep -E "(^test_|^OK|^FAILED|^ERROR|Ran [0-9]+ test)"
@echo "Test suite completed!"
# Test the conversion with a sample PDF
test-pdf: venv
@echo "Testing PDF conversion..."
@if [ -f "test.pdf" ]; then \
./venv/bin/python python/modular_pdf_converter.py test.pdf ./test_output; \
else \
echo "Please add a test.pdf file to test conversion"; \
fi
# Install everything needed for development
setup: install-python-deps
@echo "Running tests..."
@if $(MAKE) test; then \
echo "✅ All tests passed!"; \
echo "Setup complete! You can now run 'make run' to start the Python MCP server"; \
else \
echo "⚠️ Some tests failed, but setup is complete."; \
echo "You can still run 'make run' to start the Python MCP server"; \
exit 1; \
fi
# Check if all dependencies are installed
check-deps: venv
@echo "Checking Python installation..."
@python3 --version || (echo "Python 3 is not installed" && exit 1)
@echo "Checking Python packages in virtual environment..."
@./venv/bin/python -c "import pypdf" 2>/dev/null || echo " ⚠️ pypdf not installed"
@./venv/bin/python -c "import pdfplumber" 2>/dev/null || echo " ⚠️ pdfplumber not installed"
@./venv/bin/python -c "import fitz" 2>/dev/null || echo " ⚠️ pymupdf not installed"
@./venv/bin/python -c "import pandas" 2>/dev/null || echo " ⚠️ pandas not installed"
@./venv/bin/python -c "import PIL" 2>/dev/null || echo " ⚠️ pillow not installed"
@./venv/bin/python -c "import tiktoken" 2>/dev/null || echo " ⚠️ tiktoken not installed (optional but recommended for accurate token counts)"
@echo "Dependency check complete!"
# Help command
help:
@echo "Available targets:"
@echo " make setup - Install dependencies and run tests"
@echo " make config - Show MCP server configuration for Claude Code"
@echo " make run - Test/debug the MCP server (smoke test, not a daemon)"
@echo " make test - Run Python unit tests"
@echo " make test-pdf - Test PDF conversion with sample file"
@echo " make check-deps - Check if dependencies are installed"
@echo " make clean - Clean build artifacts"
@echo " make help - Show this help message"