Skip to main content
Glama
README.md
<h1 align="center">Citi Bike MCP</h1>

<p align="center">
  Ask an AI assistant where the nearest Citi Bike is.<br>
  An MCP server with one tool. It needs no API key.
</p>

---

## What it does

The server gives an assistant one tool, `nearest_citibikes`. The tool takes a location. It returns the nearest stations, with the count of e-bikes, classic bikes, and free docks at each one.

The data comes from the public [Citi Bike GBFS feeds](https://gbfs.citibikenyc.com/gbfs/gbfs.json). The tool reads the feeds on each call, so the counts are live.

## The tool

**`nearest_citibikes`**

| Input | Type | What it is |
| --- | --- | --- |
| `lat` | number | Latitude, in decimal degrees. |
| `lon` | number | Longitude, in decimal degrees. |
| `limit` | number, optional | The number of stations to return, from 1 to 50. The default is 5. |

The tool returns JSON. The stations are in order of distance, nearest first.

```json
{
  "query": { "lat": 40.7359, "lon": -73.9911, "limit": 1 },
  "stations": [
    {
      "station_id": "example-id",
      "name": "Broadway & E 14 St",
      "lat": 40.7346,
      "lon": -73.9907,
      "distance_m": 148,
      "capacity_total_docks": 66,
      "available_total_bikes": 21,
      "available_ebikes": 6,
      "available_classic_bikes": 15,
      "available_docks": 43,
      "is_renting": 1,
      "is_returning": 1,
      "last_reported": 1730000000
    }
  ]
}
```

The values in this example are not real.

## Run it

You need Node 18 or later. The server uses [Smithery](https://smithery.ai) to build and to run.

```sh
git clone https://github.com/sjhangiani12/citibike_mcp.git
cd citibike_mcp
npm install
npm run dev
```

`npm run dev` opens the server in the Smithery playground. It needs a Smithery account.

To deploy, push the repository to GitHub. Then add it at https://smithery.ai/new.

## How it works

All the code is in `src/index.ts`. Smithery loads the default export, `createServer`, which returns the MCP server.

- The tool reads `station_information.json` and `station_status.json` at the same time.
- It joins the two feeds on the station ID.
- It measures the distance to each station with the haversine formula.
- It sorts the stations by distance.

**Classic bikes.** The tool uses the `mechanical` count from the feed. If the feed has no such count, the tool subtracts the e-bikes from the total.

## Limits

- The tool covers Citi Bike only (New York City and Jersey City).
- The distance is a straight line. It is not the distance on foot.