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

# [Beta] Mint an MCP token for a Devbox.

> [Beta] Mint a token that lets a running Devbox reach an upstream MCP (Model Context Protocol) server through the Runloop MCP hub, using the credential in the supplied secret. Tool access is limited to the MCP config's allowed_tools, and the credential itself is never exposed to the Devbox.

The token is bound to this Devbox and is only accepted for requests that originate from it. Nothing is stored on the Devbox: the token is returned to the caller and is not re-issued when the Devbox is resumed.



## OpenAPI

````yaml /openapi-specs/stainless-processed-openapi.json post /v1/devboxes/{id}/create_mcp_token
openapi: 3.1.0
info:
  title: RunLoop API
  version: '0.1'
  description: >-
    The RunLoop API spec that allows you to host lambda functions and Devboxes
    to enable scaled long running ai workflows.
  contact:
    name: Runloop AI Support
    url: https://runloop.ai
    email: support@runloop.ai
servers:
  - url: https://api.runloop.ai
    description: Runloop API
    variables: {}
security:
  - bearerAuth: []
tags:
  - name: Benchmark
  - name: Blueprint
  - name: Blueprint-Lifecycle
  - name: Blueprint-ObservabilityTools
  - name: Devbox
  - name: Devbox-FileTools
  - name: Devbox-Lifecycle
  - name: Devbox-NetworkTools
  - name: Devbox-ObservabilityTools
  - name: Devbox-PersistenceTools
  - name: Devbox-ShellTools
  - name: Scenario
  - name: ScenarioScorer
  - name: accounts
  - name: agents
  - name: apikeys
  - name: axons
  - name: executions
  - name: gateway-configs
  - name: mcp-configs
  - name: network-policies
  - name: objects
  - name: restricted_keys
  - name: secrets
  - name: streaming
paths:
  /v1/devboxes/{id}/create_mcp_token:
    post:
      tags:
        - Devbox
        - Devbox-NetworkTools
      summary: '[Beta] Mint an MCP token for a Devbox.'
      description: >-
        [Beta] Mint a token that lets a running Devbox reach an upstream MCP
        (Model Context Protocol) server through the Runloop MCP hub, using the
        credential in the supplied secret. Tool access is limited to the MCP
        config's allowed_tools, and the credential itself is never exposed to
        the Devbox.


        The token is bound to this Devbox and is only accepted for requests that
        originate from it. Nothing is stored on the Devbox: the token is
        returned to the caller and is not re-issued when the Devbox is resumed.
      operationId: createDevboxMcpToken
      parameters:
        - name: id
          in: path
          description: The Devbox ID.
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/McpTokenCreateParameters'
      responses:
        '200':
          description: MCP token minted successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/McpTokenView'
        '400':
          description: >-
            Devbox is not currently running, or the MCP config or secret was not
            found.
        '404':
          description: Devbox not found.
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Runloop from '@runloop/api-client';

            const client = new Runloop({
              bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
            });

            const mcpTokenView = await client.devboxes.createMcpToken('id', {
              mcp_config: 'mcp_config',
              secret: 'secret',
            });

            console.log(mcpTokenView.devbox_id);
        - lang: Python
          source: |-
            import os
            from runloop_api_client import Runloop

            client = Runloop(
                bearer_token=os.environ.get("RUNLOOP_API_KEY"),  # This is the default and can be omitted
            )
            mcp_token_view = client.devboxes.create_mcp_token(
                id="id",
                mcp_config="mcp_config",
                secret="secret",
            )
            print(mcp_token_view.devbox_id)
components:
  schemas:
    McpTokenCreateParameters:
      type: object
      description: >-
        [Beta] Parameters for minting an MCP token for a Devbox. The token
        grants the Devbox access to the upstream MCP server described by the MCP
        config, using the supplied credential, with tool-level access control
        based on the config's allowed_tools.
      properties:
        mcp_config:
          type: string
          description: The MCP config to use. Can be an MCP config ID (mcp_xxx) or name.
        secret:
          type: string
          description: >-
            The secret containing the MCP server credential. Can be a secret ID
            or name.
      required:
        - mcp_config
        - secret
    McpTokenView:
      type: object
      properties:
        devbox_id:
          type: string
          description: The Devbox the token is bound to.
        mcp_config_id:
          type: string
          description: The ID of the MCP config the token grants access to.
        token:
          type: string
          description: >-
            The token to send to the MCP hub as a Bearer token in the
            Authorization header. Only accepted for requests originating from
            the bound Devbox.
        url:
          type: string
          description: >-
            The MCP hub URL the token authenticates against. Matches the
            RL_MCP_URL environment variable inside the Devbox.
        endpoint:
          type: string
          description: The upstream MCP server endpoint the hub proxies to.
        allowed_tools:
          type: array
          items:
            type: string
          description: Glob patterns for the tools the token permits.
      required:
        - devbox_id
        - mcp_config_id
        - token
        - url
        - endpoint
        - allowed_tools
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````