ticket-generator-mcp

ticket-generator-mcp

Enables AI agents to generate ticket IDs with QR codes, send tickets via email/SMS/WhatsApp, and retrieve event details through the Ticket Generator API.

Category
访问服务器

README

Ticket Generator MCP Server

A Model Context Protocol (MCP) server that provides AI agents with access to the Ticket Generator APIs for managing tickets and events.

Overview

This MCP server acts as a bridge between AI agents and the Ticket Generator APIs, allowing AI assistants to:

  • Generate ticket IDs with QR code images (base64 PNG)
  • Get hosted ticket URLs with optional variable field overrides
  • Send tickets via email, SMS, or WhatsApp
  • Retrieve event details for all active events on your account

Prerequisites

Quick Start

  1. Install dependencies:

    npm install
    
  2. Start the server (HTTP mode):

    npm run dev:http
    
  3. Expose locally with ngrok:

    ngrok http 3000
    
  4. Configure your MCP client with the ngrok URL and your API key:

    {
      "mcpServers": {
        "ticket-generator": {
          "url": "https://your-ngrok-url.ngrok-free.app/mcp",
          "headers": {
            "Authorization": "your_ticket_generator_api_key"
          }
        }
      }
    }
    

API Key Security

Important: In HTTP transport mode, the API key is passed securely via the Authorization header from your MCP client configuration. It is:

  • Session-specific — each client session has its own API key stored in memory
  • Transmitted securely over HTTPS (production) or ngrok tunnel (development)

In stdio transport mode, the API key is read from the TG_API_KEY environment variable.

Usage

This MCP server supports two transport modes: HTTP (for development and production deployments) and stdio (for local CLI usage). In HTTP mode the API key is securely passed from your MCP client configuration via the Authorization header. In stdio mode the key is read from the TG_API_KEY environment variable.

