- Reject JSON-RPC batches and non-object bodies before the SDK; return each
tool result once as text and bound the encoded payload (H1).
- Enable MCP only when MCP_PUBLIC_URL is set; drop the frontend URL fallback
and expose a read-only mcp_enabled public setting (M1).
- Expire never-authorized clients after 24h, cap pending registrations
globally, aggregate MCP IP limits by IPv6 /64, and limit registration
bodies to 4 KiB (M2).
- Revoke MCP grants with revoke-all-sessions and always require step-up for
administrator write grants (M3).
- Rate limit /api/v1/mcp per IP before authentication and write last_used_at
at most once per minute (M4).
- Persistently revoke grants when an account is disabled or demoted, derive
result redaction from SensitiveCredentialKeys, allowlist browser sessions
for step-up, audit every MCP read, reject invisible characters in
client_name, and document site-root-only deployment (L1-L5, L7).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use strconv to reject pagination values outside the native int range,
reuse PaginationParams.Offset for API key slices, and derive test bounds
from math.MaxInt. Cover parsing, response metadata, strict handlers, and
in-memory pagination at the arithmetic boundaries.
A page such as 9223372036854775807 passed every pagination check, so
(page-1)*pageSize wrapped around. With an even page size the offset
became negative and PostgreSQL rejected the query with "OFFSET must not
be negative"; paths that slice in memory (paginateSlice, balance history
merge) panicked with a negative slice bound. Both surfaced as HTTP 500 on
list endpoints such as /api/v1/admin/users, /api/v1/usage, /api/v1/keys
and /api/v1/admin/payment/orders.
- PaginationParams.Offset saturates Page at MaxInt/limit, so offset and
offset+limit both stay within int.
- ParsePagination clamps page the same way, which covers the repositories
that compute (page-1)*pageSize themselves.
- The prompt audit event list and the OpenAI token stats filter parse page
on their own; they now reject an overflowing page with 400, like other
invalid pagination input there.
Increment 5-2a of the ollama_cloud plan (backend half):
- M-1: accept provider=ollama_cloud for channel monitors (create/update
binding oneof) and request templates (create binding oneof, historical
short list intentionally not extended to the CN platforms); add the
service-side monitorProviders/probeCapableProviders entries, an OpenAI-
compatible chat adapter and merge-mode denylist entry; replace-mode body
validation intentionally stays lenient (opencode_go precedent).
- C36: route ollama_cloud accounts in TestAccountConnection to protocol-
aware probes (adaptive = CC + Anthropic + native Responses; pinned
protocols = single endpoint) instead of the Claude tester that appended
?beta=true; default the empty model to the account's first outbound
model; share the native Responses probe with opencode_go; resolve the
platform-default Anthropic base for pinned-anthropic accounts.
- C29: quota-mode monitors read the OllamaCloudUsageService snapshot from
account extra (no live fetch) and map windows/balance/plan to
MonitorQuotaSnapshot; ineligible accounts (e.g. reverse-proxy base_url)
and missing/failed snapshots yield explainable errors with the snapshot
fetched_at instead of the generic usage-query error.
- C28: verified no change needed - monitorAccountQuotaCapability already
allows ollama_cloud via its default branch.
- Pin the composite default-model candidate list: ollama_cloud explicitly
contributes no static default list (admin_group.go), aligning with
gateway_handler.
- save-time gate on admin account create/update (and AccountService, which has
no production consumers but is the spec-mandated location): non-empty
model_mapping values and empty-mapping allowed_models lists must all resolve
via GetModelPricing, otherwise 400 MODEL_PRICING_MISSING
- request-time gate: ollama_cloud accounts no longer fall into the global
zero-cost path when pricing is unavailable; explicit 4xx instead
- operational preflight SQL documented as comments (not a migration)
- include ollama_cloud in the billing model candidate filter (S1) so claude-*
names can no longer be priced at Anthropic rates for this platform
- keep ollama_cloud out of the LiteLLM platform map on purpose (comment only)
- refresh a stale comment in upstream_billing_probe.go
- C31: include ollama_cloud in SupportsNativeCNResponses so /v1/responses
ingress routes to the platform-native endpoint instead of degrading to
raw CC, and the stateless normalize hook (store=false + strip
previous_response_id) now applies to ollama accounts
- D2/C37': reject the stateful conversation field with an explicit 400
invalid_request_error on native Responses accounts instead of silently
dropping context; normalizeDeepSeekResponsesRequestBody now returns
([]byte, error) with all three production call sites propagating the
typed error as a client-visible 400
- D1': clamp max_tokens for non-DeepSeek models too on ollama.com
upstreams (raw CC, native Responses, Anthropic Messages); the host
check is the boundary, the >65535 upstream 400 is model-independent;
delete the now-dead isOllamaCloudRawChatCompletionsAccount predicate
- C39: mark ollama_cloud accounts force_responses in the Responses
probe (per-protocol, no network probe) and let the admin handler
schedule the probe for ollama_cloud accounts
POST /admin/accounts/:id/claude/reset-credits/redeem (Idempotency-Key
required, same middleware chain as the Codex reset-quota route). The server
re-queries eligibility and claims only the upstream next_grant_id when it is
redeemable; grant/org IDs never reach the client. Claims are serialized by
account and organization Redis leases, and a durable per-organization fence
in the idempotency table blocks further redemption after an unconfirmed
outcome (settles after 24h). Ported from upstream PR #7591.
Co-authored-by: korkin25 <eugeny.kuzakov@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>