teleport_unpack
Decrypt and import secrets from encrypted teleport bundles into your vault. Use this tool to securely manage API keys and prevent plaintext .env file leaks.
Instructions
Decrypt and import secrets from a teleport bundle.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bundle | Yes | Base64-encoded encrypted bundle | |
| passphrase | Yes | Decryption passphrase | |
| scope | No | Scope: global or project | global |
| projectPath | No | Project root path for project-scoped secrets | |
| dryRun | No | Preview without importing |
Implementation Reference
- src/mcp/server.ts:462-497 (handler)Registration and handler implementation for the 'teleport_unpack' MCP tool in src/mcp/server.ts.
server.tool( "teleport_unpack", "Decrypt and import secrets from a teleport bundle.", { bundle: z.string().describe("Base64-encoded encrypted bundle"), passphrase: z.string().describe("Decryption passphrase"), scope: scopeSchema.default("global"), projectPath: projectPathSchema, dryRun: z .boolean() .optional() .default(false) .describe("Preview without importing"), }, async (params) => { try { const payload = teleportUnpack(params.bundle, params.passphrase); if (params.dryRun) { const preview = payload.secrets .map((s) => `${s.key} [${s.scope ?? "global"}]`) .join("\n"); return text(`Would import ${payload.secrets.length} secrets:\n${preview}`); } const o = opts(params); for (const s of payload.secrets) { setSecret(s.key, s.value, o); } return text(`Imported ${payload.secrets.length} secret(s) from teleport bundle`); } catch { return text("Failed to unpack: wrong passphrase or corrupted bundle", true); } }, ); - src/core/teleport.ts:88-116 (helper)The core 'teleportUnpack' function in src/core/teleport.ts which performs the actual decryption and parsing of the teleport bundle.
* Unpack and decrypt a teleport bundle. */ export function teleportUnpack( encoded: string, passphrase: string, ): TeleportPayload { const bundleJson = Buffer.from(encoded, "base64").toString("utf8"); const bundle: TeleportBundle = JSON.parse(bundleJson); if (bundle.v !== 1) { throw new Error(`Unsupported teleport bundle version: ${bundle.v}`); } const salt = Buffer.from(bundle.salt, "base64"); const iv = Buffer.from(bundle.iv, "base64"); const tag = Buffer.from(bundle.tag, "base64"); const encrypted = Buffer.from(bundle.data, "base64"); const key = deriveKey(passphrase, salt); const decipher = createDecipheriv(ALGORITHM, key, iv); decipher.setAuthTag(tag); const decrypted = Buffer.concat([ decipher.update(encrypted), decipher.final(), ]); return JSON.parse(decrypted.toString("utf8")); }