Skip to main content
Glama

redbus-mcp

Servidor MCP (Model Context Protocol) para consultar pasajes de bus interprovinciales en Perú a través de redbus.pe. Permite que asistentes de IA compatibles con MCP (Cursor, VS Code, etc.) busquen buses en lenguaje natural: "buses de Lima a Arequipa el 20 de julio".

Alcance: solo consulta (lectura). No reserva ni realiza pagos.

Herramientas expuestas

Herramienta

Qué hace

buscar_ciudades

Busca ciudades/terminales por nombre y devuelve su ID (ej. Lima = 195105).

buscar_buses

Lista buses de una ruta y fecha: empresa, tipo, horarios, duración, precios, asientos disponibles, calificación, embarque/descenso y amenidades. Acepta nombres o IDs de ciudad.

detalle_servicio

Detalle de un servicio: mapa de asientos (número, tipo, precio, disponibilidad, piso) y puntos de embarque/descenso con horas y direcciones.

Related MCP server: mcp-emtrafesa

Requisitos

  • Node.js ≥ 18 (probado en Node 22).

Instalación

npm install
npm run build

Verificación

Prueba end-to-end contra la API real de RedBus (sin capa MCP):

npm run smoke            # usa una fecha 3 días en el futuro
npm run smoke 2026-08-05 # o una fecha concreta (ISO yyyy-MM-dd)

Inspección interactiva del servidor MCP:

npm run inspector        # abre el MCP Inspector

Uso en un cliente MCP

Registra el servidor en la configuración MCP de tu cliente (el formato mcpServers es común a la mayoría). Ejemplo:

{
  "mcpServers": {
    "redbus-peru": {
      "command": "node",
      "args": ["C:\\Users\\paranda\\Documents\\Proyectos-personales\\redbus-mcp\\build\\index.js"]
    }
  }
}

Reinicia el cliente y pregunta, por ejemplo: "¿Qué buses hay de Lima a Cusco el 2026-07-20? Ordénalos por precio."

En Cursor / VS Code la configuración es equivalente (mcp.json / settings del cliente), apuntando command/args al mismo build/index.js.

Fechas

  • Entrada del usuario: ISO yyyy-MM-dd (ej. 2026-07-20).

  • Internamente el cliente convierte al formato que exige cada endpoint de RedBus (dd-MMM-yyyy para la búsqueda, ISO para el layout de asientos).

  • La fecha debe ser hoy o futura; RedBus suele vender con pocas semanas de anticipación.

Cómo funciona (arquitectura)

RedBus expone una API interna en https://www.redbus.pe/rpw/api/. Un fetch plano es rechazado (protección anti-bot), por lo que src/redbusClient.ts:

  1. Envía headers realistas de Chrome (User-Agent, Referer, Accept-Language: es-PE, etc.).

  2. Hace warm-up: visita la home para obtener cookies y las reenvía en cada llamada.

  3. Reintenta con backoff y re-hace el warm-up si detecta bloqueo (403/429/reset).

  4. Aplica un rate-limit suave entre peticiones.

Toda la lógica anti-bot está aislada en redbusClient.ts: si RedBus endurece la protección, se puede migrar ese módulo a un navegador headless (Playwright) sin tocar las herramientas.

Estructura

src/
  index.ts            # arranque del servidor MCP (stdio) + registro de tools
  redbusClient.ts     # cliente HTTP: cookies, headers, warm-up, reintentos, endpoints
  types.ts            # tipos de las respuestas de RedBus
  tools/              # buscar_ciudades, buscar_buses, detalle_servicio
  lib/                # fechas, normalización de datos, catálogo de amenidades

Aviso

Este proyecto consume una API interna no pública de RedBus con fines personales y educativos. Respeta sus términos de servicio y evita un uso intensivo (ya incluye un rate-limit suave). No está afiliado a RedBus.

Licencia

MIT

Available Tools

3 tools
buscar_busesBuscar busesA

Busca buses interprovinciales en Perú (vía RedBus) para una ruta y fecha. Acepta nombres de ciudad o IDs para origen/destino. Devuelve empresa, tipo de bus, horarios, duración, precios, asientos disponibles, calificación, punto de embarque/descenso y las amenidades, además de routeId/operatorId para consultar el detalle con 'detalle_servicio'.

ParametersJSON Schema
NameRequiredDescriptionDefault
fechaYesFecha de viaje en formato ISO yyyy-MM-dd, ej. 2026-07-20. Debe ser hoy o futura.
limiteNoMáximo de buses a devolver (por defecto 20).
origenYesID numérico de la ciudad o su nombre (ej. 195105 o 'Lima').
destinoYes
ordenar_porNoCriterio de ordenamiento de los resultados.

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the tool's return values (company, bus type, schedules, prices, etc.) and that it is a read-only search operation. It does not mention rate limits or authentication, but for a simple search tool, the transparency is adequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no wasted words. The first sentence states the core purpose, and the second provides a concise list of return values and usage guidance. Well-structured and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 5 parameters, no output schema, and the tool's complexity, the description is complete: it covers the action, parameters, return values, and how to chain with detalle_servicio. No missing context for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 80%, so the schema already documents most parameters. The description adds extra meaning by explaining that origen/destino accept names or IDs, and by detailing the output fields, including how to use results with detalle_servicio. This adds value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly specifies it searches for interprovincial buses in Peru via RedBus for a given route and date. It distinguishes itself from sibling tools (buscar_ciudades for city search, detalle_servicio for details) by explicitly mentioning that the results contain routeId/operatorId for use with detalle_servicio.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description indicates when to use (for route and date) and provides a usage hint about using detalle_servicio for more details. However, it does not explicitly state when not to use or mention alternatives beyond the implied sibling relationship.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

buscar_ciudadesBuscar ciudadesA

Busca ciudades/terminales de Perú en RedBus por nombre y devuelve su ID numérico. Necesario porque 'buscar_buses' funciona con IDs de ciudad. Devuelve también los terminales/áreas de cada ciudad.

ParametersJSON Schema
NameRequiredDescriptionDefault
textoYesNombre (o parte) de la ciudad a buscar, ej. 'Arequipa', 'Cusco', 'Lima'.
limiteNoMáximo de ciudades a devolver (por defecto 10).

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool returns numeric IDs and also terminals/areas for each city, which is adequate for a read-only search tool. However, it does not mention any potential side effects, authentication requirements, or rate limits, which could be relevant.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long, front-loaded with the core purpose and a necessary contextual note. Every sentence adds value, and there is no redundant or extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (2 parameters, no output schema), the description is complete. It explains what the tool returns (ID and terminal/area info) and provides context with the sibling tool 'buscar_buses'. No additional details are necessary for an agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage with descriptive parameter names and descriptions. The text description adds minimal additional meaning beyond the schema, mainly connecting the parameters to the overall purpose. Since schema coverage is high, a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: search for cities/terminals in Peru by name and return numeric IDs. It explicitly distinguishes itself from the sibling tool 'buscar_buses' by explaining that the latter uses city IDs, making the purpose and necessity clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: before 'buscar_buses' because that tool uses city IDs. It does not explicitly mention when not to use it or alternatives like 'detalle_servicio', but the guidance is sufficient for an agent to understand the typical workflow.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

detalle_servicioDetalle del servicio de busA

Devuelve el detalle de un servicio de bus concreto: mapa de asientos (número, tipo, precio, disponibilidad, piso) y puntos de embarque y descenso con horarios y direcciones. Requiere routeId, operatorId y los IDs de ciudad que entrega 'buscar_buses'.

ParametersJSON Schema
NameRequiredDescriptionDefault
fechaYesFecha de viaje ISO yyyy-MM-dd (la misma de la búsqueda). Debe ser hoy o futura.
routeIdYesrouteId del bus, obtenido de 'buscar_buses'.
origenIdYesID de la ciudad de origen (el mismo usado en la búsqueda).
destinoIdYesID de la ciudad de destino.
operatorIdYesoperatorId del bus, obtenido de 'buscar_buses'.
max_asientosNoLímite de asientos a listar (por defecto 60).
solo_disponiblesNoSi es true, lista solo asientos disponibles (por defecto true).

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It discloses the return content (seat map, boarding points) but does not mention error handling, side effects, or data freshness. For a read operation, it is adequate but could be more forthcoming.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences: first explains purpose, second covers prerequisites. No redundant information, front-loaded with purpose. Every part earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 7 parameters, 5 required, and no output schema, the description covers return structure (seat map fields, boarding points with times/addresses) and prerequisites. Could mention error scenarios or pagination, but overall complete enough for an action.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% (baseline 3). The description adds value beyond schemas by explaining how to obtain IDs ('obtenido de 'buscar_buses') and constraints on 'fecha' (must be same as search, today or future). Defaults for 'max_asientos' and 'solo_disponibles' are also clarified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Devuelve' and the resource 'detalle de un servicio de bus concreto', specifying that it returns seat map details and boarding/alighting points. This distinguishes it from sibling tools like 'buscar_buses' which is for searching routes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states prerequisites: 'Requiere routeId, operatorId y los IDs de ciudad que entrega 'buscar_buses'. This tells the agent when to use this tool (after searching buses) and implies it is not for initial search. No explicit when-not-to-use, but clear enough.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.0
    • First observedbuscar_buses
    • First observedbuscar_ciudades
    • First observeddetalle_servicio

TDQS

A4.1/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: buscar_ciudades retrieves city IDs, buscar_buses searches for buses, and detalle_servicio gets detailed seat maps. No overlap or ambiguity.

Naming Consistency4/5

All tools use Spanish and follow a verb_noun pattern except detalle_servicio which is noun_noun, creating a minor inconsistency. However, the naming is readable and descriptive.

Tool Count4/5

Three tools cover the core data retrieval workflow (lookup city, search buses, get details) for a bus information service. The count is appropriate, though slightly minimal.

Completeness3/5

The tools support finding cities, searching buses, and obtaining seat details, but lack booking functionality and advanced filters. Coverage is adequate for basic search but incomplete for a full booking lifecycle.

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI assistants to access Emtrafesa bus transportation services in Peru, including querying terminals, schedules, tickets, and FAQs.
    22 npm
    8
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Connects MCP-compatible AI agents to Peru's official statistics platform (INEI Estadist), providing access to Census 2017 data, population indicators, and geographic profiles for all Peruvian departments, provinces, and districts without requiring an API key.
    9
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides access to Norway's nationwide public transport data (all modes) via the Entur API, enabling queries about routes, stops, and departures through natural language.
    1 npm
    MIT