Connect an MCP client to an MCP server through Teleport. Teleport checks your roles before every tool call, hides tools you aren’t allowed to use and records MCP requests in the audit log.
This guide uses the demo MCP server built into the Teleport Application Service, so you don’t need an MCP server of your own. You run the Application Service in a beam built from a phase. The beam enrolls itself with a single-use bound_keypair join token, so you never copy a token or secret into it.
Then you connect to the demo server in one of two ways:
- From your dev computer: your MCP client runs locally and starts
tsh mcp connect. - From inside a beam: your MCP client runs in a separate client beam, which reaches the server with the identity you delegate to it.
Install the client tools and sign in
Beams is a Teleport project and uses official Teleport client tools.
The client tools include tsh to sign in and run commands, and tctl to administer your cluster if you have permission.
Cluster: example.beams.run. Edit this example to use your cluster name.
Install version 18.11.10 of the client:
Download and open the macOS installer, then follow its instructions.
curl -O https://cdn.teleport.dev/teleport-tools-18.11.10.pkg
open teleport-tools-18.11.10.pkgFor Linux x86-64, download and install the client tools:
curl -O https://cdn.teleport.dev/teleport-v18.11.10-linux-amd64-bin.tar.gz
tar -xzf teleport-v18.11.10-linux-amd64-bin.tar.gz
sudo ./teleport/installFor Windows x86-64, run these commands in PowerShell. Add the extraction directory ($env:LOCALAPPDATA\Teleport) to your user PATH to use tsh in future terminals; the last command adds it to this terminal's PATH.
Invoke-WebRequest -Uri https://cdn.teleport.dev/teleport-v18.11.10-windows-amd64-bin.zip -OutFile teleport.zip
Expand-Archive -Path teleport.zip -DestinationPath "$env:LOCALAPPDATA\Teleport" -Force
$env:Path += ";$env:LOCALAPPDATA\Teleport"Follow the official client tools install guide for other versions and architectures.
Check that you’re running v18.11.10 of the client with tsh version.
tsh versionI sign in without a password (e.g. a passkey).
tsh login --proxy='example.beams.run' --auth=passwordlessI have a password & MFA set up for my account:
Replace you@example.com with your Teleport username.
tsh login --proxy='example.beams.run' --user=you@example.comI sign in with SSO (e.g. Okta, GitHub, SAML).
tsh login --proxy='example.beams.run'You also need:
- A Beams-enabled Teleport cluster. The admin steps need permission to create roles, assign them to users, build a phase and start a beam.
- An MCP client that can start a stdio command. The examples use Claude Code. On your dev computer, install it and sign in. Beams include Claude Code, already connected to the LLM gateway.
jq, for the admin commands.
How it works
- A beam built from the
mcp-demophase runs the Teleport Application Service with the demo MCP server turned on. The service connects out to your cluster, so the beam doesn’t need to be published. - Your MCP client starts
tsh mcp connect teleport-mcp-demoas a local stdio server.tshuses your Teleport identity to open a session to the Application Service through the Teleport proxy. - Teleport proxies the MCP messages between
tshand the demo server. It filters the tool list and every tool call against themcp.toolsallowlist in your roles, and logs MCP requests as audit events.
The demo server has three tools. They only return information and change nothing:
| Tool | What it returns |
|---|---|
teleport_user_info |
Your Teleport user name, roles and user kind |
teleport_session_info |
The MCP session: transport, app and cluster |
teleport_demo_info |
A short description of the demo server |
1. Create the roles
The Application Service beam needs a role that lets it create its own join token. Save this as mcp-demo-host.yaml:
kind: role
version: v8
metadata:
name: mcp-demo-host
spec:
allow:
rules:
- resources: [token]
verbs: [create, update]tctl create -f needs both verbs to write a bound_keypair token. To learn how role fields work, see Access control.
To call tools on the demo server, your user needs MCP access. The preset mcp-user role allows every tool on every MCP server:
kind: role
version: v8
metadata:
name: mcp-user
spec:
allow:
app_labels:
teleport.internal/app-sub-kind: mcp
mcp:
tools: ["*"]Every Teleport cluster includes mcp-user, so you don’t need to create it. To allow fewer tools, see Limit the tools.
Create mcp-demo-host, and add it and mcp-user to your user, keeping your existing roles:
tctl create -f mcp-demo-host.yaml
me=$(tsh status --format=json | jq -r .active.username)
roles=$(tctl get "users/$me" --format=json | jq -r '.[0].spec.roles | join(",")')
tctl users update "$me" --set-roles="$roles,mcp-demo-host,mcp-user"If your user comes from single sign-on, tctl users update doesn’t apply. Map both roles to your user through your identity provider’s role mapping instead.
Sign out and sign in again, so your certificate includes the new roles. You can’t delegate a role to a beam unless your own certificate has it.
2. Build the Application Service phase
Save the following as phase.yaml. The env values at the top of each step are the only settings you might change:
| Setting | Default | Meaning |
|---|---|---|
TELEPORT_AGENT_VERSION |
empty | Agent version to install. Empty uses the version your cluster recommends. |
AGENT_NAME |
mcp-demo |
Name of the Application Service in your cluster. |
JOIN_WINDOW |
10 minutes |
Time the service has to join after it creates its token. |
version: v1
metadata:
name: mcp-demo
commands:
- comment: Install the Teleport agent for this cluster
env:
# Leave empty to use the agent version your cluster recommends.
- name: TELEPORT_AGENT_VERSION
value: ""
shell: |
set -eu
find=$(curl -fsS "https://$TELEPORT_PROXY/v1/webapi/find")
version=${TELEPORT_AGENT_VERSION:-$(printf '%s' "$find" | jq -er .auto_update.agent_version)}
version=${version#v}
flavor=teleport
[ "$(printf '%s' "$find" | jq -r .edition)" = ent ] && flavor=teleport-ent
tarball="$flavor-v$version-linux-$(dpkg --print-architecture)-bin.tar.gz"
cd "$(mktemp -d)"
curl -fsSLO "https://cdn.teleport.dev/$tarball"
curl -fsSL "https://cdn.teleport.dev/$tarball.sha256" | sha256sum --check -
tar -xzf "$tarball" "$flavor/teleport"
# Install only the agent; keep the beam's own tsh, tctl and tbot.
install -D -m 755 "$flavor/teleport" /opt/teleport/bin/teleport
/opt/teleport/bin/teleport version
services:
- name: mcp-demo
context: runtime
env:
# Name shown for this Application Service.
- name: AGENT_NAME
value: mcp-demo
# Time allowed for the service to join after the token is created.
- name: JOIN_WINDOW
value: 10 minutes
shell: |
set -eu
. /etc/environment
# Wait for the beam's tbot to deliver this beam's identity.
timeout 120 sh -c 'until [ -s ~/.tsh/current-profile ]; do sleep 1; done'
state=$HOME/.mcp-demo
install -d -m 700 "$state"
cd "$state"
token="mcp-demo-$BEAM_ID"
# Create the single-use join token on first start only. A restart
# reuses the identity the service already holds in data/.
if [ ! -f teleport.yaml ]; then
(umask 077; head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n' > secret)
cat > token.yaml <<EOF
kind: token
version: v2
metadata:
name: $token
expires: "$(date -u -d '+12 hours' +%Y-%m-%dT%H:%M:%SZ)"
spec:
roles: [App]
join_method: bound_keypair
bound_keypair:
onboarding:
registration_secret: "$(cat secret)"
must_register_before: "$(date -u -d "+$JOIN_WINDOW" +%Y-%m-%dT%H:%M:%SZ)"
recovery:
limit: 1
mode: standard
EOF
tctl create -f token.yaml
rm token.yaml
fi
cat > teleport.yaml.tmp <<EOF
version: v3
teleport:
nodename: $AGENT_NAME
data_dir: $state/data
proxy_server: $TELEPORT_PROXY
join_params:
method: bound_keypair
token_name: $token
bound_keypair:
registration_secret_path: $state/secret
auth_service: { enabled: false }
proxy_service: { enabled: false }
ssh_service: { enabled: false }
app_service:
enabled: true
mcp_demo_server: true
EOF
mv teleport.yaml.tmp teleport.yaml
exec /opt/teleport/bin/teleport start --config="$state/teleport.yaml"The command runs once, when the phase is built. It installs only the teleport binary, at the version and edition your cluster reports, and keeps the beam’s own tsh, tctl and tbot. The image contains no tokens or credentials.
The service runs only in beams started from the phase (context: runtime). On first start it waits for the beam’s identity, then:
- Generates a random registration secret, readable only by the beam user.
- Creates a
bound_keypairtoken named after the beam’s ID, with theApprole. The secret works once, and only untilJOIN_WINDOWends. The token itself expires an hour after the beam does. - Writes an Application Service configuration with
mcp_demo_server: true, and starts the service. On its first join, the service registers a key pair with the token. Later connections prove possession of that key.
A restart reuses the identity the service already holds and doesn’t create another token.
Build the phase:
tsh phase apply -f phase.yaml3. Start the Application Service beam
Start a beam from the phase, delegating only mcp-demo-host:
tsh beams add --phase=mcp-demo --roles=mcp-demo-host --no-share-connected-accounts --no-consoleThe demo server registers within a minute. Check it:
tctl get app_server --format=json | jq -r '.[] | select(.spec.hostname == "mcp-demo") | .spec.app.metadata.name'teleport-mcp-demoIf it doesn’t appear, read the service logs. Replace SERVICE_BEAM with the beam’s name from tsh beams ls:
tsh beams exec SERVICE_BEAM -- beamctl logs mcp-demo4. Connect from your dev computer
List the MCP servers you can reach. Allowed Tools shows [*] because of mcp-user:
tsh mcp lsName Description Type Allowed Tools Labels
----------------- ----------------------------------------------------------------- ----- ------------- ------
teleport-mcp-demo A demo MCP server that shows current user and session information stdio [*]Register the server in Claude Code, from your project directory:
claude mcp add --transport stdio teleport-mcp-demo -- tsh mcp connect teleport-mcp-demo
claude mcp listclaude mcp list should show teleport-mcp-demo as connected. Start claude, and ask:
Use the teleport-mcp-demo server to show my Teleport user and this MCP session.Claude Code asks before it runs each tool. The answer shows your Teleport user name and roles, and the teleport-mcp-demo app on your cluster.
For other MCP clients, tsh mcp config prints the configuration, or writes it into the client’s configuration file:
# Print the JSON configuration
tsh mcp config teleport-mcp-demo
# Claude Desktop
tsh mcp config teleport-mcp-demo --client-config=claude
# Cursor
tsh mcp config teleport-mcp-demo --client-config=cursor
# VS Code, for one project
tsh mcp config teleport-mcp-demo --client-config=.vscode/mcp.jsonRestart the client after you change its configuration.
5. Connect from inside a beam
A client beam reaches MCP servers with the roles you delegate to it. Start one with beam-user and mcp-user. Keep the Application Service beam running.
tsh beams add --roles=beam-user,mcp-user --no-share-connected-accounts --no-consoleNote the beam’s name in the output, and connect to it. Replace my-beam with that name:
tsh beams ssh my-beamInside the beam, tsh is already signed in as the beam’s identity. Check that the demo server is visible, then register it in Claude Code:
tsh mcp ls
claude mcp add --transport stdio teleport-mcp-demo -- tsh mcp connect teleport-mcp-demo
claude mcp listStart claude, and ask the same question as before. This time teleport_user_info reports the beam’s identity, a bot user with the roles you delegated, not your own user.
The same setup works for any agent in the beam that can start a stdio MCP server. Point it at tsh mcp connect teleport-mcp-demo.
Limit the tools
mcp-user allows every tool on every MCP server. For an agent, allow only the tools it needs. This role reaches the same MCP servers but allows only teleport_user_info. Save it as mcp-demo-limited.yaml:
kind: role
version: v8
metadata:
name: mcp-demo-limited
spec:
allow:
app_labels:
teleport.internal/app-sub-kind: mcp
mcp:
tools: [teleport_user_info]Tool names are case-sensitive. Entries can also be globs such as teleport_*, or regular expressions such as ^teleport_(user|session)_info$.
Create the role, add it to your user the same way as in step 1, and sign in again. Then start a client beam with --roles=beam-user,mcp-demo-limited in place of mcp-user:
tctl create -f mcp-demo-limited.yamlIn that beam, tsh mcp ls shows only teleport_user_info under Allowed Tools, and the client’s tool list contains only that tool. If a client calls another tool, Teleport rejects it with RBAC is enforced by your Teleport roles.
Clean up
Remove the client beams. Save any work first.
tsh beams rm my-beamOn your dev computer, remove the server from Claude Code with claude mcp remove teleport-mcp-demo.
Remove the Application Service beam with tsh beams rm SERVICE_BEAM. The demo server disappears from tsh mcp ls shortly after. Delete its join token, or let it expire an hour after the beam does:
tctl get tokens --format=json | jq -r '.[].metadata.name | select(startswith("mcp-demo-"))'
tctl rm token/TOKEN_NAMEKeep the phase for another test, or remove it with tsh phase rm mcp-demo. Remove the roles from your user if you no longer need them, then delete the roles you created with tctl rm role/mcp-demo-host and tctl rm role/mcp-demo-limited. Keep mcp-user, because it’s a preset role.
Troubleshoot
tsh beams addreportsYou do not have permission to delegate the following roles. Your certificate doesn’t have the role yet. Check that step 1 added it to your user, then sign out and sign in again.tsh mcp lsshows no servers. The Application Service hasn’t joined. Read its logs as in step 3. If the join window passed before the service started, remove the beam and start a new one; each beam creates its own token.tsh mcp lsshows(none) [!]under Allowed Tools. None of your roles allow MCP tools. Addmcp-useror a role likemcp-demo-limited, and sign in again. For a beam, delegate the role when you start it.- Claude Code shows the server as failed. Run
tsh mcp connect teleport-mcp-demoin the same terminal. It should wait for input without an error. If it reports an expired session, sign in again withtsh login.