Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

MCP Calendar Invoice Server

A TypeScript-based Model Context Protocol (MCP) server that integrates with calendar systems to calculate working days and generate professional PDF invoices for freelancers and consultants.

TypeScript Node.js FastMCP Claude

๐ŸŒŸ Features

๐Ÿ“Š Working Days Calculation

  • Smart Business Logic: Automatically excludes weekends, holidays, and calendar events
  • Multi-Country Support: Holiday detection for 100+ countries via Nager.Date API
  • Google Calendar Integration: Excludes personal events from working days calculations
  • Detailed Breakdown: Day-by-day analysis with reasons for exclusions

๐Ÿงพ Professional Invoice Generation

  • Automated PDF Creation: Generate beautiful invoices using Puppeteer
  • Working Days Integration: Automatically calculates billable days and totals
  • Professional Templates: Modern, responsive HTML templates with print optimization
  • Multi-Currency Support: EUR, USD, and other currencies with proper formatting
  • Tax Calculations: Configurable tax rates with automatic calculations

๐Ÿ”— MCP Integration

  • 3 Powerful Tools: get_working_days, get_holidays, generate_invoice
  • Resource Access: Direct access to generated PDFs and templates via MCP resources
  • Claude Desktop Ready: Seamless integration with Claude Desktop
  • Tool + Resource Pattern: Proper MCP architecture implementation

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Claude Desktop (for MCP integration)

Installation

# Clone the repository
git clone https://github.com/Sitraka003/mcp-calendar-invoice-server.git
cd mcp-calendar-invoice-server

# Install dependencies
npm install

# Build the project
npm run build

Environment Setup

Create a .env file (optional - defaults provided):

# Google Calendar API (optional)
GOOGLE_CREDENTIALS_PATH=./credentials/google-service-account.json
GOOGLE_CALENDAR_ID=primary

# Company Information
COMPANY_NAME=FreelancePro Services
COMPANY_EMAIL=contact@freelancepro.com
COMPANY_PHONE=+33 1 23 45 67 89

# Invoice Configuration
DEFAULT_CURRENCY=EUR
DEFAULT_DAILY_RATE=500
OUTPUT_DIRECTORY=./output/invoices

Claude Desktop Configuration

Add to your Claude Desktop claude_desktop_config.json:

{
  "mcpServers": {
    "calendar-invoice-server": {
      "command": "tsx",
      "args": ["/path/to/your/project/src/index.ts"],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

๐Ÿ› ๏ธ Available MCP Tools

1. get_working_days

Calculate working days in a date range with comprehensive exclusions.

Parameters:

  • startDate (string): Start date in YYYY-MM-DD format
  • endDate (string): End date in YYYY-MM-DD format
  • countryCode (string, optional): Country for holidays (default: "FR")
  • includeCalendarEvents (boolean, optional): Exclude calendar events (default: true)
  • calendarId (string, optional): Google Calendar ID

Example:

Calculate working days from 2024-01-01 to 2024-01-31 for France

2. get_holidays

Retrieve holidays for specific countries and years with filtering options.

Parameters:

  • year (number): Year (2000-2050)
  • countryCode (string, optional): Country code (default: "FR")
  • startDate (string, optional): Filter start date
  • endDate (string, optional): Filter end date

Example:

Get French holidays for 2024 between March and June

3. generate_invoice

Generate professional PDF invoices with automatic working days calculation.

Parameters:

  • clientName (string): Client or company name
  • startDate (string): Work period start date
  • endDate (string): Work period end date
  • dailyRate (number): Daily rate in euros
  • clientAddress (string, optional): Client address
  • clientEmail (string, optional): Client email
  • description (string, optional): Work description
  • taxRate (number, optional): Tax rate as decimal (0.20 = 20%)
  • currency (string, optional): Currency code (default: "EUR")

Example:

Generate an invoice for "Acme Corporation" from 2024-01-01 to 2024-01-31 at โ‚ฌ500/day

๐Ÿ“ MCP Resources

Direct Access to Generated Content

file://templates/invoice-template.html

Access the HTML template used for invoice generation.

file://invoices/{invoice-id}.pdf

Access generated invoice PDF files by invoice ID (e.g., file://invoices/INV-2025-06-123456.pdf).

file://invoices/recent

JSON listing of recently generated invoices with metadata.

๐Ÿ—๏ธ Architecture

Tool + Resource Pattern

The server implements the proper MCP architecture:

  1. Tools perform actions (calculate working days, generate PDFs)
  2. Resources provide access to content (PDF files, templates)
  3. Workflow: Tool creates content โ†’ Returns metadata with resourceUri โ†’ Resource accessible for content

Service Architecture

src/
โ”œโ”€โ”€ index.ts              # MCP server entry point
โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ calendar.ts       # Google Calendar integration
โ”‚   โ”œโ”€โ”€ holidays.ts       # Holiday API with provider pattern
โ”‚   โ””โ”€โ”€ invoice.ts        # PDF invoice generation
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ working-days.ts   # Business days calculation
โ”‚   โ””โ”€โ”€ date-helpers.ts   # Date utility functions
โ”œโ”€โ”€ types/
โ”‚   โ”œโ”€โ”€ calendar.ts       # Calendar type definitions
โ”‚   โ”œโ”€โ”€ holidays.ts       # Holiday type definitions
โ”‚   โ””โ”€โ”€ invoice.ts        # Invoice type definitions
โ””โ”€โ”€ config/
    โ””โ”€โ”€ environment.ts    # Configuration management

๐Ÿ“Š Example Workflows

1. Working Days Analysis

User: "How many working days are there in January 2024 in France?"
โ†’ Tool: get_working_days
โ†’ Result: 23 working days (excludes weekends + New Year's Day)

2. Invoice Generation + Access

User: "Generate an invoice for Acme Corp for January 2024"
โ†’ Tool: generate_invoice (creates PDF)
โ†’ Resource: file://invoices/INV-2025-06-123456.pdf (access PDF)
โ†’ Result: Invoice metadata + direct PDF access

3. Holiday Planning

User: "Show me all French holidays in Q2 2024"
โ†’ Tool: get_holidays (with date filtering)
โ†’ Result: Easter Monday, Labour Day, Victory Day, Ascension Day, etc.

๐Ÿงช Testing

Run Tests

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Watch mode
npm run test:watch

๐Ÿ”ง Development

Available Scripts

npm run dev          # Development server with hot reload
npm run build        # Build TypeScript to JavaScript
npm run start        # Start production server
npm run test         # Run test suite
npm run clean        # Clean build artifacts

Project Structure

calendar-mcp-server/
โ”œโ”€โ”€ src/                 # Source code
โ”œโ”€โ”€ templates/           # Invoice HTML templates
โ”œโ”€โ”€ output/invoices/     # Generated PDF invoices
โ”œโ”€โ”€ credentials/         # Google API credentials (optional)
โ”œโ”€โ”€ docs/               # Documentation
โ””โ”€โ”€ tests/              # Test files

๐ŸŒ Supported Countries

The server supports holiday detection for 100+ countries including:

  • ๐Ÿ‡ซ๐Ÿ‡ท France (FR) - Default
  • ๐Ÿ‡บ๐Ÿ‡ธ United States (US)
  • ๐Ÿ‡ฌ๐Ÿ‡ง United Kingdom (GB)
  • ๐Ÿ‡ฉ๐Ÿ‡ช Germany (DE)
  • ๐Ÿ‡จ๐Ÿ‡ฆ Canada (CA)
  • ๐Ÿ‡ฆ๐Ÿ‡บ Australia (AU)
  • ๐Ÿ‡ช๐Ÿ‡ธ Spain (ES)
  • ๐Ÿ‡ฎ๐Ÿ‡น Italy (IT)
  • And many more...

๐Ÿ“‹ Requirements

System Requirements

  • Node.js 18.0.0 or higher
  • Memory: 2GB+ RAM (for PDF generation)
  • Storage: File system write access for invoice output
  • Network: Internet access for holiday API calls

Optional Integrations

  • Google Calendar API: For calendar event exclusions
  • Claude Desktop: For MCP client integration

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • FastMCP - TypeScript MCP framework
  • Nager.Date - Holiday API service
  • Google Calendar API - Calendar integration
  • Puppeteer - PDF generation
  • Claude Desktop - MCP client platform

๐Ÿ“ž Support


Built with โค๏ธ for the freelancer community using the Model Context Protocol

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages