Skip to main content
Glama

Tidewise

I built a small server that lets an AI assistant look up real Canadian tide and water level data, plus a command line agent and a set of test questions that check its answers. I did it because my summer 2026 co-op at Fisheries and Oceans Canada had me working with ocean data, which made me curious about the tide data they publish. I also wanted to learn how to give an AI assistant real tools (using MCP, the Model Context Protocol, a standard way for an assistant to call outside programs) and how to check that it uses them correctly.

Try it: andyhetianjun.github.io/tidewise. It has a Today page (tides and marine weather for five stations, rebuilt every 6 hours), the eval reports with a trace for every case, and example conversations step by step (from the offline model).

CI

A short clip of the demo site

How Claude does

I ran all 43 questions with Claude Sonnet 5.5 as the assistant:

Model

Right tools

Answer as expected

Grounded

Traps handled

All three

Claude Sonnet 5.5 (recorded)

40/43

37/43

38/43

15/15

31/43

Offline rule-based model

42/43

43/43

43/43

15/15

42/43

Deliberately sloppy model

42/43

28/43

3/43

0/15

3/43

How this was recorded: there was no API key, so each question was run by a separate, fresh Claude Sonnet 5.5 session that played the assistant by typing shell commands into a recording harness (RECORDING.md). The harness runs the real tools on the bundled sample, logs every call, and saves the final answer. So these are real answers from the model, recorded once, not a live API call and not a repeated run. The model's thinking between calls is not captured. The recordings are in recordings/claude-sonnet-5-5/ and you can step through each one on the demo site. To score them again: uv run tidewise eval --from-recordings recordings/claude-sonnet-5-5.

Claude handled all 15 questions with no answer correctly. It lost points on 12 of the 43. Several of those are my checks being strict about wording, not wrong answers; Where Claude slipped goes through each. The rule-based model scores higher because I wrote it against these questions, so the comparison says more about my checks than about which one is smarter. One run per question is a small sample.

Related MCP server: Kitesurf Forecast MCP

Install in one line

You need uv, a Python package tool. Nothing else to install, and no account or API key:

uvx --from git+https://github.com/andyhetianjun/tidewise tidewise ask "When is high tide in Halifax tomorrow?" --offline --model fake -v

To add the tools to an MCP client (an app that lets an assistant call tools), put this in its config:

{
  "mcpServers": {
    "tidewise": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/andyhetianjun/tidewise", "tidewise", "serve"]
    }
  }
}

Add "env": { "TIDEWISE_OFFLINE": "1" } to use the bundled sample instead of the live service. I checked both commands from an empty folder against a local copy of the repo (a real MCP client listed the seven tools and called one). I have not tried any particular desktop MCP app.

How it works

flowchart LR
    Q[question] --> A[assistant]
    A -->|calls tools over MCP| S[tidewise server]
    S --> D[(tide data and marine weather)]
    D --> S --> A
    A --> R[answer]
    R --> C{{checks: right tools, expected facts, every number came from a tool}}

The server turns public tide and weather data into seven tools. The assistant picks tools, reads what they return and writes the answer. The checks then score it. More detail is under Design and Architecture below.

Features

  • Weather alongside tides: marine forecasts and hourly weather from Environment Canada, and questions that need both.

  • Grounded answers: a check that every time, height and wind speed in an answer came from a tool, plus questions where the right answer is "I don't know".

  • Eval runner: each eval case in its own process, in parallel, with timeouts, retries and a clickable HTML report.

  • Tracing: OpenTelemetry traces of each answer (model replies and tool calls, with tokens when known) written to a local file or sent to Jaeger, and a waterfall viewer on the demo site.

What it does

You can ask "When is high tide in Halifax tomorrow?" and the assistant picks the right tool, fetches the data and answers with times and heights. The data comes from the public water level service run by the Canadian Hydrographic Service (called IWLS). The server offers seven tools:

Tool

Use it for

find_stations

Find tide gauges by name, or the nearest ones to a latitude and longitude

next_high_low_tide

The next predicted highs and lows at a station, labelled high or low

get_tide_predictions

Predicted water level curve over a time range

get_water_levels

Observed (measured) water levels over a time range

compare_observed_vs_predicted

Mean, RMS and largest gap between measured and predicted

get_marine_forecast

Marine weather text and warnings for the water at a station (Environment Canada)

get_hourly_weather

Hourly wind, temperature and rain chance near a station, about the next 24 hours

How to use it

