Skip to content

ktms mcp: drain on shutdown, clean stop, lenient bearer scheme - #111

Merged
coyl merged 1 commit into
mainfrom
fix/ktms-mcp-serve
Oct 24, 2026
Merged

coyl merged 1 commit into
mainfrom
fix/ktms-mcp-serve

Conversation

@coyl

@coyl coyl commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #110, from the review of the same code in light-tokenmeter (ai-process/light-tokenmeter#24):

  • serveMCP waits for http.Server.Shutdown before returning, so running tool calls finish before the deferred Admin API connection closes.
  • A signal (how MCP hosts stop a stdio server) exits 0 instead of printing "context canceled" with exit 1.
  • Authorization scheme matched case-insensitively, surrounding spaces tolerated; still a constant-time token compare.
  • The --listen token is checked before the admin key and any network call; --mcp-token-file without --listen is a usage error.

The HTTP server lets running calls finish before the Admin API connection
closes, and a signal ends a stdio server with exit 0. The bearer scheme is
matched without case. The MCP token is checked before the admin key and
any call, and --mcp-token-file without --listen is a usage error.
@github-actions

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedOct 24, 2026, 1:06 AM

@coyl
coyl merged commit 28e42ea into main Oct 24, 2026
10 checks passed
@coyl
coyl deleted the fix/ktms-mcp-serve branch October 24, 2026 01:12
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.

1 participant