{"token_count": 2853}

# MCP Access Reference

This guide lists the interfaces and options for interacting with the Teleport Application Service for MCP access, including the static configuration file for the `teleport` binary, and `tsh mcp` commands.

## Configuration

---

WARNING

Backing up production instances, environments, and/or settings before making permanent modifications is encouraged as a best practice. Doing so allows you to roll back to an existing state if needed.

---

The following snippet shows the full YAML configuration of an Application Service appearing in the `teleport.yaml` configuration file:

```
app_service:
  # Enables application proxy service.
  enabled: true
  # Enables the builtin Teleport demo MCP server that shows current user and
  # session information. To access it, this MCP server uses the app label
  # "teleport.internal/resource-type" with the value "demo".
  mcp_demo_server: true
  # This section contains definitions of all applications proxied by this
  # service. It can contain multiple items.
  apps:
  # Name of the application. Used for identification purposes.
  - name: "mcp-everything"
    # Endpoint URI of the target MCP server.
    # Use "mcp+http://" and "mcp+https://" as scheme for streamable HTTP MCP servers.
    # Use "mcp+sse+http://" and "mcp+sse+https://" as scheme for SSE MCP servers.
    # Leave it empty or use "mcp+stdio://" for stdio MCP servers.
    # For streamable HTTP MCP servers, the path in the URI is used when the MCP
    # client requests "/" but is not appended to requests for other paths.
    uri: "mcp+http://localhost:12345/mcp"
    # Free-form application description.
    description: "Example Everything MCP server"
    # Static labels to assign to the app. Used in RBAC.
    labels:
      env: "prod"

    # Contains MCP server-related configurations.
    mcp:
      # Command to launch stdio-based MCP servers.
      command: "docker"
      # Args to execute with the command.
      args: ["run", "-i", "--rm", "mcp/everything"]
      # Name of the host user account under which the command will be
      # executed. Required for stdio-based MCP servers.
      run_as_host_user: "docker"
      # OAuth settings for streamable HTTP MCP servers that require their own
      # OAuth login. "tsh mcp login" uses these values when the user does not
      # set the matching flags. Teleport does not enforce them.
      oauth:
        # Whether the MCP server requires OAuth.
        # Options:
        # - required: the MCP server requires OAuth
        # - not_required: the MCP server does not use OAuth, and
        #   "tsh mcp login" stops without logging in. Cannot be combined with
        #   the other OAuth settings.
        # Default: unset, "tsh mcp login" checks the MCP server
        mode: required
        # Client ID of an OAuth client registered with the provider. When set,
        # tsh skips dynamic client registration. Users of a confidential
        # client pass "--client-secret" to "tsh mcp login", unless
        # client_secret_ref is set.
        client_id: "1234.5678"
        # Local port of the redirect URI registered for the client, making it
        # "http://127.0.0.1:<port>/callback". Mutually exclusive with
        # redirect_uri, so set only one of them.
        callback_port: 3118
        # Exact loopback redirect URI registered for the client. Use it instead
        # of callback_port when the registered URI uses "localhost". Mutually
        # exclusive with callback_port, so set only one of them.
        redirect_uri: "http://localhost:3118/callback"
        # OAuth scopes to request.
        scopes: ["read", "write"]
        # URL of the OAuth authorization server metadata document. When set, tsh
        # fetches the metadata from it instead of discovering it from the MCP
        # server, and does not check its issuer against the URL. Use it for MCP
        # servers whose OAuth discovery fails.
        auth_server_metadata_url: "https://mcp.example.com/.well-known/oauth-authorization-server"
        # Name of the mcp_oauth_client_secret Auth uses to exchange authorization
        # codes for this app, scope-qualified if the secret is scoped. Requires
        # client_id.
        client_secret_ref: "example"

    # Disable TLS validation for SSE and streamable HTTP MCP servers.
    insecure_skip_verify: true
    # Rewrites section for SSE and streamable HTTP MCP servers.
    rewrite:
      # Specify whether to include roles or traits in the JWT.
      # Options:
      # - roles-and-traits: include both roles and traits
      # - roles: include only roles
      # - traits: include only traits
      # - none: exclude both roles and traits from the JWT token
      # Default: roles-and-traits
      jwt_claims: roles-and-traits
      # Headers passthrough configuration.
      headers:
      - "Authorization: Bearer {{internal.jwt}}"
      - "X-Custom-Header: example"
      - "X-External-Trait: {{external.env}}"

```

## Resource

The MCP server resources are registered as `app` resources in the Teleport backend. Here is the spec of MCP server resources managed by `tctl` resource command:

```
kind: app
version: v3
metadata:
  # MCP server name
  name: everything
  # MCP server description.
  description: The Everything MCP server
  # MCP server labels.
  labels:
    env: local
spec:
  # Endpoint URI of the target MCP server.
  # Use "mcp+http://" and "mcp+https://" as scheme for streamable HTTP MCP servers.
  # Use "mcp+sse+http://" and "mcp+sse+https://" as scheme for SSE MCP servers.
  # For streamable HTTP MCP servers, the path in the URI is used when the MCP
  # client requests "/" but is not appended to requests for other paths.
  uri: "mcp+http://localhost:12345/mcp"

  mcp:
    # OAuth settings for streamable HTTP MCP servers that require their own
    # OAuth login. "tsh mcp login" uses these values when the user does not
    # set the matching flags. Teleport does not enforce them.
    oauth:
      # Whether the MCP server requires OAuth.
      # Options:
      # - required: the MCP server requires OAuth
      # - not_required: the MCP server does not use OAuth, and
      #   "tsh mcp login" stops without logging in. Cannot be combined with
      #   the other OAuth settings.
      # Default: unset, "tsh mcp login" checks the MCP server
      mode: required
      # Client ID of an OAuth client registered with the provider. When set,
      # tsh skips dynamic client registration. Users of a confidential
      # client pass "--client-secret" to "tsh mcp login", unless
      # client_secret_ref is set.
      client_id: "1234.5678"
      # Local port of the redirect URI registered for the client, making it
      # "http://127.0.0.1:<port>/callback". Mutually exclusive with
      # redirect_uri, so set only one of them.
      callback_port: 3118
      # Exact loopback redirect URI registered for the client. Use it instead
      # of callback_port when the registered URI uses "localhost". Mutually
      # exclusive with callback_port, so set only one of them.
      redirect_uri: "http://localhost:3118/callback"
      # OAuth scopes to request.
      scopes: ["read", "write"]
      # URL of the OAuth authorization server metadata document. When set, tsh
      # fetches the metadata from it instead of discovering it from the MCP
      # server, and does not check its issuer against the URL. Use it for MCP
      # servers whose OAuth discovery fails.
      auth_server_metadata_url: "https://mcp.example.com/.well-known/oauth-authorization-server"
      # Name of the mcp_oauth_client_secret Auth uses to exchange authorization
      # codes for this app, scope-qualified if the secret is scoped. Requires
      # client_id.
      client_secret_ref: "example"

  # Disable TLS validation for SSE and streamable HTTP MCP servers.
  insecure_skip_verify: true
  # Rewrites section for SSE and streamable HTTP MCP servers.
  rewrite:
    # Specify whether to include roles or traits in the JWT.
    # Options:
    # - roles-and-traits: include both roles and traits
    # - roles: include only roles
    # - traits: include only traits
    # - none: exclude both roles and traits from the JWT token
    # Default: roles-and-traits
    jwt_claims: roles-and-traits
    # Headers passthrough configuration.
    headers:
    - "Authorization: Bearer {{internal.jwt}}"
    - "X-Custom-Header: example"
    - "X-External-Trait: {{external.env}}"

```

## CLI

This section shows CLI commands relevant for MCP access.

### tsh mcp ls

Lists available MCP servers.

```
List all MCP servers.
$ tsh mcp ls
Search MCP servers with keywords.
$ tsh mcp ls --search foo,bar
Filter MCP servers with labels.
$ tsh mcp ls key1=value1,key2=value2
Get MCP server names using "jq".
$ tsh mcp ls --format json  | jq -r '.[].metadata.name'
```

| Flag       | Description                                                                                                                         |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `--search` | List of comma separated search keywords or phrases enclosed in quotations (e.g. `--search=foo,bar,"some phrase"`).                  |
| `--query`  | Query by predicate language enclosed in single quotes. (e.g. `--query='labels["key1"] == "value1" && labels["key2"] != "value2"')`. |
| `--format` | Format output (`text`, `json`, `yaml`).                                                                                             |

### tsh mcp config

Print client configuration details or update the configuration directly.

```
Print sample configuration for a MCP server app
$ tsh mcp config my-mcp-server-app
Print sample configuration for a streamable HTTP MCP server with custom headers
$ tsh mcp config my-mcp-server-app -H "Header1: value1" -H "Header2: value2"
Add all MCP servers to Claude Desktop
$ tsh mcp config --all --client-config=claude
Search MCP servers with labels and add to the specified JSON file
$ tsh mcp config --labels env=dev --client-config=my-config.json`
```

| Flag              | Description                                                                                                                                                                                                                             |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--all`           | Select all MCP servers. Mutually exclusive with `--labels` or `--query`.                                                                                                                                                                |
| `--labels`        | List of comma separated labels to filter by labels (e.g. key1=value1,key2=value2).                                                                                                                                                      |
| `--query`         | Query by predicate language enclosed in single quotes. (e.g. `--query='labels["key1"] == "value1" && labels["key2"] != "value2"')`.                                                                                                     |
| `--client-config` | If specified, update the specified client config. `claude` for default Claude Desktop config, or specify a JSON file path. Can also be set with environment variable `TELEPORT_MCP_CLIENT_CONFIG`.",                                    |
| `--json-format`   | Format the JSON file (`pretty`, `compact`, `auto`, `none`). `auto` saves in compact if the file is already compact, otherwise pretty. Can also be set with environment variable `TELEPORT_MCP_CONFIG_JSON_FORMAT`. Default is `auto`.", |
| `-H`, `--header`  | Extra custom headers used for streamable HTTP MCP servers.                                                                                                                                                                              |

### tsh mcp connect

Used by AI tools such as Claude Desktop to connect to an MCP server via Teleport.

---

TIP

`tsh mcp config` can print sample configuration or update your AI tools directly. This eliminates the need to manually construct the tsh mcp connect command.

---

```
$ tsh mcp connect mcp-everything
```

`tsh` debug logs are enabled by default and can be disabled by the environment variable `TELEPORT_DEBUG=false`. You can also specify the `--no-debug` flag when generating sample configurations with `tsh mcp config`.

### tsh proxy mcp

Starts a local proxy for MCP connections. Only supported for target MCP servers with streamable HTTP transport.

```
$ tsh proxy mcp my-streamable-http-mcp-server
```