You need uv, a Python package tool. Everything below works offline, using a small sample of real data saved in the repo.

git clone https://github.com/andyhetianjun/tidewise
cd tidewise
uv sync

uv run pytest -q
uv run tidewise eval
uv run tidewise ask "When is high tide in Halifax tomorrow?" --offline --model fake -v

The last command prints:

[tool] find_stations {'query': 'Halifax', 'limit': 3}
[tool] next_high_low_tide {'station': '00490', 'after': '2026-11-26', 'count': 6}
Tides at Halifax on 2026-11-26: low tide at 02:47 AST (0.353 m); high tide at 08:36 AST (1.977 m); low tide at 15:33 AST (-0.02 m); high tide at 21:25 AST (1.747 m).

To use live data and a real model, set an API key (only the agent needs one, not the server):

export ANTHROPIC_API_KEY=...
uv run tidewise ask "When is high tide in Halifax tomorrow?" -v

Without a key, ask falls back to a simple offline model and says so.

Use a local copy from an MCP client

If you cloned the repo, point the client at the folder instead:

{
  "mcpServers": {
    "tidewise": {
      "command": "uv",
      "args": ["run", "--directory", "/absolute/path/to/tidewise", "tidewise", "serve"]
    }
  }
}

Add "env": { "TIDEWISE_OFFLINE": "1" } to use the bundled sample instead of the live service.

There is also a Dockerfile (docker build -t tidewise .). I have not built it on my own machine; the GitHub Actions workflow builds it on every push.

Design

  • Tool inputs are typed and strict, and the docstrings become the descriptions the model reads. Errors say what to do next: bad coordinates, ranges over 7 days, unknown stations, stations that do not report a series, and a station that is listed but silent (Halifax had no observed readings in my sample).

  • A date like 2026-11-26 means that whole day in the station's local time, so "tomorrow" works. Results come back in UTC and local time.

  • Responses are cached on disk (24 hours for predictions, 10 minutes for observed data). Requests are limited to one per second, with retries on 429 and 5xx errors that respect Retry-After.

  • The tool logic is plain Python methods, kept separate from the MCP wrapper, so the data source can be swapped between the live service and the saved sample.

More detail is in docs/design.md.

Checking the answers

src/tidewise/eval_cases.json has 43 questions: 18 about tides, 5 about weather, 5 that need tides and weather together, and 15 traps where the right answer is to say it does not know. Each question names the tool that should answer it, the arguments that must match, and facts the answer must contain. I worked those facts out from the sample data by hand. Three checks run on every case: right tools, answer as expected, and grounded (nothing in the answer that no tool returned). Five traps are held out: I wrote them after the offline model was finished.

uv run tidewise eval                       # offline, rule-based model, in one process
uv run tidewise eval --model sloppy        # a careless stand-in, to see the checks catch it
uv run tidewise run-evals --out report     # one process per case, in parallel, HTML report

Measured on my machine (offline sample, rule-based model):

cases: 43
tool selection: 42/43 (98%)
answer correct: 43/43 (100%)
grounded:       43/43 (100%)
all three:      42/43 (98%)
trap cases handled (said so, invented nothing): 15/15
held-out cases, all three checks: 4/5

The sloppy stand-in calls the right tools but pads answers and never says it does not know: 42/43 tools, 28/43 answers that contain the expected facts, but only 3/43 grounded and 0/15 traps handled.

Claude's recorded run (table at the top) scores 31/43 on all three checks, 4/5 on the held-out questions. The offline model is a keyword matcher I wrote against most of these questions, so its scores show that the tools, the loop, the checks and the runner fit together, and that the checks can fail.

Where Claude slipped

These are the 12 questions Claude did not pass fully, with what it actually did (the full traces are on the demo site).

Real mistakes, small ones:

  • Observed water level in Vancouver yesterday. It reported the lowest reading as 0.79 m at the start of the day. The tool's lowest value was 0.71 m, the first reading of the next day, which the range included. It read the wrong end of the series.

  • Boat at Saint John. It said to expect strong tidal currents in the Bay of Fundy. No tool said that; it came from general knowledge. The grounding check flagged the place name.

  • Halifax predictions on 2026-11-27, kayak at Halifax, paddling at Charlottetown. It stated times no tool returned: "high near 09:30" and "low near 16:30" when the hourly points were on the hour, "slack high around 08:30" when the tool said 08:36, and a "best window to 15:30" it chose itself. They are reasonable guesses, and they are exactly what the grounding check is for.

