# Installation and Usage Guide
## π Quick Start
### 1. Install Dependencies
```bash
cd word-doc-mcp
npm install
```
### 2. Choose Server Version
- **Basic Version**: `server-basic.js` - Original functionality, simple document reading and search
- **Full Version**: `server.js` - Complete version with all new features
### 3. Start Server
#### Basic Version
```bash
npm run start:basic
# or
node server-basic.js
```
#### Full Version
```bash
npm start
# or
node server.js
```
### 4. Configure MCP Client
Add to your MCP client configuration:
```json
{
"mcpServers": {
"word-doc-reader": {
"command": "node",
"args": ["path/to/word-doc-mcp/server.js"]
}
}
}
```
## π Feature Comparison
| Feature | Basic Version | Full Version |
|---------|---------------|--------------|
| Text Extraction | β
| β
|
| Memory Storage | β
| β
|
| Simple Search | β
| β
|
| Table Extraction | β | β
|
| Image OCR | β | β
|
| Large Document Optimization | β | β
|
| Smart Caching | β | β
|
| Full-text Index | β | β
|
| Configuration File | β | β
|
## π§ System Requirements
### Basic Version
- Node.js 14+
- 2GB RAM
- 100MB disk space
### Full Version
- Node.js 16+
- 4GB RAM (8GB+ recommended)
- 1GB disk space (for cache and temp files)
- Multi-core CPU (for parallel processing)
## βοΈ Configuration
### Basic Configuration
No configuration required, ready to use out of the box.
### Advanced Configuration
Edit the `config.json` file:
```json
{
"processing": {
"maxFileSize": 10485760,
"maxPages": 100,
"chunkSize": 1048576,
"parallelProcessing": true
},
"cache": {
"enabled": true,
"defaultTTL": 3600,
"cacheDirectory": "./.cache"
},
"ocr": {
"enabled": true,
"languages": ["chi_sim", "eng"]
}
}
```
## π Directory Structure
```
word-doc-mcp/
βββ server.js # Full version
βββ server-basic.js # Basic version
βββ package.json # Dependencies configuration
βββ config.json # Configuration file
βββ README.md # Documentation
βββ INSTALL.md # Installation guide
βββ tests/ # Test directory
βββ .cache/ # Cache directory (auto-created)
βββ output/ # Output directory (auto-created)
βββ node_modules/ # Dependencies
```
## π― Usage Examples
### 1. Read Document
```javascript
const result = await mcp.call("read_word_document", {
filePath: "./document.docx",
memoryKey: "doc1",
documentType: "api-doc",
extractTables: true,
extractImages: true,
useCache: true
});
```
### 2. Search Documents
```javascript
const searchResults = await mcp.call("search_documents", {
query: "API interface",
documentType: "api-doc",
limit: 10
});
```
### 3. Cache Management
```javascript
// View cache statistics
const stats = await mcp.call("get_cache_stats");
// Clear cache
await mcp.call("clear_cache", { type: "all" });
```
## π Troubleshooting
### Common Issues
1. **Module Installation Failure**
```bash
# Clear cache and reinstall
npm cache clean --force
npm install
```
2. **OCR Recognition Failure**
- Ensure sufficient memory
- Check supported image formats
- Try reducing image resolution
3. **Slow Large Document Processing**
- Increase `chunkSize` configuration
- Enable parallel processing
- Use SSD storage
4. **Memory Insufficient**
```bash
# Increase Node.js memory limit
node --max-old-space-size=4096 server.js
```
### Performance Optimization
1. **Enable Caching**
```json
{
"useCache": true
}
```
2. **Selective Extraction**
```json
{
"extractTables": false,
"extractImages": false
}
```
3. **Adjust Processing Parameters**
```json
{
"processing": {
"chunkSize": 2097152, // 2MB chunks
"parallelProcessing": true
}
}
```
## π Support
If you encounter issues, please:
1. Check log output
2. Confirm file paths are correct
3. Verify file format support
4. Check system resource usage
## π Upgrade Guide
### Upgrading from Basic to Full Version
1. Backup existing configuration
2. Install new dependencies:
```bash
npm install tesseract.js node-cache sharp jszip
```
3. Update startup script:
```bash
node server.js
```
4. Optional: Configure `config.json`
### Clean Old Data
```javascript
// Clear old memory cache
await mcp.call("clear_memory");
// Clear all new cache
await mcp.call("clear_cache", { type: "all" });
```