agentleFS
MikeRobGITMikeRobGIT/lodgify-mcp/CLAUDE.md

lodgify-mcp

CLAUDE.md4 starsChanged 16 months agoMITView on GitHub

This is a Model Context Protocol (MCP) server that exposes Lodgify Public API v2 endpoints as MCP tools, enabling AI assistants to interact with Lodgify's property management system programmatically. Required environment variables in .env: When implementing new Lodgify tools, follow this modular pattern:

  • Reads credentials

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

18 rules. About 0 are common, 13 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read-only mode support for operational safety

    line 40
  2. Distinctive:

    When implementing new Lodgify tools, follow this modular pattern:

    line 83
  3. Distinctive:

    Create tool registration object with name, category, config, and handler

    line 87
  4. Very specific:

    Use closure-based getClient() to access the Lodgify orchestrator

    line 88
  5. Very specific:

    Use flexibleEnhanceResponse() or enhanceResponse() for response formatting

    line 89
  6. Distinctive:

    Import the new tool module

    line 93
  7. Distinctive:

    Add tool to the appropriate category registration

    line 94
  8. Very specific:

    Use flexibleEnhanceResponse() for backward-compatible response building

    line 103
  9. Very specific:

    Create human-readable summaries with generateSummary()

    line 106
  10. Distinctive:

    Availability: - Check property availability for date ranges

    line 134
  11. Very specific:

    Check for Retry-After header (use if present)

    line 154
  12. Distinctive:

    Never log raw API keys or sensitive data

    line 162
  13. Distinctive:

    Use structured logging with appropriate levels

    line 164
  14. Distinctive:

    Document key rotation procedures in README

    line 165
  15. Distinctive:

    All tools must have Zod validation schemas

    line 169
  16. Distinctive:

    When testing the MCP server during development:

    line 181
  17. Distinctive:

    Stop the currently running server process (Ctrl+C).

    line 183
  18. Distinctive:

    If using an MCP client (e.g., Claude or VS Code), restart the MCP session after code changes.

    line 187

≈ “Common” is an estimate: at least 1 in 5 of the 28,633 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

This is a Model Context Protocol (MCP) server that exposes Lodgify Public API v2 endpoints as MCP tools, enabling AI assistants to interact with Lodgify's property management system programmatically.

Core Architecture

Technology Stack

  • Runtime: Bun ≥ 1.3.13 (or Node.js ≥ 18)
  • Language: TypeScript
  • Protocol: MCP over stdio
  • SDK: @modelcontextprotocol/sdk
  • Validation: Zod schemas
  • HTTP Client: Native fetch with custom retry logic

Key Components

  1. MCP Server (src/server.ts)
    • Minimal entry point that initializes the modular MCP server
    • Coordinates server setup and starts the stdio transport
    • Delegates all functionality to modular components
  2. MCP Modules (src/mcp/)
    • Registry Pattern: Central registries for tools and resources
    • Tool Modules (src/mcp/tools/): Organized by category (property, booking, availability, rate, webhook, messaging)
    • Resource Modules (src/mcp/resources/): Health check and system monitoring
    • Error Handling (src/mcp/errors/): Centralized error processing and sanitization
    • Server Setup (src/mcp/server-setup.ts): Server initialization and configuration
    • Schemas (src/mcp/schemas/): Shared Zod validation schemas
    • Utils (src/mcp/utils/): TypeScript types and response enhancement utilities
    • Response Enhancement (src/mcp/utils/response/): Response builder, summary generator, suggestion generator
  3. Lodgify Orchestrator (src/lodgify-orchestrator.ts)
    • Unified API for all Lodgify endpoints (v1 and v2)
    • Centralized authentication and configuration
    • Read-only mode support for operational safety
    • Health monitoring and status reporting
  4. Core Modules (src/core/)
    • HTTP client (src/core/http/) with retry and rate limiting
    • Error handling (src/core/errors/) with structured error types
    • Rate limiter (src/core/rate-limiter/) with sliding window implementation
    • Retry logic (src/core/retry/) with exponential backoff
  5. API Modules (src/api/v1/, src/api/v2/)
    • Modular API client implementations
    • TypeScript interfaces for all endpoints
    • Specialized clients for bookings, properties, rates, webhooks, etc.

Development Commands

# Initial setup
bun install
cp .env.example .env  # Configure LODGIFY_API_KEY

# Development
bun dev              # Run TypeScript directly (Bun has built-in TS support)
bun run build        # Compile TypeScript to dist/
bun run test         # Run unit tests (isolated per file; plain `bun test` can leak mocks)
bun test --watch     # Run tests in watch mode
bun run lint         # Run ESLint
bun run typecheck    # Run TypeScript type checking

# Production
bun start            # Run compiled server from dist/

Environment Configuration

Required environment variables in .env:

  • LODGIFY_API_KEY: Your Lodgify API key (required)
  • LOG_LEVEL: Logging level (error|warn|info|debug, default: info)
  • DEBUG_HTTP: Set to "1" for verbose HTTP debugging (optional)

Tool Implementation Pattern

When implementing new Lodgify tools, follow this modular pattern:

  1. Tool Module Creation in appropriate category file (src/mcp/tools/[category]-tools.ts):
    • Define Zod schema for input validation
    • Create tool registration object with name, category, config, and handler
    • Use closure-based getClient() to access the Lodgify orchestrator
    • Use flexibleEnhanceResponse() or enhanceResponse() for response formatting
    • Export tool registration for the registry
  2. Registry Integration in src/mcp/tools/register-all.ts:
    • Import the new tool module
    • Add tool to the appropriate category registration
    • Tools are automatically registered when server starts
  3. Client Method in lodgify-orchestrator.ts:
    • Build URL with path parameters
    • Pass query parameters through bracket notation flattener
    • Handle response and errors consistently
  4. Response Enhancement:
    • Use flexibleEnhanceResponse() for backward-compatible response building
    • Extract entity-specific details with extractEntityDetails()
    • Generate contextual suggestions with generateSuggestions()
    • Create human-readable summaries with generateSummary()
    • Errors are automatically processed with enhanced context and suggestions
  5. Error Handling:
    • Errors are automatically processed through centralized error handler
    • Enhanced errors include suggestions for resolution
    • Sanitization removes sensitive data before returning to user
    • McpError codes are applied based on error type

Testing Strategy

  • Unit Tests: Focus on HTTP client retry logic, query flattening, error formatting
  • Integration Tests: Mock or live test each tool with sample inputs
  • Contract Tests: Validate tool outputs against expected shapes
  • Smoke Tests: Sequential execution of all tools with test credentials

MCP Tool Catalog

For a complete reference of all available Lodgify MCP tools with detailed parameters and examples, see: @docs/TOOL_CATALOG.md

Tool Categories Summary

The server implements 30+ MCP tools across these categories:

  • Property Management - List, get, search properties and rooms
  • Booking & Reservation - Full CRUD operations for bookings, check-in/out, payment links
  • Rates & Pricing - View and update rates, get pricing quotes
  • Availability - Check property availability for date ranges
  • Messaging - Thread management for guest communications
  • Webhooks - Event subscription management
  • Resources - Health check and system status

Query Parameter Handling

The client supports bracket notation for complex nested parameters:

// Example: roomTypes[0].Id=123&guest_breakdown[adults]=2
params = {
  "roomTypes[0].Id": 123,
  "guest_breakdown[adults]": 2
}

Rate Limiting Strategy

  1. Detect 429 responses
  2. Check for Retry-After header (use if present)
  3. Otherwise use exponential backoff: 2^attempt seconds (max 30s)
  4. Maximum 5 retry attempts
  5. Log retry attempts with timing information

Security Considerations

  • API keys are loaded from environment variables only
  • Never log raw API keys or sensitive data
  • Mask PII fields in error messages and logs
  • Use structured logging with appropriate levels
  • Document key rotation procedures in README

Code Quality Standards

  • All tools must have Zod validation schemas
  • TypeScript strict mode enabled
  • Comprehensive error handling with typed errors and enhanced responses
  • Response enhancement utilities provide consistent user experience
  • Unit test coverage target: ≥90% for client code
  • Integration tests for all MCP tools with enhanced response validation
  • Clear separation between MCP server and HTTP client layers
  • Type-safe response building with EnhancedResponse interface
  • Contextual suggestions and summaries for better user guidance

Debugging

When testing the MCP server during development:

  1. Stop the currently running server process (Ctrl+C).
  2. Restart locally via:
    • bun dev (hot re-run) or
    • bun run build && bun start (from dist/).
  3. If using an MCP client (e.g., Claude or VS Code), restart the MCP session after code changes. Hot-reload is not supported.
  4. For CLI testing, re-run node dist/server.js after each change.

Task Master AI Instructions

Import Task Master's development workflow commands and guidelines, treat as if import is in the main CLAUDE.md file. @./.taskmaster/CLAUDE.md

  • The owner of the repository is mikerobgit. the repository name is lodgify-mcp (package: @mikerob/lodgify-mcp)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.