Skip to main content
Glama

telephone


Why

Coding agents get stuck on problems they cannot fix from where they sit. An agent driving a CLI hits a crash, but the CLI's source lives in another repo it has no access to. Today a human copies the error into a second agent session that does have the code, copies the questions back, and relays answers until the bug is fixed.

Telephone removes the human relay. The stuck agent dials a line, an agent with the code answers, and they talk it through over MCP until one of them hangs up.

 Caller agent (no code access)                 Implementer agent (has the repo)
 "acme-cli sync crashes with KeyError: 'region'"  --->
                                             <---  "Run `acme-cli --version` and paste ~/.acme/config.toml"
 "v2.3.1, config has no region key"               --->
                                             <---  "Fixed: region now defaults to us-east-1. Pull and retry."
 "Works. Thanks!"  [hang_up(resolved=true)]       --->

Related MCP server: MCPs

How it works

One MCP server, any number of named lines. Each participant connects to the same server and is reached in whichever way its client supports:

Client

How it hears the other side

Codex CLI (and any MCP client)

Stays on the line with a long-polling listen / say tool call. The server holds the call open and returns the peer's message as the tool result.

ChatGPT

Subscribes to the line through MCP Events; the server sends a signed webhook that wakes the Work chat.

Why not plain server push? Under the current MCP spec (2026-07-28), a server may only send its own requests while a client request is in flight, and Codex CLI does not surface notifications/message to the model. A tool result is the one channel every agent reads, so Telephone delivers every message as a tool result or, for clients that support it, an MCP Event.

Tools

Tool

Who

What it does

dial

caller

Opens a call on a named line with your opening message; returns your seat and waits for the first reply

answer

implementer

Takes the call on a line (waits for someone to dial); returns your seat and the opening message

say

either

Sends a message, then waits for the reply (wait_s: 0 returns at once)

listen

either

Waits for the other agent's next message

get_messages

either

Reads the whole transcript without waiting

hang_up

either

Ends the call; the caller reports resolved: true/false

Every call tool except get_messages (which returns the plain transcript) answers with an outcome (message, waiting, no_call, ended) and a plain-words next_step, so an agent knows to call listen again instead of ending its turn. Calls also end at max_turns or after idle_timeout_s (see common/telephone.yaml), so two agents can never loop forever. Each call is logged as JSONL under .telephone/transcripts/.

Lines live in memory: run a single server process.

Eval: Codex phones Codex

make eval_codex_call        # two real Codex CLIs fix a planted acme-cli bug over a call
make eval_codex_call_fake   # same harness with scripted agents (no LLM)

The caller runs read-only with a broken acme-cli and no source; the implementer has the repo. The run passes only if the caller hangs up resolved: true, the implementer asked before fixing, acme-cli sync now works, and the fixture's tests pass. See tests/evals/codex_phone_call/.

Status

Piece

State

Call tools over MCP (long-poll delivery for Codex CLI and any MCP client)

Ready

Protocol revisions

2025-era clients (handshake) and 2026-07-28 clients (no session) on the same /mcp

