japan-transfer-mcp
Version:
Model Context Protocol (MCP) server for J-Route Planner
239 lines (238 loc) • 6.28 kB
TypeScript
/**
* MCP-optimized types for Japanese route planner.
* These types are designed to be concise and practical for LLM consumption.
*/
/**
* Simple route search query for MCP.
*/
export type McpRouteQuery = {
/** Departure station name */
from: string;
/** Arrival station name */
to: string;
/** Via stations (optional) */
via?: string[];
/** Date and time in ISO format (YYYY-MM-DDTHH:MM) */
datetime: string;
/** Search type */
searchType: 'departure' | 'arrival' | 'first' | 'last';
/** Search priority */
priority?: 'time' | 'cost' | 'transfers';
/** Maximum number of results to return */
maxResults?: number;
};
/**
* Simple station search query for MCP.
*/
export type McpStationQuery = {
/** Station name or partial name */
query: string;
/** Station types to include */
types?: ('station' | 'bus' | 'spot')[];
/** Maximum number of results */
maxResults?: number;
};
/**
* MCP route search response.
*/
export type McpRouteResponse = {
/** Search summary */
summary: {
from: string;
to: string;
searchTime: string;
totalResults: number;
};
/** List of route options */
routes: McpRoute[];
/** Search status */
status: 'success' | 'error' | 'no_results';
/** Error message if any */
error?: string;
};
/**
* Simplified route information optimized for MCP.
*/
export type McpRoute = {
/** Route ranking (1-based) */
rank: number;
/** Route characteristics */
tags: ('fastest' | 'cheapest' | 'fewest_transfers' | 'recommended')[];
/** Overall timing */
time: {
/** Departure time (HH:MM format) */
departure: string;
/** Arrival time (HH:MM format) */
arrival: string;
/** Total duration in minutes */
duration: number;
};
/** Fare information */
fare: {
/** Total fare in yen */
total: number;
/** Fare breakdown by transport type */
breakdown?: {
train?: number;
bus?: number;
other?: number;
};
};
/** Transfer information */
transfers: {
/** Number of transfers */
count: number;
/** Total transfer time in minutes */
totalTime: number;
};
/** Route segments */
segments: McpSegment[];
/** Important notices */
notices?: string[];
};
/**
* Route segment (station or transport).
*/
export type McpSegment = {
/** Segment type */
type: 'station' | 'transport' | 'transfer';
/** Segment details */
details: McpStationSegment | McpTransportSegment | McpTransferSegment;
};
/**
* Station segment information.
*/
export type McpStationSegment = {
/** Station name */
name: string;
/** Station role in route */
role: 'origin' | 'destination' | 'transfer';
/** Platform information */
platform?: string;
/** Time at station */
time?: string;
};
/**
* Transport segment information.
*/
export type McpTransportSegment = {
/** Transport type */
type: 'train' | 'subway' | 'bus' | 'walk';
/** Line name */
line: string;
/** Direction/destination */
direction?: string;
/** Operator */
operator?: string;
/** Departure station */
from: {
name: string;
time: string;
platform?: string;
};
/** Arrival station */
to: {
name: string;
time: string;
platform?: string;
};
/** Travel time in minutes */
duration: number;
/** Fare for this segment */
fare?: number;
/** Distance */
distance?: string;
/** Service notices */
notices?: string[];
};
/**
* Transfer segment information.
*/
export type McpTransferSegment = {
/** Transfer time in minutes */
duration: number;
/** Wait time in minutes */
waitTime?: number;
/** Transfer instructions */
instructions?: string;
};
/**
* Station search response.
*/
export type McpStationResponse = {
/** Search query */
query: string;
/** Found stations */
stations: McpStation[];
/** Search status */
status: 'success' | 'error' | 'no_results';
/** Error message if any */
error?: string;
};
/**
* Station information.
*/
export type McpStation = {
/** Station name */
name: string;
/** Station type */
type: 'station' | 'bus' | 'spot';
/** Prefecture */
prefecture?: string;
/** City */
city?: string;
/** Reading (hiragana/katakana) */
reading?: string;
/** Geographic coordinates */
location?: {
latitude: number;
longitude: number;
};
};
/**
* MCP function parameters for route search.
*/
export type McpRouteSearchParams = {
/** Departure station name */
from_station: string;
/** Arrival station name */
to_station: string;
/** Date and time in ISO format (YYYY-MM-DDTHH:MM) */
datetime: string;
/** Search type: departure, arrival, first, last */
datetime_type: 'departure' | 'arrival' | 'first' | 'last';
/** Via stations (optional, comma-separated) */
via_stations?: string;
/** Search priority (optional) */
priority?: 'time' | 'cost' | 'transfers';
/** Maximum number of results (optional, default 3) */
max_results?: number;
};
/**
* MCP function parameters for station search.
*/
export type McpStationSearchParams = {
/** Station name or partial name to search */
query: string;
/** Station types to include (optional, comma-separated) */
types?: string;
/** Maximum number of results (optional, default 10) */
max_results?: number;
};
/**
* MCP function parameters for route search by coordinates.
*/
export type McpRouteSearchByGeoParams = {
/** Departure latitude,longitude */
from_latlng: string;
/** Arrival latitude,longitude */
to_latlng: string;
/** Date and time in ISO format (YYYY-MM-DDTHH:MM) */
datetime: string;
/** Search type: departure, arrival, first, last */
datetime_type: 'departure' | 'arrival' | 'first' | 'last';
/** Search priority (optional) */
priority?: 'time' | 'cost' | 'transfers';
/** Maximum number of results (optional, default 3) */
max_results?: number;
};