> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runaether.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Finish connecting an MCP server with OAuth

> Finishes an MCP server OAuth connection, the caller's own or the organization's, with the authorization response the browser brought back to the web app's callback page.

Use this tool when you need to:
- Complete a connection begun with startMcpServerOAuth or startOrgMcpServerOAuth once the authorization server redirects back
- Learn how an authorization ended, connected or why not, and where the callback page goes next

Examples:
- POST /mcp-servers/oauth/callback {"state": "AAECAwQFBgcICQ", "code": "SplxlOBeZQQYbYS6WxSbIA", "iss": "https://auth.acme.dev"}
- POST /mcp-servers/oauth/callback {"state": "AAECAwQFBgcICQ", "error": "access_denied"}

Hints:
- state is required (up to 8192 characters), beside the response's code (up to 4096) or error (up to 256); iss is the response's RFC 9207 iss parameter exactly as received, omitted when the response carried none.
- Answers 200 with a typed status: connected, invalid_state, state_expired (over 15 minutes since the start), other_user, not_authorized, iss_mismatch, authorization_failed, exchange_failed, token_invalid, server_changed or oauth_app_deleted; oauth_error is the authorization server's error code when it sent one.
- mcp_server_id is nullable: it names the server once the state opened for the user who started it and they are still authorized, and for server_changed; it is null for invalid_state, state_expired, other_user and not_authorized.
- Only the user who started the authorization finishes it, while still an owner, admin or member of the server's organization and, for the organization's connection, still an owner or admin (not_authorized otherwise); a response finished in another user's session is other_user, refused before its code is redeemed.
- The grant is stored encrypted on the connection when the status is connected. return_to is the start's return_to whenever the state opened, refusals included, for the callback page to go there with the outcome; null when the start named none or the state did not open.
- Use startMcpServerOAuth or startOrgMcpServerOAuth instead to begin a connection; this operation only finishes one.
- Called by the web app's callback page in the signed-in user's session; any signed-in user may call it. Refused with 422 for a body the schema refuses and 500 on an internal failure; every other outcome is a status in a 200.
- An agent host's grant is refused with 403 agent_host_route_not_allowed.



## OpenAPI

````yaml api-reference/openapi.json POST /mcp-servers/oauth/callback
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /mcp-servers/oauth/callback:
    post:
      tags:
        - mcp-servers
      summary: Finish connecting an MCP server with OAuth
      description: >-
        Finishes an MCP server OAuth connection, the caller's own or the
        organization's, with the authorization response the browser brought back
        to the web app's callback page.


        Use this tool when you need to:

        - Complete a connection begun with startMcpServerOAuth or
        startOrgMcpServerOAuth once the authorization server redirects back

        - Learn how an authorization ended, connected or why not, and where the
        callback page goes next


        Examples:

        - POST /mcp-servers/oauth/callback {"state": "AAECAwQFBgcICQ", "code":
        "SplxlOBeZQQYbYS6WxSbIA", "iss": "https://auth.acme.dev"}

        - POST /mcp-servers/oauth/callback {"state": "AAECAwQFBgcICQ", "error":
        "access_denied"}


        Hints:

        - state is required (up to 8192 characters), beside the response's code
        (up to 4096) or error (up to 256); iss is the response's RFC 9207 iss
        parameter exactly as received, omitted when the response carried none.

        - Answers 200 with a typed status: connected, invalid_state,
        state_expired (over 15 minutes since the start), other_user,
        not_authorized, iss_mismatch, authorization_failed, exchange_failed,
        token_invalid, server_changed or oauth_app_deleted; oauth_error is the
        authorization server's error code when it sent one.

        - mcp_server_id is nullable: it names the server once the state opened
        for the user who started it and they are still authorized, and for
        server_changed; it is null for invalid_state, state_expired, other_user
        and not_authorized.

        - Only the user who started the authorization finishes it, while still
        an owner, admin or member of the server's organization and, for the
        organization's connection, still an owner or admin (not_authorized
        otherwise); a response finished in another user's session is other_user,
        refused before its code is redeemed.

        - The grant is stored encrypted on the connection when the status is
        connected. return_to is the start's return_to whenever the state opened,
        refusals included, for the callback page to go there with the outcome;
        null when the start named none or the state did not open.

        - Use startMcpServerOAuth or startOrgMcpServerOAuth instead to begin a
        connection; this operation only finishes one.

        - Called by the web app's callback page in the signed-in user's session;
        any signed-in user may call it. Refused with 422 for a body the schema
        refuses and 500 on an internal failure; every other outcome is a status
        in a 200.

        - An agent host's grant is refused with 403
        agent_host_route_not_allowed.
      operationId: finishMcpServerOAuth
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FinishMcpServerOAuthRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpServerOAuthOutcome'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpServersErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpServersErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpServersErrorResponse'
          description: Gone
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpServersErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpServersErrorResponse'
          description: Internal Server Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpServersErrorResponse'
          description: Service Unavailable