MCP Events extension (io.modelcontextprotocol/events: events/*, callback verification, signed webhooks)

Served on both revisions; tested with a simulated subscriber

ChatGPT end to end

Matches what ChatGPT expects (2026-07-28, capabilities.events, -32015 on a failed challenge); not yet tried against live ChatGPT

Quick Start

uv sync                         # install deps
uv tool install prek && prek install

uv run telephone --help         # CLI
uv run telephone-serve          # HTTP API + MCP at /mcp on one port
uv run telephone-mcp            # legacy: stdio MCP only, for local dev

Connect a client to the running server with an API key (how to create one), e.g. Codex CLI:

# ~/.codex/config.toml
[mcp_servers.telephone]
url = "http://localhost:8080/mcp"
env_http_headers = { "X-API-KEY" = "TELEPHONE_API_KEY" }
tool_timeout_sec = 600   # lets `listen` wait for long replies

Architecture

Telephone is built on one codebase with three interfaces. Business logic lives once in services/ and ships as a CLI subcommand, an MCP tool, and an HTTP route, with the same Pydantic contract everywhere.

┌──────────────┐  ┌──────────────┐  ┌──────────────┐
│ src/cli/app  │  │ mcp_server/  │  │ api_server/  │   transport / interface
│  (Typer)     │  │ (MCPServer)  │  │ (FastAPI)    │
└──────┬───────┘  └──────┬───────┘  └──────┬───────┘
       │                 │                 │
       └─────────────────┼─────────────────┘
                         ▼
                 ┌───────────────┐
                 │  services/    │   pure @service functions
                 │  @service     │   (transport-agnostic)
                 └───────┬───────┘
                         ▼
                 ┌───────────────┐
                 │  models/      │   Pydantic I/O contracts
                 └───────┬───────┘
                         ▼
        ┌────────────┬───────┬────────────┬─────────────┐
        │ common/    │ db/   │ utils/llm/ │ src/utils/  │   shared infra
        │ (config)   │ (ORM) │ (DSPY)     │ (logs/theme)│
        └────────────┴───────┴────────────┴─────────────┘

Feature

Stack

CLI (auto-discovered commands, global flags, shell completions, self-update)

Typer

MCP server (streamable HTTP at /mcp; stdio for local dev)

MCP Python SDK v2 (MCPServer), protocol 2025-11-25 and 2026-07-28

HTTP API server (also hosts /mcp)

FastAPI + Uvicorn

Auth

WorkOS AuthKit (OAuth 2.1) + API keys

Payments

Stripe subscriptions + x402 per-call pricing

Database + migrations

SQLAlchemy + Alembic

Config (YAML + .env)

pydantic-settings

Lint / type / dead code

Ruff + ty + Vulture + import-linter

Pre-commit

prek

MCP-only behavior (progress, elicitation, MCP Apps) goes in opt-in enhancers under mcp_server/enhancers/, so CLI and API consumers of the same service are unaffected. See mcp_server/MCP_UI_ARCHITECTURE.md.

CLI Usage

Global flags go before the subcommand:

Flag

Short

Description

--verbose

-v

Increase output verbosity

--quiet

-q

Suppress non-essential output

--debug

Show full tracebacks on error

--format

-f

Output format: table, json, plain

--dry-run

Preview actions without executing

--version

-V

Print version and exit

uv run telephone --format json config show
uv run telephone doctor

New commands are auto-discovered from src/cli/commands/; scaffold one with uv run telephone init my_command --desc "Does something".

Configuration

from common import global_config

global_config.server.port  # values from common/global_config.yaml
global_config.OPENAI_API_KEY  # secrets from .env
uv run telephone config show
uv run telephone config get server.port
uv run telephone config set logging.verbose false

Full configuration docs

Credits

Built with uv, Typer, the MCP Python SDK, FastAPI, and prek.

Available Tools

58 tools
gmail_add_attachmentA

Attach one file to an existing Gmail draft and return the draft's full attachment list (each with attachment_id, filename, mime_type, size_bytes). Only the attachments change - body, subject, and recipients are preserved exactly. Pass the file as 'attachment' (filename + mime_type + base64 data_base64).

Inputs: draft_id (required), attachment (required), user_id. Returns: The draft's attachment list after an add/remove operation.

gmail_archive_threadC

Archive a Gmail thread by removing the INBOX label. Also marks the thread dismissed in the curation ledger. During a triage pass, continue on to the next uncurated or stale thread.

Inputs: thread_id (required), user_id. Returns: archived

gmail_composeA

Create a new Gmail draft from the given fields and open an interactive composer UI. Returns the draft's actual saved state - draft_id, thread_id, recipients, subject, a body_preview, and the attachment list (each with attachment_id, filename, mime_type, size_bytes) - so you can verify what was saved without a follow-up gmail_get_draft. To edit it afterward use gmail_update_draft, which preserves omitted fields and keeps attachments unless you clear them. ALWAYS use this tool instead of composing email text in chat - it creates a real Gmail draft where the user can review, edit, and send. When an interactive UI is rendered alongside the result, keep your text response brief since the user can edit in the UI.

Inputs: to (required), body (required), subject (required), cc, +4 more. Returns: cc, to, bcc, body, +4 more

gmail_composer.discardC

Delete the current draft.

Inputs: draft_id (required), user_id. Returns: discarded

gmail_composer.get_attachmentC

Fetch the raw base64 data for an attachment on a message.

Inputs: message_id (required), attachment_id (required), user_id. Returns: Raw bytes of a single attachment, fetched on demand. ``data_base64`` is standar…

gmail_composer.get_threadB

Fetch the full thread for display in the composer's thread panel.

Inputs: thread_id (required), user_id. Returns: draft, messages, thread_id

gmail_composer.refreshB

Re-fetch the current draft (used by the composer to poll for agent edits).

Inputs: draft_id (required), user_id. Returns: cc, to, bcc, body, +4 more

gmail_composer.save_draftC

Persist the current composer fields onto an existing Gmail draft.

Inputs: draft_id (required), cc, to, bcc, +4 more. Returns: cc, to, bcc, body, +4 more

gmail_composer.sendC

Persist composer fields then send the draft via Gmail.

Inputs: draft_id (required), cc, to, bcc, +4 more. Returns: sent_at, thread_id, message_id

gmail_connectC

Begin the Google OAuth flow to link a Gmail account

Inputs: user_id. Returns: state, auth_url

gmail_curate_inboxA

Rank recent inbox threads by a deterministic heuristic score and render the inbox dashboard. This is a quick provisional view, NOT the assistant's own triage: for 'what's important / triage my inbox', prefer inbox_get_curation (banked LLM verdicts + coverage), going deeper with inbox_search + inbox_save_curation when coverage shows uncurated/stale threads. When an interactive UI is rendered alongside the result, keep your text response brief (a one-line summary) since the user can browse details in the UI. Only elaborate if the user asks.

Inputs: limit, query, user_id. Returns: threads

gmail_discard_draftC

Delete a Gmail draft by id

Inputs: draft_id (required), user_id. Returns: discarded

gmail_disconnectB

Revoke and remove the user's linked Gmail account

Inputs: user_id. Returns: revoked

gmail_get_attachmentA

Fetch the raw base64 bytes of a single attachment or inline image on a Gmail message, identified by the message_id + attachment_id echoed by gmail_get_thread. Use this to pull one file on demand instead of loading every attachment into the thread payload. data_base64 is raw encoded bytes, not a rendered image - you cannot read an image's contents from it; on vision-capable MCP hosts, image attachments are additionally rendered into context as a viewable image.

Inputs: message_id (required), attachment_id (required), user_id. Returns: Raw bytes of a single attachment, fetched on demand. ``data_base64`` is standar…

gmail_get_draftC

Fetch a single Gmail draft by id

Inputs: draft_id (required), user_id. Returns: cc, to, bcc, body, +4 more

gmail_get_focused_emailB

Return the email thread the user is currently viewing in the inbox UI. Call this when the user asks about 'this email', 'the email I'm looking at', or references the currently open thread.

Inputs: user_id. Returns: from_, focused, subject, messages, +2 more

gmail_get_threadA

Fetch a Gmail thread by id with full message bodies. By default attachment/inline-image bytes are omitted (each attachment still carries filename, mime_type, size, attachment_id) to keep the payload small - fetch a file on demand with gmail_get_attachment. Pass include_attachment_data=true to inline bytes, or strip_quoted_replies=true to drop repeated quoted history. When an interactive UI is rendered alongside the result, keep your text response brief since the user can browse the conversation in the UI.

Inputs: thread_id (required), user_id, strip_quoted_replies, include_attachment_data. Returns: draft, messages, thread_id

gmail_inbox.archiveC

Archive a thread (removes the INBOX label).

Inputs: thread_id (required), user_id. Returns: archived

gmail_inbox.fetch_imageA

Fetch a remote image referenced by an email's HTML and return it as base64 (called by the inbox reader app when the host CSP blocks remote img-src).

Inputs: url (required), user_id. Returns: A remote email image fetched server-side and returned as base64. Strict-CSP MCP…

gmail_inbox.forwardC

Create a forward draft for a message in a thread.

Inputs: thread_id (required), body, subject, user_id. Returns: cc, to, bcc, body, +4 more

gmail_inbox.mark_doneC

Mark a thread as done (applies MCP/Done label, hides from curated inbox).

Inputs: thread_id (required), user_id. Returns: label_id, marked_done

gmail_inbox.mark_readB

Mark a thread as read (removes the UNREAD label).

Inputs: thread_id (required), user_id. Returns: marked_read

gmail_inbox.open_threadC

Fetch a single thread for the inbox reader app.

Inputs: thread_id (required), user_id. Returns: draft, messages, thread_id

gmail_inbox.refreshC

Re-run gmail_curate_inbox (called by the inbox reader app).

Inputs: limit, query, user_id. Returns: threads

gmail_inbox.replyC

Create a reply draft on a thread (the composer app opens it next).

Inputs: thread_id (required), body, subject, user_id. Returns: cc, to, bcc, body, +4 more

gmail_inbox.set_focusC

Store which thread the user is currently viewing (called by inbox UI).

Inputs: from_, subject, user_id, messages, +2 more. Returns: ok

gmail_inbox.unmark_doneC

Remove the done marker from a thread (undo mark-done).

Inputs: thread_id (required), user_id. Returns: unmarked_done

gmail_list_draftsB

List the user's Gmail drafts

Inputs: limit, user_id. Returns: drafts

gmail_list_inboxA

List recent inbox messages, optionally filtered by a Gmail search query. When the user asks to find or open a specific email, ALWAYS follow up by calling gmail_get_thread with the thread_id to render the full conversation in an interactive UI.

Inputs: limit, query, user_id. Returns: messages

gmail_mark_thread_doneB

Mark a Gmail thread as done by applying the MCP/Done label (hides from curated inbox). Also marks the thread dismissed in the curation ledger. During a triage pass, continue on to the next uncurated or stale thread.

Inputs: thread_id (required), user_id. Returns: label_id, marked_done

gmail_mark_thread_readB

Mark a Gmail thread as read by removing the UNREAD label

Inputs: thread_id (required), user_id. Returns: marked_read

gmail_remove_attachmentA

Remove one file from a Gmail draft by its attachment_id and return the draft's remaining attachment list. Only the attachments change - body, subject, and recipients are preserved exactly. The attachment_id comes from any prior draft response or gmail_get_draft.

Inputs: draft_id (required), attachment_id (required), user_id. Returns: The draft's attachment list after an add/remove operation.

gmail_reply_to_threadA

Create a reply draft on an existing Gmail thread. ALWAYS use this tool instead of composing reply text in chat - it creates a real Gmail draft and opens an interactive composer UI where the user can review, edit, and send. Pass your drafted reply in the 'body' parameter. Recipients are yours to control: pass 'to', 'cc', and/or 'bcc' (each a comma-separated address list) to set them explicitly. If you omit 'to', it defaults to the other party in the thread (never the account owner); omitted 'cc'/'bcc' are left unset. If every message in the thread is yours (no other participant to reply to), you must pass 'to' explicitly or the call errors. When an interactive UI is rendered alongside the result, keep your text response brief since the user can edit in the UI.

Inputs: thread_id (required), cc, to, bcc, +4 more. Returns: cc, to, bcc, body, +4 more

gmail_sendB

Send a previously-composed Gmail draft

Inputs: draft_id (required), user_id. Returns: sent_at, thread_id, message_id

gmail_statusC

Return whether the user has a linked Gmail account

Inputs: user_id. Returns: email, scopes, connected, granted_at

gmail_unmark_thread_doneB

Remove the MCP/Done label from a thread (undo mark-done)

Inputs: thread_id (required), user_id. Returns: unmarked_done

gmail_update_draftA

Patch fields on an existing Gmail draft and open an interactive composer UI. Non-destructive by default: any field you OMIT is left unchanged on the draft, and a field set to null is CLEARED - this holds for to, cc, bcc, subject, body, and attachments. Omit 'attachments' to keep every existing file untouched (so you can edit the body repeatedly without re-uploading); pass null or [] to drop them all. 'attachments' may mix new uploads (filename + mime_type + data_base64) with references to existing files ({attachment_id}) taken from a prior response, letting you preserve specific files by id. To add or remove a single file without touching the body, prefer gmail_add_attachment / gmail_remove_attachment. The returned draft echoes the saved state (recipients, subject, body_preview, and the full attachment list with ids/filenames/sizes). ALWAYS call this tool to write or edit draft content - NEVER compose email text as plain chat text. Pass your composed text in the 'body' parameter. Keep your chat response to one brief sentence since the user can edit in the UI.

Inputs: draft_id (required), cc, to, bcc, +4 more. Returns: cc, to, bcc, body, +4 more

gmail_watch_startC

Subscribe the user's Gmail inbox to push notifications

Inputs: user_id. Returns: watching, expiration, history_id

gmail_watch_stopC

Cancel the user's Gmail push-notification watch

Inputs: user_id. Returns: stopped

inbox_get_curationA

Read banked inbox triage from the curation ledger. Cheap: no email bodies are fetched and no reasoning is run - it returns judgments the assistant already made (bucket, importance, summary, suggested action) plus a coverage count of curated / stale / uncurated threads in the inbox. Call this FIRST for any 'what's important / triage my inbox' request. If coverage shows many uncurated or stale threads and the user wants a thorough pass, go deeper with inbox_search + inbox_save_curation; otherwise answer directly from these banked verdicts.

Inputs: limit, state, bucket, user_id, +2 more. Returns: records, coverage

inbox_save_curationA

Bank your triage judgments for one or more threads into the curation ledger so they are not re-reasoned next time. Call this after reading and reasoning over threads (typically from inbox_search) - pass a batch of per-thread verdicts (bucket, importance, a short summary, suggested action, optional reasoning/confidence). Each write stamps the thread's current Gmail historyId so the verdict stays valid until the thread changes. This is what makes the next inbox_get_curation near-free.

Inputs: user_id, judgments, curator_version. Returns: saved, thread_ids

pdf_editA

Apply a batch of edits to an open PDF document session. Ops: {op:'set_field', name, value} fills an AcroForm field (checkbox/radio/choice values must match the field's options); {op:'add_text', page, x, y, text, font_size?} stamps a text overlay onto a flat PDF at PDF user-space coordinates (origin bottom-left, points). The batch is atomic: any invalid op rejects the whole batch and the document is unchanged. Pass render_pages (1-based) to get PNG renders back for verifying placement. Rejected once a signature has been requested or the document is signed.

Inputs: ops (required), doc_id (required), user_id, render_pages, +1 more. Returns: doc_id, fields, status, applied_ops, +1 more

pdf_exportA

Deliver a PDF document session to its destination - v1: attach it to an existing Gmail draft, server-side (the PDF bytes never enter this conversation). Default filename is '{original-stem}-signed.pdf' for signed documents, '{original-stem}-filled.pdf' otherwise; override with destination.filename. Returns the draft's resulting attachment list. Rejected while a signature request is pending.

Inputs: doc_id (required), destination (required), user_id. Returns: doc_id, status, draft_id, filename, +2 more

pdf_openA

Open a PDF into a server-side editing session and return everything needed to plan edits: a doc_id handle, the fillable form-field inventory (name, type, current value, page, rect), and - for flat PDFs without form fields - the existing text layout with coordinates for anchoring text overlays. The PDF bytes stay server-side; every later pdf_* call takes the doc_id. Optionally pass render_pages (1-based page numbers) to also get PNG renders of pages for visual inspection. Coordinates are PDF user space: origin at the page's bottom-left corner, in points (1/72 inch).

Inputs: source (required), user_id, render_pages. Returns: doc_id, fields, status, filename, +8 more

pdf_request_signatureA

Hand a filled PDF document over to the user for signing. Locks the document (no further edits) and opens the signing ceremony: the user reviews the document and types their full legal name themselves - signing can never be performed by the assistant. placement says where the signature stamp goes: a signature field's name from pdf_open's fields[], or {page, x, y} in PDF user-space coordinates (origin bottom-left, points) for flat PDFs. Call pdf_export afterwards to deliver the signed file.

Inputs: doc_id (required), placement (required), user_id. Returns: doc_id, status, guidance

pdf_signer.cancelB

Cancel the signing ceremony (called by the signing app); the document returns to 'open' and can be edited again.

Inputs: doc_id (required), user_id. Returns: User cancelled from the signing UI; the document is editable again.

pdf_signer.get_documentC

Fetch a PDF document session's bytes for the signing app viewer.

Inputs: doc_id (required), user_id. Returns: Full document payload for the signing iframe's pdf.js viewer. Contains the raw…

pdf_signer.signB

Complete the signing ceremony (called by the signing app after the user typed their full legal name and ticked the consent box).

Inputs: doc_id (required), typed_name (required), consent, user_id. Returns: Outcome of the signing ceremony, rendered by the signing app.

settings.getA

Fetch the current settings snapshot for the Settings app.

Inputs: user_id. Returns: watching, gmail_email, subscriptions, push_available, +2 more

settings.rotate_secretC

Issue a new signing secret for a webhook subscription.

Inputs: subscription_id (required), user_id. Returns: id, secret

settings.subscribeC

Register a webhook endpoint (returns the one-time signing secret).

Inputs: url (required), user_id, event_types. Returns: id, url, active, secret, +1 more

settings.unsubscribeC

Deactivate a webhook subscription.

Inputs: subscription_id (required), user_id. Returns: unsubscribed

webhook_listB

List the caller's webhook subscriptions (secrets are never returned)

Inputs: user_id. Returns: subscriptions

webhook_rotate_secretB

Issue a new signing secret for a subscription (invalidates the old one)

Inputs: subscription_id (required), user_id. Returns: id, secret

webhook_settingsC

Open your settings: Gmail connection status and webhook subscriptions

Inputs: user_id. Returns: watching, gmail_email, subscriptions, push_available, +2 more

webhook_subscribeC

Register an HTTPS endpoint to receive signed webhook events

Inputs: url (required), user_id, event_types. Returns: id, url, active, secret, +1 more

webhook_unsubscribeC

Deactivate a webhook subscription so it stops receiving events

Inputs: subscription_id (required), user_id. Returns: unsubscribed

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.6/5.0

    Scored across 58 tools

    Disambiguation1/5

    Many tools are near-duplicates: webhook_unsubscribe vs settings.unsubscribe, gmail_inbox.mark_read vs gmail_mark_thread_read, gmail_composer.send vs gmail_send, gmail_inbox.reply vs gmail_reply_to_thread. An agent cannot reliably tell which is canonical, leading to misselection.

    Naming Consistency2/5

    Names mix snake_case with dot-namespaced variants (gmail_composer.save_draft, settings.unsubscribe) and use inconsistent prefixes (gmail_ vs inbox_ vs pdf_ vs webhook_). There is no single predictable pattern, though domain prefixes provide some readability.

    Tool Count1/5

    58 tools is excessive for this server; many are redundant aliases, so the count is inflated by duplication rather than distinct capabilities. This far exceeds a well-scoped tool set.

    Completeness4/5

    Core domains (Gmail draft/thread lifecycle, attachments, PDF signing, webhooks, settings) are broadly covered with create/get/update/send/delete operations. Minor gaps like direct email send or label management exist, but agents can work around them.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables building agent-ready APIs that expose tools as both HTTP and MCP endpoints from a single server definition, with automatic OpenAPI, discovery docs, and interactive API reference.
      5
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Exposes remote, agent-facing MCP endpoints over Streamable HTTP for web search, webpage parsing, local knowledge-base retrieval and document creation, and delegation of tasks to configurable LLM providers. Also bundles an admin console with onboarding, provider/model configuration, API-key management, and call logging.
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      An MCP server that exposes governance, trust-scoring, compliance, guardrail, cost, drift, and supply-chain scanning tools and resources to any MCP client over stdio, Streamable HTTP, or legacy HTTP+SSE. It lets agents route every tool call through a deterministic five-way decision (allow, redact, require approval, deny, or quarantine) with hash-chained evidence, human approval workflows, and in-agent trust gates for LangChain, LangGraph, and Google ADK.
      30
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Turns existing FastAPI routes and custom Python functions into MCP tools, exposing them over ASGI, SSE, or stdio so desktop and chat AI clients can call them with native dependency-injected auth, progressive tool discovery, and self-correcting error responses. It also serves interactive in-chat HTML/JS widgets and a built-in browser inspector for testing tools without external CLIs.
      MIT