Bangalore BMTC Mobility Connectivity Platform
班加罗尔 BMTC MCP 服务器
为班加罗尔都市运输公司 (BMTC) 公交服务实施购物中心连接器程序 (MCP) 服务器。
建筑学

BMTC MCP 服务器采用模块化分层架构,有效分离关注点并提升可维护性。该系统旨在处理班加罗尔都市交通公司公交车的实时交通数据,并通过标准化 API 提供。
核心组件
API 层:用于身份验证、路线、站点、公交车位置和预计到达时间 (ETA) 信息的 RESTful 端点
服务层:业务逻辑、数据转换和ETA计算
数据访问层:通过 Mongoose ODM 集成 MongoDB
缓存层:基于 Redis 的缓存,以提高性能
外部集成层:BMTC API 集成
Related MCP server: poa-bus-mcp
特征
实时公交车位置追踪
路线信息和时间安排
停靠站详情和预计到达时间 (ETA)
支持班加罗尔 2,200 多条公交线路和 8,400 多个公交车站
身份验证和授权
数据缓存和优化
附近站点和公交车的地理空间查询
先决条件
Node.js(v14 或更高版本)
npm 或 yarn
MongoDB
Redis(可选,用于缓存)
Git
安装和设置
方法 1:标准安装
克隆存储库
git clone https://github.com/ajeetraina/bengaluru-bmtc-mcp.git
cd bengaluru-bmtc-mcp安装依赖项
npm install配置环境变量
cp .env.example .env使用您的配置编辑.env文件:
PORT=3000
NODE_ENV=development
MONGO_URI=mongodb://localhost:27017/bmtc-mcp
REDIS_URI=redis://localhost:6379
API_KEY=your_api_key_here
JWT_SECRET=your_jwt_secret_here
JWT_EXPIRES_IN=86400
BMTC_API_ENDPOINT=https://bmtc-api-endpoint.example
BMTC_API_KEY=your_bmtc_api_key_here
CACHE_DURATION=300
LOG_LEVEL=info使用模拟数据填充数据库(可选)
node src/scripts/seed.js启动服务器
npm start对于自动重启的开发:
npm run dev方法 2:使用 Docker Compose
克隆存储库
git clone https://github.com/ajeetraina/bengaluru-bmtc-mcp.git
cd bengaluru-bmtc-mcp配置环境变量(可选)
可以直接在docker-compose.yml文件中修改环境变量,或者创建.env文件:
cp .env.example .env构建并启动容器
docker-compose up -d这将启动三个容器:
bmtc-mcp-api:Node.js API 服务器bmtc-mcp-mongo:MongoDB 数据库bmtc-mcp-redis:Redis缓存服务器
使用模拟数据填充数据库(可选)
docker-compose exec api node src/scripts/seed.js查看日志
docker-compose logs -f api停止容器
docker-compose down要删除卷:
docker-compose down -v使用 API
服务器运行后,您可以访问以下 API:
http://localhost:3000/api/v1如需 API 文档,请访问:
http://localhost:3000/api-docs示例 API 端点
# Authentication
POST /api/v1/auth/login
GET /api/v1/auth/me
# Routes
GET /api/v1/routes
GET /api/v1/routes/:routeId
GET /api/v1/routes/search?source=Kempegowda&destination=Electronic
# Stops
GET /api/v1/stops
GET /api/v1/stops/:stopId
GET /api/v1/stops/near?lat=12.9767&lng=77.5713&radius=500
GET /api/v1/stops/search?query=Lalbagh
# Bus Locations
GET /api/v1/bus-locations
GET /api/v1/bus-locations/:busId
GET /api/v1/bus-locations/near?lat=12.9767&lng=77.5713&radius=1000
# ETA
GET /api/v1/eta/:stopId
GET /api/v1/eta/:stopId/:routeIdAPI 密钥
JWT 秘密
JWT 密钥用于签署身份验证令牌。生成一个安全的随机字符串:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"将其添加到您的.env文件中:
JWT_SECRET=your_generated_secret_hereBMTC API 密钥
对于开发,您可以使用模拟数据,而无需实际的 BMTC API 密钥:
BMTC_API_ENDPOINT=https://bmtc-api-endpoint.example
BMTC_API_KEY=your_bmtc_api_key_here对于生产,您需要直接联系 BMTC 来请求官方 API 访问权限。
发展
测试
运行测试:
npm test运行覆盖测试:
npm run test:coverage代码检查
检查代码风格:
npm run lint修复代码风格问题:
npm run lint:fix项目结构
bengaluru-bmtc-mcp/
├── .env.example # Environment variables template
├── .eslintrc.json # ESLint configuration
├── .github/ # GitHub configuration
│ └── workflows/ # GitHub Actions workflows
├── .gitignore # Git ignore file
├── CONTRIBUTING.md # Contribution guidelines
├── Dockerfile # Docker configuration
├── LICENSE # MIT License
├── README.md # Project documentation
├── docker-compose.yml # Docker Compose configuration
├── docs/ # Documentation
│ ├── api.md # API documentation
│ └── setup.md # Setup guide
├── jest.config.js # Jest configuration
├── package.json # Project dependencies
└── src/ # Source code
├── config/ # Configuration files
├── controllers/ # Request handlers
├── index.js # Application entry point
├── middlewares/ # Express middlewares
├── models/ # MongoDB models
├── public/ # Static files
├── routes/ # API routes
├── scripts/ # Utility scripts
├── services/ # External service integrations
├── tests/ # Test files
└── utils/ # Utility functions贡献
请阅读CONTRIBUTING.md了解我们的行为准则和提交拉取请求的流程的详细信息。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
致谢
This server cannot be deployed
Maintenance
Related MCP Connectors
Real-time transit stops, routes, arrivals, vehicle positions, and schedules via OneBusAway APIs.
Provide real-time transportation data including bus arrivals, train service alerts, carpark availa…
Read-only public transit departures, stop search, and city coverage for bus and train users.
Get real-time NYC bus arrivals, live vehicle locations, and service alerts. Plan trips between any…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides real-time bus and train information across 10+ cities in Malaysia, including live vehicle tracking, arrival predictions, stop search, and route discovery for public transit systems.3MIT
- AlicenseNot gradedqualityDmaintenanceAccess bus stops, routes, and real-time information for Porto Alegre's public transportation system.3MIT
- FlicenseNot gradedqualityDmaintenanceProvides real-time and scheduled bus information for Montevideo's public transport system.1-
- AlicenseAqualityDmaintenanceProvides Estonian public transport timetables, trip planning, stop search, and real-time vehicle tracking.8MIT