This MCP server provides a simple interface to access Bay Area Rapid Transit (BART) departure data. It implements the Model Context Protocol (MCP) to offer structured information about BART trains, allowing users to query departure times, station information, and other transit details.
The BART MCP server can be installed using pip:
pip install mcp-bart
Alternatively, you can clone the repository and install it directly:
git clone https://github.com/username/mcp-bart.git
cd mcp-bart
pip install -e .
To start the MCP server, run the following command:
python -m mcp_bart.server
By default, the server will listen on port 8080. You can specify a different port using the --port
option:
python -m mcp_bart.server --port 9000
The server exposes endpoints that follow the MCP specification. You can query BART departures using HTTP requests:
curl http://localhost:8080/api/departures
You can filter departures by station using the station
parameter:
curl http://localhost:8080/api/departures?station=montgomery
The following stations are supported:
The server can be configured using environment variables:
BART_API_KEY
: Your BART API key (optional)BART_DEFAULT_STATION
: Default station for queriesMCP_LOG_LEVEL
: Log level (default: INFO)Example:
export BART_API_KEY="your-api-key"
export BART_DEFAULT_STATION="montgomery"
python -m mcp_bart.server
You can also create a config file at ~/.mcp-bart/config.json
:
{
"api_key": "your-api-key",
"default_station": "embarcadero",
"log_level": "DEBUG"
}
This server implements the Model Context Protocol, which means you can use any MCP-compatible client to interact with it. Here's an example using the Python MCP client:
from mcp_client import MCPClient
client = MCPClient("http://localhost:8080")
departures = client.query("departures", {"station": "montgomery"})
for departure in departures:
print(f"Train to {departure['destination']} departing at {departure['time']}")
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "bart-mcp" '{"command":"npx","args":["-y","bart-mcp"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"bart-mcp": {
"command": "npx",
"args": [
"-y",
"bart-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"bart-mcp": {
"command": "npx",
"args": [
"-y",
"bart-mcp"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect