Skip to content

docs: add needs_reauth state, reauthorize endpoint, per-client tool sync/timeout, allowed_extra_headers, and OAuth config rotation to MCP OpenAPI spec - #5723

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
07-30-docs_sync_mcp_openapi_spec_with_current_client_api
Aug 8, 2026
Merged

docs: add needs_reauth state, reauthorize endpoint, per-client tool sync/timeout, allowed_extra_headers, and OAuth config rotation to MCP OpenAPI spec#5723
Pratham-Mishra04 merged 1 commit into
devfrom
07-30-docs_sync_mcp_openapi_spec_with_current_client_api

Conversation

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Summary

This PR expands the MCP client API surface with new per-client configuration fields, a dedicated reauthorize endpoint, a needs_reauth connection state, and clarified semantics around admin discovery credentials, OAuth config rotation, and the verify-headers flow.

Changes

  • New needs_reauth connection state: Added to MCPConnectionState enum. For shared OAuth clients, this is a sticky state set when the connection credential is permanently rejected; the health monitor will not auto-recover it. For per-user clients, it is a response-only projection indicating the retained admin discovery credential needs repair while end-user tool calls continue working.

  • New POST /api/mcp/client/{id}/reauthorize endpoint: Redoes the OAuth consent flow for an already-authorized OAuth-based client without delete-and-recreate. For oauth clients it repairs a dead connection credential; for per_user_oauth clients it repairs the retained admin discovery credential (only allowed when that credential is in needs_reauth).

  • New per-client fields on create and update requests: tool_sync_interval (per-client override for the global tool-list sync interval, negative value disables), tool_execution_timeout (per-client override for the global execution timeout), and allowed_extra_headers (allowlist of request-level headers callers may forward to the MCP server at execution time).

  • New global mcp_tool_sync_interval config field: Global tool-list sync interval in minutes; per-client values override or disable it. Defaults to 10 minutes when unset.

  • OAuth config rotation via PUT /api/mcp/client/{id}: The update request now accepts an oauth_config field that rotates the stored OAuth configuration in place. When any field actually changes, all bound tokens are flipped to needs_reauth. Immutable fields (connection_type, auth_type, connection_string, stdio_config, oauth_config_id) are no longer accepted on update.

  • OAuthConfigRequest gains a resource field: RFC 8707 resource indicator sent on authorization and token requests for upstream providers that support resource indicators.

  • verify-headers semantics updated: Sample header values submitted to POST /api/mcp/client/{id}/verify-headers are now retained as the admin discovery credential for periodic tool-list refresh rather than being discarded. The endpoint now also serves as a repair path when the retained credential is in needs_update; repeat calls in any other state return 409.

  • complete-oauth endpoint clarified: The path parameter is the oauth_config_id (not the MCP client ID). The endpoint now handles both create-time flows and reauthorize flows. Replay attempts return 409.

  • state filter on GET /api/mcp/clients clarified: Only connected and disconnected are meaningful filter values; disconnected covers error, pending, needs_reauth, and disabled states. The needs_reauth projection on per-user clients happens after filtering, so those clients still match connected.

  • /api/mcp/sessions clarified: Admin discovery credentials never appear in session listings; only user-, VK-, and session-keyed rows are listed.

  • OAuth config revocation clarified: Revocation is not terminal; admins can restore access via the new reauthorize endpoint.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Validate the new reauthorize endpoint for an oauth-type MCP client:

  1. Create an OAuth-based MCP client and complete the initial OAuth flow.
  2. Revoke the OAuth config via DELETE /api/oauth/config/{id}.
  3. Confirm the client transitions to needs_reauth.
  4. Call POST /api/mcp/client/{id}/reauthorize and complete the returned flow.
  5. Confirm the client returns to connected.

Validate per-client tool_sync_interval and tool_execution_timeout by setting them on create/update and confirming they override global config values.

Validate allowed_extra_headers by forwarding a header at execution time and confirming it is accepted or rejected based on the allowlist.

Validate verify-headers repair path by updating per_user_header_keys on an existing client, confirming the admin credential flips to needs_update, then calling verify-headers with fresh values and confirming it returns to active.

Breaking changes

  • Yes
  • No

The MCPClientUpdateRequest schema removes previously accepted immutable fields (connection_type, auth_type, connection_string, stdio_config, oauth_config_id, client_id) from the update body. Clients sending those fields will need to drop them. The complete-oauth path parameter is clarified to be oauth_config_id, not the MCP client ID — callers using the MCP client ID directly will need to update.

Security considerations

  • Admin discovery credentials retained by verify-headers are never surfaced on /api/mcp/sessions and are never used for end-user traffic.
  • OAuth config rotation cascades needs_reauth to all bound tokens, forcing re-authentication; a no-op round trip does not cascade.
  • allowed_extra_headers controls which caller-supplied headers reach the upstream MCP server, limiting header injection surface.
  • The resource field on OAuthConfigRequest scopes tokens to a specific protected resource per RFC 8707, reducing token misuse risk.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This was referenced Jul 30, 2026

Pratham-Mishra04 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-30-docs_update_mcp_auth_lifecycle_docs_for_rotation_reauth_and_repair branch from eeabf77 to 68f08e8 Compare August 8, 2026 08:43
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-30-docs_sync_mcp_openapi_spec_with_current_client_api branch from c2adb1e to 1b9b96a Compare August 8, 2026 08:43
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Pratham-Mishra04 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Aug 8, 8:47 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 8, 9:57 AM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 8, 9:58 AM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@transports/bifrost-http/handlers/mcp.go`:
- Around line 1214-1218: Extend the validation around req.ToolExecutionTimeout
in the create and update handlers to reject values greater than the maximum
whole-second value representable by time.Duration, ((1 << 63) - 1) /
int64(time.Second), returning HTTP 400 before the time.Duration conversion.
Preserve the existing negative-value rejection and use the same validation
behavior for both request paths.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e9a4469e-664f-4ad0-bf7b-e2caacb1efe0

📥 Commits

Reviewing files that changed from the base of the PR and between 68f08e8 and 1b9b96a.

📒 Files selected for processing (8)
  • docs/openapi/openapi.json
  • docs/openapi/openapi.yaml
  • docs/openapi/paths/management/mcp.yaml
  • docs/openapi/paths/management/oauth.yaml
  • docs/openapi/schemas/management/config.yaml
  • docs/openapi/schemas/management/mcp.yaml
  • docs/openapi/schemas/management/oauth.yaml
  • transports/bifrost-http/handlers/mcp.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • docs/openapi/openapi.yaml
  • docs/openapi/schemas/management/config.yaml
  • docs/openapi/paths/management/oauth.yaml
  • docs/openapi/schemas/management/oauth.yaml
  • docs/openapi/schemas/management/mcp.yaml
  • docs/openapi/paths/management/mcp.yaml
  • docs/openapi/openapi.json

Comment on lines +1214 to +1218
if req.ToolExecutionTimeout < 0 {
SendError(ctx, fasthttp.StatusBadRequest, "tool_execution_timeout must not be negative")
return
}
resolvedToolExecutionTimeout := time.Duration(req.ToolExecutionTimeout) * time.Second

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 5 'tool_execution_timeout|ToolExecutionTimeout' transports docs/openapi

python - <<'PY'
max_duration_ns = (1 << 63) - 1
max_seconds = max_duration_ns // 1_000_000_000
candidate = max_seconds + 1

wrapped = (candidate * 1_000_000_000) & ((1 << 64) - 1)
if wrapped >= (1 << 63):
    wrapped -= (1 << 64)

assert wrapped < 0
print(f"{candidate} seconds wraps to {wrapped} nanoseconds")
PY

Repository: maximhq/bifrost

Length of output: 49188


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- handler request type and create path ---'
sed -n '1125,1235p' transports/bifrost-http/handlers/mcp.go
sed -n '1540,1585p' transports/bifrost-http/handlers/mcp.go

printf '%s\n' '--- persistence conversion and timeout consumers ---'
sed -n '2160,2220p' transports/bifrost-http/lib/config.go
rg -n -C 4 'ToolExecutionTimeout|tool_execution_timeout' transports/bifrost-http/handlers/mcp.go transports/bifrost-http/lib/config.go transports/bifrost-http/server

printf '%s\n' '--- relevant stack summary ---'
git diff --stat
git status --short

Repository: maximhq/bifrost

Length of output: 31154


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- request type definition ---'
rg -n -C 8 'type MCPClientRequest struct|type TableMCPClient struct' transports/bifrost-http/handlers/mcp.go transports

printf '%s\n' '--- exact overflow outcomes ---'
python3 - <<'PY'
MAX_DURATION_NS = (1 << 63) - 1
NANOSECONDS_PER_SECOND = 1_000_000_000
MAX_SECONDS = MAX_DURATION_NS // NANOSECONDS_PER_SECOND

def duration_seconds(seconds):
    raw = (seconds * NANOSECONDS_PER_SECOND) & ((1 << 64) - 1)
    return raw - (1 << 64) if raw >= (1 << 63) else raw

for seconds in (MAX_SECONDS, MAX_SECONDS + 1, 2 * MAX_SECONDS + 2):
    wrapped = duration_seconds(seconds)
    print(f"{seconds}: {wrapped} ns, negative={wrapped < 0}")
PY

printf '%s\n' '--- validation around create and update ---'
sed -n '1688,1710p' transports/bifrost-http/handlers/mcp.go

Repository: maximhq/bifrost

Length of output: 4808


Reject tool_execution_timeout values that overflow time.Duration.

Before the create and update conversions, reject values above ((1 << 63) - 1) / int64(time.Second) with HTTP 400. Otherwise, 9223372037 seconds wraps negative and can cause HTTP 500 errors, while larger values can wrap to an incorrect short timeout.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@transports/bifrost-http/handlers/mcp.go` around lines 1214 - 1218, Extend the
validation around req.ToolExecutionTimeout in the create and update handlers to
reject values greater than the maximum whole-second value representable by
time.Duration, ((1 << 63) - 1) / int64(time.Second), returning HTTP 400 before
the time.Duration conversion. Preserve the existing negative-value rejection and
use the same validation behavior for both request paths.

Source: Path instructions

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 07-30-docs_update_mcp_auth_lifecycle_docs_for_rotation_reauth_and_repair to graphite-base/5723 August 8, 2026 09:53
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/5723 to dev August 8, 2026 09:56
@Pratham-Mishra04
Pratham-Mishra04 requested a review from a team as a code owner August 8, 2026 09:56
…ize error docs, document oauth_config_id immutability
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-30-docs_sync_mcp_openapi_spec_with_current_client_api branch from 1b9b96a to db7da55 Compare August 8, 2026 09:56
@Pratham-Mishra04
Pratham-Mishra04 merged commit 9022abf into dev Aug 8, 2026
14 of 15 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 07-30-docs_sync_mcp_openapi_spec_with_current_client_api branch August 8, 2026 09:58
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.

2 participants