agentleFS
MikeRobGITMikeRobGIT/lodgify-mcp/AGENTS.md

lodgify-mcp

AGENTS.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 AGENTS.md into the rules it gives an agent

16 rules. About 1 is common, 13 are distinctive, and 2 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    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 39
  2. Distinctive:

    When implementing new Lodgify tools, follow this modular pattern:

    line 82
  3. Distinctive:

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

    line 86
  4. Very specific:

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

    line 87
  5. Distinctive:

    Import the new tool module

    line 91
  6. Distinctive:

    Add tool to the appropriate category registration

    line 92
  7. Distinctive:

    Availability: - Check property availability for date ranges

    line 124
  8. Very specific:

    Check for Retry-After header (use if present)

    line 144
  9. Common:

    Never log raw API keys or sensitive data

    line 152
  10. Distinctive:

    Use structured logging with appropriate levels

    line 154
  11. Distinctive:

    Document key rotation procedures in README

    line 155
  12. Distinctive:

    All tools must have Zod validation schemas

    line 159
  13. Distinctive:

    When testing the MCP server during development:

    line 168
  14. Distinctive:

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

    line 170
  15. Distinctive:

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

    line 174
  16. Distinctive:

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

    line 179

≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.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
AGENTS.md

AGENTS.md

This file provides guidance to AI coding agents (e.g., Claude, Gemini, and other code assistants) 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 interfaces
  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)
bun run 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
    • 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. Error Handling:
    • Errors are automatically processed through centralized error handler
    • 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
  • Unit test coverage target: ≥90% for client code
  • Integration tests for all MCP tools
  • Clear separation between MCP server and HTTP client layers

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., your AI agent 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 AGENTS.md file.

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.