Right answer, but my checks wanted something else:

  • Predicted levels in Vancouver. It said the low was "about 0.02 m"; the tool said 0.015. Correct rounding, but the check looks for 0.01 or 0.015.

  • Tide table for Saint John. It used the high and low tide tool instead of the hourly prediction tool. The four highs and lows it gave are right (8.55 m and 0.35 m), but the check wants the hourly table.

  • Temperature in Saint John. It gave 1 to 3 C and left out the 4 C at noon from the range I asked for, so the "1 to 4" check failed.

  • Canoe at Tofino. It said no, and gave the storm warning and the tide times, but not the exact words "not a good time".

  • Boat at Saint John. Besides the Fundy line, it said "looks calm" and wrote "6:20 am" where the check looks for "looks good" and "06:20".

  • Marine warnings for Vancouver. The grounding check flagged "12:00 UTC". That is the current time from the system prompt, which Claude used to point out that the forecast issue time looked later than now. It is a false alarm from my checker, and a sensible observation from Claude.

  • Waves in Halifax; tidal streams in Halifax Harbour. Both answers correctly say it does not know. It looked at the marine forecast (waves) or a station (streams) first, and my tool check wants no tool call for these.

Counting only the first group as real mistakes, Claude made small errors on 5 of 43 questions. That reading is mine, so treat it as a judgement, not a measurement.

Limits

  • Time zones come from the station's province code, so a few stations near borders may show the wrong local zone.

  • Tide predictions have no weather in them (the weather tools add forecasts, but only for about the next day). In the sample, observed water at Vancouver was on average 0.52 m above prediction on 2026-11-24; the comparison tool reports that, but it cannot say why.

  • Ranges are capped at 7 days and 200 points per call, to keep results small enough for a model to read.

  • Offline mode only knows five stations, five days of tides and about one day of weather. Outside that you get an error saying so.

What I would do next

  • Run each question several times and with a few phrasings, since one recorded run per question is a small sample. Relax the checks that were only strict about wording.

  • Add buoy data for wave height (a trap question today).

  • Add the current speed series some stations have.

  • Serve over streamable HTTP as well as standard input and output.

  • Look up time zones from coordinates instead of provinces.

Architecture and tests

flowchart LR
    Q[question] --> A[agent loop]
    A <-->|messages| M[Claude / offline model]
    A -->|MCP tool calls| S[tidewise MCP server]
    S --> T[TideService]
    T --> L[IWLS client: cache, rate limit, retries]
    T --> F[offline sample files]
    L --> API[(api-iwls.dfo-mpo.gc.ca)]
  • The agent connects to the server through a real MCP client running in the same process, so it sees the same tool list and schemas any other client would.

  • Tests: 132 pass (uv run pytest -q). Lint and format checks pass (uv run ruff check ., uv run ruff format --check .).

  • CI (GitHub Actions) runs lint, format check, tests, the offline eval and a Docker build. A second workflow builds the demo site and publishes it to GitHub Pages, on every push to main and every 6 hours (uv run tidewise site --out site --live). The Today page fetches live data while the site is built, shows when it was last updated, and falls back to the bundled sample for any part that does not answer; nothing fetched is committed.

  • Tide data comes from Fisheries and Oceans Canada through the public IWLS API. Weather comes from Environment and Climate Change Canada through the MSC GeoMet API, under the Open Government Licence - Canada. Please check their terms before heavy use.

MIT licensed.

Available Tools

7 tools
compare_observed_vs_predictedA

Compare measured water levels with the predicted tide.

    Returns the average difference, root-mean-square difference and the
    largest gap (observed minus predicted). Large gaps usually come from
    storm surge, wind or river flow. Needs a station with both observed
    and predicted series, and a time range in the past.

    Args:
        station: Station code or name.
        start: Start time (same formats as get_water_levels).
        end: End time. At most 7 days after start.
    

Inputs: end (required), start (required), station (required).

find_stationsA

Find tide gauge stations by place name, or the nearest ones to a point.

    Give `query` (for example "Halifax" or "Saint John"), or both `latitude`
    and `longitude`. With coordinates, results are sorted by distance. Each
    result has the station `code` to use in the other tools, its time zone,
    and which data series it has: wlo (observed water level), wlp (predicted
    water level), wlp-hilo (predicted high and low tides).

    Args:
        query: Part of a station name. Case does not matter.
        latitude: Degrees north, -90 to 90. Needs longitude.
        longitude: Degrees east, -180 to 180 (west is negative). Needs latitude.
        limit: How many stations to return, 1 to 20.
        max_distance_km: Drop stations farther than this from the point.
        include_inactive: Also list stations that are not operating.
    

