/ Каталог / Песочница / 12306-mcp
● Сообщество Joooook ⚡ Сразу

12306-mcp

автор Joooook · Joooook/12306-mcp

Query China's 12306 railway tickets via AI — search trains, check availability, and plan routes with natural language.

12306-mcp is an MCP server that connects AI assistants to China's official 12306 railway system. It supports ticket availability queries, train filtering, transit stop lookups, and multi-leg transfer planning. Runs via npx, Docker, or HTTP mode for flexible deployment.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

12306-mcp-2.replay ▶ готово
0/0

Установка

Выберите клиент

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "12306-mcp-2": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/Joooook/12306-mcp"
      ]
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "12306-mcp-2": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/Joooook/12306-mcp"
      ]
    }
  }
}

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "12306-mcp-2": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/Joooook/12306-mcp"
      ]
    }
  }
}

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "12306-mcp-2": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/Joooook/12306-mcp"
      ]
    }
  }
}

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "12306-mcp-2",
      "command": "TODO",
      "args": [
        "See README: https://github.com/Joooook/12306-mcp"
      ]
    }
  ]
}

Continue использует массив объектов серверов, а не map.

~/.config/zed/settings.json
{
  "context_servers": {
    "12306-mcp-2": {
      "command": {
        "path": "TODO",
        "args": [
          "See README: https://github.com/Joooook/12306-mcp"
        ]
      }
    }
  }
}

Добавьте в context_servers. Zed перезагружается автоматически.

claude mcp add 12306-mcp-2 -- TODO 'See README: https://github.com/Joooook/12306-mcp'

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: 12306-mcp

How to find the cheapest train between two cities with 12306-mcp

👤 Travelers planning trips within China ⏱ ~5 min beginner

Когда использовать: You need to compare train options between two Chinese cities and find the best deal.

Предварительные требования
  • 12306-mcp server running — npx -y 12306-mcp
Поток
  1. Search for available trains
    Search for trains from Beijing to Shanghai tomorrow. Show me all available options with prices and seat types.✓ Скопировано
    → A table of trains with departure times, durations, seat classes, and prices
  2. Filter by preference
    Which of these has second-class seats available and arrives before 6pm?✓ Скопировано
    → Filtered list matching the criteria

Итог: A clear comparison of train options to make a booking decision.

Подводные камни
  • Station names must match 12306's database exactly — Use the station search tool first to confirm the correct station name

Plan a multi-leg train journey with transfers using 12306-mcp

👤 Travelers heading to cities without direct trains ⏱ ~10 min beginner

Когда использовать: No direct train exists between your origin and destination.

Предварительные требования
  • 12306-mcp server running — npx -y 12306-mcp
Поток
  1. Query transfer options
    I need to get from Chengdu to Lhasa by train. Find me transfer routes with the shortest total travel time.✓ Скопировано
    → One or more transfer itineraries with intermediate stations and connection times
  2. Check availability on each leg
    Check ticket availability for each leg of the recommended route on March 15.✓ Скопировано
    → Seat availability for both legs of the journey

Итог: A complete multi-leg itinerary with confirmed availability.

Подводные камни
  • Tight transfer windows may cause missed connections — Ask Claude to filter for transfers with at least 2 hours between trains

Комбинации

Сочетайте с другими MCP — эффект x10

12306-mcp-2 + fetch

Combine train search with web fetch to check weather at your destination before booking

Find me a train from Shanghai to Hangzhou this Saturday, and check the weekend weather forecast for Hangzhou.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
query_tickets from: str, to: str, date: str Search for available train tickets between two stations 1 API call
search_stations keyword: str Look up station names and codes by keyword 1 API call
query_transfer from: str, to: str, date: str Find transfer routes when no direct train exists 1 API call
get_train_route_stations train_no: str Get all stops along a specific train's route 1 API call

Стоимость и лимиты

Во что обходится

Квота API
Depends on 12306 public API rate limits — typically sufficient for personal use
Токенов на вызов
200–800 tokens per query
Деньги
Free — queries the public 12306 API
Совет
Batch station lookups before running ticket queries to avoid redundant calls.

Безопасность

Права, секреты, радиус поражения

Хранение учётных данных: No credentials required — uses public 12306 API endpoints
Исходящий трафик: All calls go to 12306.cn official API endpoints

Устранение неполадок

Частые ошибки и исправления

Station name not found

Use the station search tool to find the exact name. Chinese station names must match the 12306 database — try both simplified Chinese and pinyin.

Проверить: Search for the station by keyword first
No trains found for the given date

12306 only sells tickets 15 days in advance. Ensure your date is within the booking window.

Проверить: Try a date within the next 15 days
Connection timeout

The 12306 API can be slow during peak booking times (e.g., Spring Festival). Retry after a few minutes.

Проверить: Test with a simple station search to confirm connectivity

Альтернативы

12306-mcp в сравнении

АльтернативаКогда использоватьКомпромисс
mcp-server-12306You want a Python-based alternative with FastAPI backend and additional price query toolsMore features (price queries, HTTP streaming) but requires Python/uv setup

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills