Skip to content

Warn on dead mcp.* keys (#151); gate every publisher on integration tests; :latest = latest release - #154

Merged
jrosskopf merged 9 commits into
mainfrom
fix/gh-151-mcp-port-and-release-gate
Sep 29, 2026
Merged

jrosskopf merged 9 commits into
mainfrom
fix/gh-151-mcp-port-and-release-gate

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Both decisions from the last round, in one PR to keep it to one CI run.

1. Three mcp.* keys were documented but did nothing — now they say so (closes #151)

mcp.port was documented as "the MCP server port" (default 8081). It was parsed, logged at debug
level and never read. MCP is served on the HTTP port. I ran flAPI with mcp.port: 8081: nothing
listens on 8081. That is exactly how the launch tutorial broke.

Its two neighbours in the same reference table had no reader at all:

  • mcp.host: MCP binds wherever the HTTP server binds.
  • mcp.allow-list-changed-notifications: documented as "enable listChanged", default true. But
    flAPI has no server-to-client notification transport and advertises listChanged: false
    unconditionally, so this was impossible, not just unused.

All three are handled the same way. Setting one logs a warning naming the key, why it's ignored
and what to use instead. It's not an error, and nothing about how flAPI runs changes.
It fires at parse time, so --validate-config shows it too:

[WARNING] mcp.port is set but ignored: MCP is served on the HTTP port, alongside the REST API. Set that with http-port, -p/--port or FLAPI_PORT. Remove it from the configuration.

Removed: MCPConfig::port (its only reader was the debug log), the whole unused
MCPServerConfig struct, and the unused CONTENT_TYPE_SSE constant.

Docs cleaned everywhere the keys appeared: CONFIG_REFERENCE.md, MCP_REFERENCE.md (which
contradicted itself: its table documented port while line 1597 said "there is no separate
port"), the MCP protocol spec, CLAUDE.md, and both example configs. The examples set all three
keys and would otherwise print three warnings on every startup.

2. A release now waits for its own integration tests

create-release, and the PyPI publish that depends on it, needed the builds and smoke jobs but not
integration-tests. On v26.09.26 both were live while the tag's integration suite was still
running. They now wait for it. I checked that integration-tests has no PR-only if:: a skipped
dependency would skip create-release and quietly stop every release.

Also

3. Codex review — round 1 findings, all fixed

A Codex crew review (correctness, design, usability) requested changes. Each finding was verified
against the code and a running server before fixing:

  • Docker was the third publisher the release gate missed, and the real problem was bigger:
    docker-build had no condition, so every run, pull requests included, pushed :latest
    (confirmed in a PR run's log). Now PRs push nothing, main pushes :main/:sha-*, and only a
    v* tag pushes :latest + :<tag>, gated on integration and Linux smoke tests.
  • The doc sweep missed the runnable examples. The README's docker run used a flag that
    doesn't exist (--enable-mcp exits 1), plus 8081 in eight places. The MCP guide called a
    non-existent /mcp route, and MCP_CONFIG_INTEGRATION.md posted to a non-existent
    /mcp/tools/call. All now use POST /mcp/jsonrpc on the HTTP port.
  • listChanged: true in three response examples: now false, as the server sends.
  • Running the integration doc's workflow for real exposed a product defect:
    flapi_create_endpoint keeps the endpoint in memory with no template, so the documented
    create → update → reload flow can't work. Filed as MCP config tools: an endpoint created via flapi_create_endpoint can't be given a template, persisted or served #155; the doc says so rather than
    presenting it as working.

A second Codex review covers these fix commits.

Test plan

  • Red first: test_mcp_port_ignored.py (via --validate-config) failed for all three keys
    on main. Green now, plus a case pinning no warning when none is set.
  • 794 C++ unit tests; 55 integration tests across the MCP, auth-matrix, tasks, modern-era and
    security-warning suites
  • Workflow parsed as YAML: create-release needs integration-tests; pypi-publish needs
    create-release; integration-tests runs on tags
  • Swept all docs, examples and CLAUDE.md for remaining references to the three keys

🤖 Generated with Claude Code

mcp.port was documented as "the MCP server port", default 8081. It was parsed,
logged at debug level, and never read again: MCP is served by the unified
server on the HTTP port. An operator who set it believed MCP was listening on
8081. A launch tutorial did exactly that and pointed every MCP command at 8081;
running flAPI with that config, nothing listens there - "connection refused".

Checking the rest of the same reference table turned up two more with no
reader at all, not even a parse:

  - mcp.host - MCP binds wherever the HTTP server binds;
  - mcp.allow-list-changed-notifications - documented as "enable listChanged",
    default true, but flAPI has no server-to-client notification transport and
    advertises listChanged: false unconditionally. Not just unused: impossible.

Fixing mcp.port alone would have left its siblings, so all three are handled
the same way. Setting any of them now logs a warning naming the key, why it is
ignored and what to use instead. None is an error - the configuration still
loads and flAPI behaves exactly as before. The warning is emitted at parse
time, so --validate-config shows it, which is where operators linting a
config in CI will see it.

Red first: test_mcp_port_ignored.py (via --validate-config) failed for all
three keys on main, and passes now, along with a case pinning that no warning
appears when none is set.

Removed rather than left to rot:
  - MCPConfig::port, whose only reader was the debug log line;
  - MCPServerConfig, a whole struct nothing uses (stdio_transport, mcp_port);
  - CONTENT_TYPE_SSE, defined and never used - flAPI answers MCP with JSON.

Documentation: CONFIG_REFERENCE.md (table, two examples, defaults table),
MCP_REFERENCE.md (which contradicted itself - its table documented `port`
while line 1597 said "there is no separate port"), the mcp-protocol spec,
CLAUDE.md, and both example configs, which set all three keys and would
otherwise print three warnings on every example startup.

A top-level `server: {port, host}` block has the same problem but is a
different key family; filed as #153 rather than widened into this change.

Closes #151
create-release needed the builds and all eight smoke jobs, but not
integration-tests. So the GitHub release - and the PyPI publish, which needs
create-release - could go out before the tag's own integration suite
finished, or despite it failing. On v26.09.26 it was still running when both
were already live. It passed, and the same commit had passed on main, but the
release itself was unguarded by its own test run.

integration-tests is now in create-release's needs, so it gates both.
Checked that it has no `if:` restricting it to pull requests: a skipped
dependency would skip create-release and quietly stop every release. It adds
little wall-clock - it runs alongside windows-build, the slowest job, and
normally finishes first.

Also drops the kit's local-stamping workaround for v26.09.23: v26.09.26 is
the first release carrying the stamped server.json, verified at 26.9.26.
A Codex crew review of this PR (correctness, design, usability - all three
REQUEST_CHANGES) found that the doc sweep for #151 had missed the runnable
examples, which is where the damage is done. Verified each against the code
and a running server before changing it:

  - README: the Docker command published port 8081 "for the MCP server", the
    MCP section offered `--enable-mcp` - a flag that does not exist, so the
    documented `docker run` exits 1 with "Unknown argument: --enable-mcp" -
    and seven curl examples pointed at localhost:8081. MCP is on by default
    and shares the HTTP port, so the command needs neither. The Dockerfile
    link pointed at a /docker directory that does not exist.
  - docs/guides/mcp-tools.md called http://localhost:8081/mcp. Wrong port,
    and /mcp is not a route: only /mcp/jsonrpc and /mcp/health are
    registered.
  - docs/MCP_CONFIG_INTEGRATION.md posted a bare {name, arguments} body to
    /mcp/tools/call on 8081 - neither the route nor the envelope exists. It
    now wraps each call in a tools/call JSON-RPC envelope at /mcp/jsonrpc;
    checked that the script parses as bash and emits valid JSON-RPC, and
    that the tools' real inputSchemas accept those arguments.
  - Three initialize-response examples advertised listChanged: true, which
    the server never sends.

Running that workflow against a real server exposed a product defect the
routes had been hiding: flapi_create_endpoint keeps the endpoint in memory
with no template source, so update_template tries to write the template
directory itself and reload finds no YAML. That is not a doc fix; filed as
#155, and the doc says so at the top of the script rather than presenting a
known-broken workflow as working.

Why the first sweep missed the README lines: to find bad routes it excluded
every line containing /mcp/jsonrpc - which also hid lines with the right route
and the wrong port.
The Codex review of this PR flagged that on a v* tag, docker-build needed only
linux-build, so the image was published before the tag's integration tests -
the third publisher the release gate had missed. Checking it turned up
something larger: docker-build had no condition at all, so EVERY run pushed
ghcr.io/datazoode/flapi:latest, pull requests included. Confirmed in a
pull_request run's log ("pushing manifest for ghcr.io/datazoode/flapi:latest",
2026-09-26 09:46:23). `docker run ghcr.io/datazoode/flapi` therefore pulled
whatever PR had most recently run CI - unmerged, unreviewed code.

What is pushed now:

  pull_request  nothing - the image is still built, to prove it builds; the
                registry login and the push are skipped
  push to main  :main and :sha-<commit>
  v* tag        :latest, :<tag> and :sha-<commit>

and publishing waits for integration-tests and the four Linux smoke jobs, the
same gate the GitHub release and PyPI now have. Checked every job docker-build
needs has no `if:`, so none can be skipped on a tag and cascade-skip the push.

Until the next release, :latest still points at the last PR-built image; the
next tag replaces it.
@jrosskopf jrosskopf changed the title Warn on the three mcp.* keys that never took effect (#151); gate releases on integration tests Warn on dead mcp.* keys (#151); gate every publisher on integration tests; :latest = latest release Sep 29, 2026
Both from the second Codex review of this PR; both reviewers raised each.

create-release did not need docker-build. On a v* tag an image build or push
could fail while the GitHub release and the PyPI publish (which needs
create-release) still went out - a release with no :latest or :<tag> image.
It now needs docker-build. No cycle: docker-build needs only the builds, the
tests and the smoke jobs.

The MCP_CONFIG_INTEGRATION.md script used `set -e` as its only failure check,
but a failed tool call arrives as a JSON-RPC error inside a successful HTTP
response, so curl exits 0 and the script carried on to print "Endpoint created
and configured" - after the step-2 failure the same doc warns about (#155). Each
call now checks for `error` or `result.isError` and exits on either.

Run against a real server: step 1 succeeds, step 2 reports "MCP call failed:
... Could not open template file for writing" on stderr, the script exits 1,
and the success line is never printed.
…pt fails closed

From the third Codex review of this PR.

On a v* tag, docker-build pushed :latest before create-release ran. If the
wheel build, `gh release create` or the PyPI publish then failed, :latest
pointed at a version with no GitHub release and no package. Now docker-build
pushes only the immutable :sha-<commit> image (plus :main on main), and a new
docker-promote job - needing docker-build and pypi-publish-flapi-io - adds
:latest and :<tag> to that same image with `buildx imagetools create`. No
rebuild: what gets tagged :latest is byte-for-byte the image the tests ran
against.

Verified as far as is possible without cutting a tag:
  - actionlint: the whole workflow is clean;
  - no dependency cycle across all 17 jobs, and docker-build no longer
    references :latest at all;
  - the exact promote command, run with --dry-run against the real registry
    using the :sha-<full commit> image main already pushed, resolves the
    source and yields the multi-arch index (linux/amd64 + linux/arm64 plus
    provenance). Only the push itself is untried, and that is the login step.

The doc script's jq check failed open: any non-zero jq exit - jq missing, an
empty reply, an HTML error page - was read as "no error" and the script went
on. It now requires jq up front and treats a reply that is not a JSON object
as a failure. Checked with canned responses: empty, HTML, JSON-RPC error and
isError all stop the script with exit 1; a genuine result continues; a PATH
without jq exits 1 with "this script needs jq".
…test

From the fourth Codex review of this PR.

- Promotion used :sha-<commit>, which a main run and a tag run for the SAME
  commit both write - and the tag build stamps the release version into the
  binary. If main pushed between the tag's docker-build and docker-promote,
  the release would have been published with main's build. docker-build now
  exports the digest it pushed and docker-promote tags exactly that digest.

- Two release runs could promote out of order: an older release finishing
  late (a slow approval, a re-run) moved :latest backwards. Promotions are now
  serialised (concurrency group, never cancelled), and :latest is only moved
  when this tag is the newest non-draft, non-prerelease release; the version
  tag is always pushed.

- The doc script accepted a reply like {"jsonrpc":"2.0","id":1} - a JSON
  object with neither error nor result. It now requires a positive shape: an
  object, no error, a result object, and isError not true.

Verified, as close to real as is possible without cutting a tag:
  - actionlint: clean;
  - the promote step's exact run: script, extracted from the workflow and run
    with --dry-run against the real registry and the real release list, using
    the digest of an image main already pushed: as v26.09.26 it requests
    :v26.09.26 and :latest; as v26.09.23 it requests only :v26.09.23 and warns
    that it is not the newest; with no digest it exits 1;
  - the doc script against canned replies: empty, HTML, an object with no
    result, result:null, a JSON-RPC error and isError:true all stop it; a real
    result and isError:false continue.
…ueue

From the fifth Codex review of this PR. The job-level concurrency group added
in round 4 keeps only ONE pending job, and GitHub cancels it when another
arrives: three releases in quick succession would silently drop the middle
one's promotion, leaving a GitHub release and a PyPI package with no Docker
version tag.

The suggested fix, `queue: max`, is documented only for workflow-level
concurrency, not jobs.<id>.concurrency - checked against GitHub's workflow
syntax reference - and actionlint rejects it on a job. Relying on it would risk
invalidating the whole workflow file, so the group is removed instead, and
promotion no longer needs serialising:

  1. each run tags ITS release :<tag> from the exact digest it built and
     tested. The tag is unique per release, so no other run can race it;
  2. :latest is set to the NEWEST release's image - whichever run gets there
     last - and the release list is re-read after writing, so a run that
     listed releases just before a newer one appeared corrects the stale
     :latest it wrote. If the newest release's own image is not pushed yet,
     the run leaves :latest to that release's promotion.

Every promotion now runs; the order they finish in no longer matters.

Verified by extracting the step's exact run: script from the workflow and
running it with --dry-run against the real registry and release list:
v26.09.26 (whose version tag the old pipeline never pushed) takes the
"not published yet" path and exits 0; with the newest release resolved to an
image that exists, it writes :latest, confirms the list is unchanged, and
exits 0. actionlint is clean.
From the sixth Codex review of this PR: three paths let the job report
success while :latest was not on the newest release.

  - Any `imagetools inspect` failure read as "not published yet", so a
    transient registry error - even on the image this run had pushed
    moments before - exited 0 with :latest stale. A run no longer inspects its
    own image (if it were really missing, the create fails the job), and
    inspections of other releases retry before concluding anything.
  - Exhausting the three convergence attempts exited 0. It is now an error.
  - When the newest release's image is genuinely missing because that
    release's own promotion failed, older runs skipped silently. They now
    raise a workflow warning that says to re-run that promotion.

Every path verified by running the step's exact run: script, extracted from
the workflow, against stubbed docker and gh that record each call:

  this release is newest          exit 0, :latest written once
  another release newest, exists  exit 0, :latest written once
  newest release image missing    exit 0, not written, ::warning::
  a newer release keeps appearing exit 1, ::error:: after 3 attempts
  own tag push fails              exit 1
  release list unavailable        exit 1

actionlint is clean.
@jrosskopf
jrosskopf merged commit c47fb05 into main Sep 29, 2026
23 checks passed
@jrosskopf
jrosskopf deleted the fix/gh-151-mcp-port-and-release-gate branch September 29, 2026 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp.port is documented and parsed but never read — MCP always shares the HTTP port

1 participant