Local Development with ngrok

  1. Start the MCP server in HTTP mode:

    npm run dev:http
    

    This will start the server on http://localhost:3000

  2. In a separate terminal, expose your local server using ngrok:

    ngrok http 3000
    
  3. Copy the ngrok forwarding URL (e.g., https://abc123.ngrok-free.app)

  4. Configure your MCP client (Claude Desktop, Cursor, etc.) with the ngrok URL and your API key:

    {
      "mcpServers": {
        "ticket-generator": {
          "url": "https://abc123.ngrok-free.app/mcp",
          "headers": {
            "Authorization": "your_ticket_generator_api_key"
          }
        }
      }
    }
    

Production Deployment

For production deployment, follow these steps:

  1. Deploy the server to your hosting platform (AWS, DigitalOcean, etc.)

  2. Set the required environment variable:

    export MCP_TRANSPORT=http
    

    Note: The server listens on 0.0.0.0:3000 (hardcoded in server.js).

  3. Optional environment variables for production:

    • CORS_ORIGINS — comma-separated allowed origins (e.g., https://yourapp.com)
    • RATE_WINDOW_MS — rate-limit window in ms (default: 60000)
    • RATE_MAX — max requests per IP per window (default: 60)
    • JSON_LIMIT — JSON body limit (default: 200kb)
    • LOG_FORMAT — morgan log format (default: combined)
  4. Start the server:

    npm start
    
  5. Configure your MCP client with your production URL:

    {
      "mcpServers": {
        "ticket-generator": {
          "url": "https://your-production-domain.com/mcp",
          "headers": {
            "Authorization": "your_ticket_generator_api_key"
          }
        }
      }
    }
    

Server Endpoints

  • GET /health — Health check endpoint
  • POST /mcp — MCP initialization and tool call handling
  • GET /mcp — Server-to-client notifications via streaming
  • DELETE /mcp — Session termination

Available Tools

The MCP server provides the following tools for AI agents:

1. get_ticket_data

Generates a ticket ID and its QR Code image (base64 PNG) for a given event. Optionally pass a ticket category and image width.

Parameters:

  • eventId (required): The Ticket Generator Event ID for which the ticket should be created
  • width (required): QR image width/height in pixels (square). Allowed range: 300–1500. Default: 300
  • ticketCategoryId (optional): Ticket Category ID. If the event has only one category, this can be omitted

2. get_ticket_url

Returns a URL to the rendered QR Code ticket for the specified event (and optional category). You can optionally override up to 5 variable fields on the ticket design.

Parameters:

  • eventId (required): Ticket Generator Event ID
  • ticketCategoryId (optional): Ticket Category ID. Omit if the event has a single category
  • variables (optional): Array of up to 5 variable field overrides, each with:
    • value (required): Value for this variable (e.g., "Mark", "A2")
    • header (optional): Header/label for this variable (e.g., "Name", "Seat"). Leave empty to use the default label defined in the design

3. send_ticket

Sends a generated ticket to a recipient via Email, SMS, or WhatsApp. You can include subject, body, and sender details, along with up to 5 custom variable fields.

Parameters:

  • eventId (required): Ticket Generator Event ID
  • ticketCategoryId (optional): Ticket Category ID. Omit if the event has a single category
  • email (optional): Email address of the recipient (ticket will be sent here)
  • phoneNumber (optional): Recipient's phone number for SMS delivery
  • whatsApp (optional): Set true to send ticket via WhatsApp (requires phoneNumber)
  • whatsAppConsent (optional): Whether the recipient has consented to receive WhatsApp messages (required if whatsApp is true)
  • subject (optional): Subject line of the email (if email is provided)
  • body (optional): Message body (HTML or plain text) for the email/SMS/WhatsApp message
  • fromName (optional): The sender name shown to the recipient
  • variables (optional): Array of up to 5 variable fields to personalize the ticket, each with:
    • value (required): Value corresponding to the header (e.g., "A12", "Mark")
    • header (optional): Variable header label (e.g., "Seat", "Name"). Optional if default is set in design

4. get_events_details

Returns the details (name, description, start date, end date, location, ticket categories, etc.) of all active events associated with your account.

Parameters:

  • None — this tool takes no parameters and returns all active events for your API key

Integration with MCP Clients

Claude Desktop

Add this server to your Claude Desktop configuration file (claude_desktop_config.json):

{
  "mcpServers": {
    "ticket-generator": {
      "url": "https://your-server-url.com/mcp",
      "headers": {
        "Authorization": "your_ticket_generator_api_key"
      }
    }
  }
}

For local development with ngrok:

{
  "mcpServers": {
    "ticket-generator": {
      "url": "https://abc123.ngrok-free.app/mcp",
      "headers": {
        "Authorization": "your_ticket_generator_api_key"
      }
    }
  }
}

Cursor IDE

Add the server to your Cursor MCP configuration:

{
  "mcpServers": {
    "ticket-generator": {
      "url": "https://your-server-url.com/mcp",
      "headers": {
        "Authorization": "your_ticket_generator_api_key"
      }
    }
  }
}

Other MCP Clients

Any MCP-compatible client can connect to this server using HTTP transport. Configure it with:

  • URL: Your server endpoint (e.g., https://your-domain.com/mcp)
  • Authorization Header: Your Ticket Generator API key

API Endpoints

This MCP server integrates with the following Ticket Generator API endpoints (base URL: https://apis.ticket-generator.com/client/v1):

  1. POST /ticket/data — Generate a ticket ID and QR code image
  2. POST /ticket/url — Get a hosted URL for a rendered ticket
  3. POST /ticket/send — Send a ticket via email, SMS, or WhatsApp
  4. GET /event/details — Retrieve details for all active events

For detailed information about the Ticket Generator APIs, visit: https://apis.ticket-generator.com/client/api-docs/

Error Handling

The MCP server includes comprehensive error handling:

  • Invalid API keys are caught and reported
  • Network errors are handled gracefully
  • Invalid parameters are validated and error messages are provided
  • All errors are returned in a structured format for AI agents to understand

Development

Project Structure

ticket-generator-mcp/
├── server.js              # Main MCP server implementation
├── package.json           # Node.js dependencies and scripts
├── ecosystem.config.cjs   # PM2 configuration for production
├── Dockerfile             # Docker container configuration
├── deploy.sh              # ECR build/push + ECS deployment script
├── task-definition.json   # AWS ECS Fargate task definition template
├── nginx.conf             # Nginx reverse proxy configuration
├── DEPLOYMENT.md          # AWS Fargate/ECS deployment guide
├── NGINX-SETUP.md         # Nginx setup options
├── PM2-GUIDE.md           # PM2 usage guide
└── README.md              # This file

Adding New Tools

To add new tools to the MCP server:

  1. Add the tool definition to the getToolDefinitions() function
  2. Add the corresponding case in the handleToolCall() function
  3. Implement the API call using the makeTGRequest helper function

Local Development Setup

  1. Install dependencies:

    npm install
    
  2. Start the server in development mode:

    npm run dev:http
    
  3. In a separate terminal, start ngrok:

    ngrok http 3000
    
  4. Use the ngrok URL to configure your MCP client with your API key in the Authorization header

License

ISC

Support

For issues related to:

  • This MCP server: Create an issue in this repository
  • Ticket Generator APIs: Contact Ticket Generator support
  • MCP protocol: Refer to the MCP documentation

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选