Bengaluru BMTC MCP server provides real-time bus tracking, routes, stops, ETA, and efficient data management for Bangalore transit.
The Bengaluru BMTC MCP Server is an open-source implementation of a Model Context Protocol (MCP) server specifically designed to facilitate the integration of real-time transit data from Bangalore Metropolitan Transport Corporation (BMTC). This server follows a modular, layered architectural design that ensures scalability and maintainability. It offers RESTful APIs for key services such as bus location tracking, route information, stop details, ETA calculations, and authentication/authorization mechanisms.
The Bengaluru BMTC MCP Server provides a comprehensive set of features tailored to enhance the operations of AI applications by leveraging real-time transit data:
The server adheres to the MCP protocol, making it compatible with various AI clients, including tools like Claude Desktop, Continue, Cursor, etc. The architecture is designed to ensure seamless integration of these clients by abstracting away backend complexities.
The MCP server architecture is structured as follows:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
The following Mermaid diagram illustrates the flow of data in the MCP server, from the AI application to the BMC TC API and finally to the backend services:
sequenceDiagram
participant AIApplication
participant MCPClient
participant MCPProtocol
participant MCPServer
participant BMTCAPI
participant BackendServices
AIApplication ->> MCPClient: Initiate Request
MCPClient ->> MCPProtocol: Process and Prepare Request
MCPProtocol ->> MCPServer: Forward Request
MCPServer ->> BMTCAPI: Fetch Data
BMTCAPI ->> MCPServer: Provide Data
MCPServer ->> BackendServices: Transform Data
BackendServices ->> MCPServer: Store Data in Cache
MCPServer ->> MCPClient: Return Processed Response
MCPClient ->> AIApplication: Forward Response
To set up the Bengaluru BMTC MCP Server, follow these detailed steps:
Clone the Repository
git clone https://github.com/ajeetraina/bengaluru-bmtc-mcp.git
cd bengaluru-bmtc-mcp
Install Dependencies
npm install
Configure Environment Variables
Create a .env
file and configure the necessary environment variables:
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
Optional: Seed the Database with Mock Data
node src/scripts/seed.js
Start the Server
npm start
For development with auto-restart:
npm run dev
Clone the Repository
git clone https://github.com/ajeetraina/bengaluru-bmtc-mcp.git
cd bengaluru-bmtc-mcp
Build and Start Containers
docker-compose up -d
Seed the Database with Mock Data (Optional)
docker-compose exec api node src/scripts/seed.js
View Logs
docker-compose logs -f api
Stop Containers
docker-compose down
To remove volumes as well:
docker-compose down -v
AI assistants can use the MCP server to provide real-time information about bus locations and ETA, allowing users to plan their journeys more efficiently. For instance, an AI assistant powered by Cursor could fetch the latest bus location data and estimate arrival times directly from the MCP server.
AI applications like Continue can integrate with the MCP server to offer personalized route recommendations based on user locations and real-time transit data. This integration enhances the user experience by providing accurate and up-to-date information about nearby bus stops and routes.
The Bengaluru BMTC MCP Server supports the following MCP clients:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ (Tools Only) | ✅ | ❌ (Prompting) | Tools Only |
Here is a sample configuration snippet for integrating the MCP server with an AI client:
{
"mcpServers": {
"bengaluruBMTCTransit": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-bengalurBMTCTransit"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
A smart home assistant powered by Continue can query the MCP server to track buses in real-time. When a user asks, “How long until my bus arrives?” the home assistant queries the server’s API and provides an accurate ETA based on the current location of the bus.
A business application using Cursor as its backend can leverage the MCP server to suggest optimal routes for employees commuting from one part of the city to another. The application fetches real-time data about traffic and bus schedules, optimizing routes dynamically based on user preferences and current conditions.
graph TD
A[AI Application] -->|MCP Client| B[MCP Layer]
B --> C[MCP Protocol Handlers & Servers]
C --> D[BMTC API Gateway]
D --> E[BMTCTransit Real-Time Data Source]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#f2d9da
A: Yes, but with limitations compared to full support for tools like Continue. Cursor can access resources and tools through the MCP server but lacks prompt capabilities.
A: Configurations determine how the client interacts with the backend services; incorrect settings or missing environment variables can lead to errors in data fetching or processing.
A: Yes, Redis-based caching is enabled for efficient management of frequently queried datasets. This improves response times and reduces load on external APIs like the BMTC API.
A: The server employs a layered architecture that includes caching mechanisms to manage high traffic and ensures smooth operation even under heavy loads.
A: In case of downtime, the API returns standard error responses. Resilience strategies are in place, such as retries with exponential backoff, to minimize disruptions to AI application workflows.
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Analyze search intent with MCP API for SEO insights and keyword categorization
MCP server for accessing and managing IMDB data with notes, summaries, and tools
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases
Connects n8n workflows to MCP servers for AI tool integration and data access