components:
  schemas:
    FinishMcpServerOAuthRequest:
      additionalProperties: false
      properties:
        code:
          maxLength: 4096
          type: string
        error:
          maxLength: 256
          type: string
        iss:
          description: >-
            The response's iss parameter (RFC 9207), exactly as received;
            omitted when the response carried none.
          maxLength: 2048
          type: string
        state:
          maxLength: 8192
          minLength: 1
          type: string
      required:
        - state
      type: object
    McpServerOAuthOutcome:
      additionalProperties: false
      properties:
        mcp_server_id:
          format: uuid
          type:
            - string
            - 'null'
        oauth_error:
          pattern: ^[A-Za-z0-9_.-]{1,64}$
          type:
            - string
            - 'null'
        return_to:
          description: >-
            The Aether mobile app's deep link or the server's connect page the
            start asked to end at, for the callback page to go there with this
            outcome. Null when the start named none, or when the state could not
            be opened.
          pattern: ^(aether://mcp-connected|/connect/[a-z][a-z0-9_-]{0,31})$
          type:
            - string
            - 'null'
        status:
          enum:
            - connected
            - invalid_state
            - state_expired
            - other_user
            - not_authorized
            - iss_mismatch
            - authorization_failed
            - exchange_failed
            - token_invalid
            - server_changed
            - oauth_app_deleted
          type: string
      required:
        - status
        - mcp_server_id
        - oauth_error
        - return_to
      type: object
    McpServersErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - account_deleting
            - aether_inference_unavailable
            - aether_inference_unserved
            - agent_connector_not_found
            - agent_default_project_archived
            - agent_profile_changed
            - agent_profile_harness_fixed
            - bad_gateway
            - bad_request
            - cli_upgrade_required
            - client_outdated
            - conflict
            - connection_agent_only
            - connection_harness_mismatch
            - connection_not_held
            - control_forbidden
            - default_skill_required
            - fallback_is_own_connection
            - fallback_required_with_pin
            - fallback_requires_pin
            - forbidden
            - gateway_timeout
            - gone
            - integration_auth_unexpected
            - integration_not_in_directory
            - integration_shape_changed
            - internal_error
            - mcp_connection_github_not_connected
            - mcp_connection_oauth_not_accepted
            - mcp_connection_org_not_offered
            - mcp_connection_secret_invalid
            - mcp_connection_server_changed
            - mcp_connection_static_secret_not_accepted
            - mcp_credential_policy_not_applicable
            - mcp_credential_policy_org_unavailable
            - mcp_credential_policy_required
            - mcp_oauth_app_auth_method_unsupported
            - mcp_oauth_app_invalid
            - mcp_oauth_app_issuer_invalid
            - mcp_oauth_app_required
            - mcp_oauth_not_advertised
            - mcp_oauth_pkce_unsupported
            - mcp_oauth_registration_failed
            - mcp_repo_config_invalid
            - mcp_server_address_refused
            - mcp_server_aether_managed
            - mcp_server_api_key_not_applicable
            - mcp_server_args_invalid
            - mcp_server_auth_discovery_failed
            - mcp_server_auth_unsupported
            - mcp_server_directory_managed
            - mcp_server_directory_moved
            - mcp_server_display_name_invalid
            - mcp_server_env_invalid
            - mcp_server_headers_invalid
            - mcp_server_key_invalid
            - mcp_server_key_reserved
            - mcp_server_key_taken
            - mcp_server_kind_change_refused
            - mcp_server_not_from_directory
            - mcp_server_not_mcp
            - mcp_server_package_invalid
            - mcp_server_plugin_bundled
            - mcp_server_plugin_off
            - mcp_server_response_too_large
            - mcp_server_return_to_invalid
            - mcp_server_runtime_invalid
            - mcp_server_switched_off
            - mcp_server_unreachable
            - mcp_server_url_invalid
            - mcp_server_version_unpinned
            - method_not_allowed
            - not_acceptable
            - not_found
            - not_implemented
            - org_role_insufficient
            - org_suspended
            - payment_required
            - plugin_moved
            - plugin_name_taken
            - plugin_request_invalid
            - plugin_server_key_reserved
            - plugin_server_key_taken
            - plugin_server_probe_failed
            - plugin_server_required
            - plugin_skill_invalid
            - plugin_source_address_refused
            - plugin_source_empty
            - plugin_source_invalid
            - plugin_source_not_found
            - plugin_source_not_public
            - plugin_source_too_large
            - plugin_source_unreachable
            - plugin_source_unsupported
            - plugin_switched_off
            - plugin_undeliverable
            - precondition_failed
            - rate_limited
            - request_canceled
            - request_timeout
            - request_too_large
            - service_unavailable
            - skill_slug_reserved
            - unauthenticated
            - unsupported_media_type
            - validation_failed
          minLength: 1
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
        - code
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
            - agent_host_route_not_allowed
            - credential_kind_not_admitted
            - grant_scope_insufficient
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.