Inputs: limit, query, latitude, longitude, +2 more.

get_hourly_weatherA

Get the hourly weather forecast near a station: wind, temperature, rain chance.

    Uses the nearest Environment Canada city forecast point. Wind is given in
    km/h and in knots. The forecast only covers about the next 24 hours; the
    error tells you the window if you ask outside it. Also returns sunrise
    and sunset. For a marine warning or the wind over open water, use
    get_marine_forecast as well.

    Args:
        station: Station code like "00490" or a name like "Halifax".
        start: Start time. "2026-11-26T06:00" (station local time),
            "2026-11-26T11:00:00Z" (UTC), a date alone (start of that
            local day) or "now".
        end: End time, same formats. A date alone means the end of that day.
            Defaults to 24 hours after start.
    

Inputs: station (required), end, start.

get_marine_forecastA

Get the Environment Canada marine weather forecast for the water at a station.

    Returns the text forecast for the marine area the station is in: wind
    (in knots), weather, visibility, air temperature, freezing spray, and any
    marine warnings such as gale or small craft warnings. The forecast
    covers roughly the next 24 to 36 hours and is only for the next day or
    so. There is no forecast for inland stations, and some areas have none
    in winter. Use get_hourly_weather for wind hour by hour.

    Args:
        station: Station code like "00490" or a name like "Halifax".
    

Inputs: station (required).

get_tide_predictionsA

Get predicted water levels (the tide table curve) for a station.

    Same inputs and output shape as get_water_levels. Predictions come from
    harmonic analysis and do not include weather. To find just the next high
    and low tides, next_high_low_tide is shorter.

    Args:
        station: Station code like "00490" or a name like "Halifax".
        start: Start time. "2026-11-26" (whole local day), "2026-11-26T08:00"
            (station local time), "2026-11-26T12:00:00Z" (UTC) or "now".
        end: End time, same formats. A date alone means the end of that day.
            At most 7 days after start.
        resolution_minutes: 15 or 60. At most 200 points are returned.
    

Inputs: end (required), start (required), station (required), resolution_minutes.

get_water_levelsA

Get observed (measured) water levels for a station over a time range.

    Returns a summary (highest, lowest, mean) and the points. Some stations
    do not report observed levels, and a station can go quiet for a while;
    the error says so. For the future, use get_tide_predictions instead.

    Args:
        station: Station code like "07735" or a name like "Vancouver".
        start: Start time. "2026-11-24" (whole local day), "2026-11-24T08:00"
            (station local time), "2026-11-24T16:00:00Z" (UTC) or "now".
        end: End time, same formats. A date alone means the end of that day.
            At most 7 days after start.
        resolution_minutes: 15 or 60. At most 200 points are returned.
    

Inputs: end (required), start (required), station (required), resolution_minutes.

next_high_low_tideA

List the next predicted high and low tides at a station.

    Each event says whether it is a high or a low, the time (UTC and local)
    and the height. To answer "when is high tide tomorrow", pass
    after="<tomorrow's date>" and read the events that fall on that day;
    ask for enough events (count=6 or more) to cover the whole day.

    Args:
        station: Station code like "00490" or a name like "Halifax".
        after: Where to start looking: "now", a date, or a date and time.
        count: How many events to return, 1 to 12.
    

Inputs: station (required), after, count.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool targets a clearly distinct operation: station discovery, observed levels, predicted curve, high/low events, comparison, marine forecast, and hourly weather. Descriptions explicitly cross-reference related tools (e.g., get_tide_predictions vs next_high_low_tide) to clarify boundaries.

    Naming Consistency4/5

    Consistent snake_case with verb_noun pattern for most tools (find_stations, get_water_levels, compare_observed_vs_predicted). One deviation: next_high_low_tide is a noun phrase rather than a verb-led name, but overall the pattern is predictable.

    Tool Count5/5

    7 tools is well within the ideal 3-15 range. Each tool covers a distinct facet of tide and weather data, and there are no redundant or filler tools.

    Completeness4/5

    Covers the core lifecycle: station discovery, observed/predicted water levels, high/low events, comparison, and weather forecasts. Minor gaps like direct station metadata or water temperature are not critical for the apparent purpose.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers