cosmonautaperuviano/node-zbooks-mcp-server
If you are the rightful owner of node-zbooks-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A robust Model Context Protocol (MCP) server for seamless integration with Zoho Books API, utilizing Node.js and TypeScript.
Zoho Books MCP Server - Node.js TypeScript Implementation
A powerful Model Context Protocol (MCP) server that provides seamless integration with Zoho Books API, built with Node.js and TypeScript. This implementation offers dual-endpoint support for both Claude Desktop and OpenAI API platforms.
š Features
- Dual-Endpoint Architecture: Supports both Claude Desktop (
/sse
) and OpenAI API (/mcp
) endpoints - Type-Safe: Fully written in TypeScript with comprehensive type definitions
- Modern Node.js: Built with ES modules and latest Node.js features
- Robust Error Handling: Comprehensive error handling and logging
- Health Monitoring: Built-in health checks and monitoring
- Configurable: Flexible configuration via environment variables
- Production Ready: Includes security, CORS, rate limiting, and more
š Prerequisites
- Node.js: 18.0.0 or higher
- npm: 9.0.0 or higher
- Zoho Books Account: With API access and OAuth credentials
š ļø Installation
1. Clone and Setup
# Clone the repository
git clone <repository-url>
cd node-zbooks-mcp
# Install dependencies
npm install
# Copy environment template
cp env.example .env
2. Configure Environment
Edit .env
file with your Zoho Books credentials:
# Zoho API Configuration
ZOHO_CLIENT_ID=your_zoho_client_id_here
ZOHO_CLIENT_SECRET=your_zoho_client_secret_here
ZOHO_REFRESH_TOKEN=your_zoho_refresh_token_here
ZOHO_ORGANIZATION_ID=your_zoho_organization_id_here
ZOHO_REGION=com
# Server Configuration
NODE_ENV=development
PORT=8000
HOST=0.0.0.0
# Logging
LOG_LEVEL=info
šÆ Available Tools
The MCP server provides the following tools for Zoho Books integration:
Invoice Management
list_invoices
- List invoices with filtering and paginationget_invoice
- Get specific invoice detailscreate_invoice
- Create new invoices
Contact Management
list_contacts
- List customers and vendorsget_contact
- Get specific contact detailscreate_contact
- Create new customers/vendors
Item Management
list_items
- List products and servicesget_item
- Get specific item detailscreate_item
- Create new itemsupdate_item
- Update existing items
Sales Order Management
list_sales_orders
- List sales ordersget_sales_order
- Get specific sales order details
Expense Management
list_expenses
- List expenses with filteringget_expense
- Get specific expense detailscreate_expense
- Create new expenses
Health Check
health_check
- Test server and API connectivity
š Usage
Development Mode
# Start in dual-endpoint mode (default)
npm run dev
# Start in Claude Desktop mode only
npm run start:claude
# Start in OpenAI API mode only
npm run start:openai
# Start with dual endpoints explicitly
npm run start:dual
Production Mode
# Build the project
npm run build
# Start production server
npm start
Testing
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Health check
npm run health-check
š API Endpoints
Health Check
GET /health
Root Information
GET /
Claude Desktop (SSE)
POST /sse/
OpenAI API (JSON-RPC)
POST /mcp/
š§ Configuration
Environment Variables
Variable | Description | Default |
---|---|---|
ZOHO_CLIENT_ID | Zoho OAuth Client ID | Required |
ZOHO_CLIENT_SECRET | Zoho OAuth Client Secret | Required |
ZOHO_REFRESH_TOKEN | Zoho OAuth Refresh Token | Required |
ZOHO_ORGANIZATION_ID | Zoho Organization ID | Required |
ZOHO_REGION | Zoho region (com, eu, in, etc.) | com |
NODE_ENV | Environment mode | development |
PORT | Server port | 8000 |
HOST | Server host | 0.0.0.0 |
LOG_LEVEL | Logging level | info |
CORS_ORIGINS | Allowed CORS origins | * |
Server Modes
The server supports multiple startup modes:
# Dual endpoints (Claude + OpenAI)
npm run dev
# Claude Desktop only (STDIO)
npm run dev -- --stdio
npm run dev -- --claude-only
# OpenAI API only (HTTP)
npm run dev -- --openai-only
# Dual HTTP endpoints
npm run dev -- --dual-endpoints
šļø Project Structure
node-zbooks-mcp/
āāā src/
ā āāā config/ # Configuration management
ā āāā tools/ # MCP tool implementations
ā āāā types/ # TypeScript type definitions
ā āāā utils/ # Utility functions
ā āāā server/ # Server-specific modules
ā āāā server.ts # Main server entry point
āāā scripts/ # Build and utility scripts
āāā docs/ # Documentation
āāā tests/ # Test files
āāā dist/ # Compiled JavaScript (generated)
āāā package.json # Project configuration
āāā tsconfig.json # TypeScript configuration
āāā README.md # This file
š Security Features
- Helmet: Security headers and protection
- CORS: Configurable cross-origin resource sharing
- Rate Limiting: Configurable request rate limiting
- Input Validation: Zod-based schema validation
- Error Handling: Secure error messages in production
š Monitoring & Logging
Logging
- Winston: Structured logging with multiple transports
- Log Levels: error, warn, info, debug
- File Logging: Optional file output
- JSON Format: Structured log format for analysis
Health Checks
- API Connectivity: Tests Zoho Books API connection
- Memory Usage: Monitors memory consumption
- Uptime: Tracks server uptime
- Custom Checks: Extensible health check system
š Troubleshooting
Common Issues
-
Environment Variables Not Set
Error: Missing required environment variables
- Ensure all required variables are set in
.env
- Copy from
env.example
and fill in values
- Ensure all required variables are set in
-
Zoho API Authentication Failed
Error: Failed to refresh access token
- Verify Zoho OAuth credentials
- Check refresh token is still valid
- Ensure organization ID is correct
-
Port Already in Use
Error: EADDRINUSE: address already in use
- Change
PORT
in.env
file - Kill process using the port:
lsof -ti:8000 | xargs kill
- Change
Debug Mode
Enable debug logging:
LOG_LEVEL=debug
DEBUG=zoho-mcp:*
š Deployment
Docker (Recommended)
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist/ ./dist/
EXPOSE 8000
CMD ["node", "dist/server.js"]
PM2 Process Manager
{
"name": "zoho-mcp-server",
"script": "dist/server.js",
"instances": "max",
"exec_mode": "cluster",
"env": {
"NODE_ENV": "production",
"PORT": 8000
}
}
systemd Service
[Unit]
Description=Zoho Books MCP Server
After=network.target
[Service]
Type=simple
User=node
WorkingDirectory=/opt/zoho-mcp
ExecStart=/usr/bin/node dist/server.js
Restart=on-failure
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run linting and tests
- Submit a pull request
Development Setup
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run format
š License
MIT License - see LICENSE file for details.
š Related Links
- Zoho Books API Documentation
- Model Context Protocol Specification
- Claude Desktop Documentation
- OpenAI API Documentation
š Support
For issues and questions:
- Check the troubleshooting section
- Search existing issues
- Create a new issue
Built with ā¤ļø using Node.js, TypeScript, and the Model Context Protocol