Skip to content

适用于 ADK 的 AgentPhone MCP 工具

ADK 已支持PythonTypeScript

AgentPhone MCP 服务器 将你的 ADK 智能体连接到 AgentPhone —— 一个专为 AI 智能体打造的电话平台。此次集成赋予了你的智能体拨打和接听电话、发送和接收短信、管理电话号码以及使用自然语言创建自主 AI 语音智能体的能力。

使用案例

  • 自主电话通话:让你的智能体拨打某个电话号码,并围绕特定主题进行完整的 AI 驱动对话,并在完成后返回完整的转录文本。

  • 短信发送:发送和接收文本消息,跨多个电话号码管理对话线程,并检索消息历史记录。

  • 电话号码管理:配置具有特定区号的电话号码,将其分配给智能体,并在不再需要时释放号码。

  • AI 语音智能体:创建具有可配置语音和系统提示语的智能体,自动处理呼入和呼出电话,无需配置 Webhook。

  • Webhook 集成:设置项目级或智能体级的 Webhook,以接收有关呼入消息和通话事件的实时通知。

先决条件

与智能体配合使用

from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
from mcp import StdioServerParameters

AGENTPHONE_API_KEY = "你的_AGENTPHONE_API_KEY"

root_agent = Agent(
    model="gemini-2.5-pro",
    name="agentphone_agent",
    instruction="帮助用户拨打电话、发送短信和管理电话号码",
    tools=[
        McpToolset(
            connection_params=StdioConnectionParams(
                server_params=StdioServerParameters(
                    command="npx",
                    args=[
                        "-y",
                        "agentphone-mcp",
                    ],
                    env={
                        "AGENTPHONE_API_KEY": AGENTPHONE_API_KEY,
                    }
                ),
                timeout=30,
            ),
        )
    ],
)
from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams

AGENTPHONE_API_KEY = "你的_AGENTPHONE_API_KEY"

root_agent = Agent(
    model="gemini-2.5-pro",
    name="agentphone_agent",
    instruction="帮助用户拨打电话、发送短信和管理电话号码",
    tools=[
        McpToolset(
            connection_params=StreamableHTTPConnectionParams(
                url="https://mcp.agentphone.to/mcp",
                headers={
                    "Authorization": f"Bearer {AGENTPHONE_API_KEY}",
                },
            ),
        )
    ],
)
import { LlmAgent, MCPToolset } from "@google/adk";

const AGENTPHONE_API_KEY = "你的_AGENTPHONE_API_KEY";

const rootAgent = new LlmAgent({
    model: "gemini-2.5-pro",
    name: "agentphone_agent",
    instruction: "帮助用户拨打电话、发送短信和管理电话号码",
    tools: [
        new MCPToolset({
            type: "StdioConnectionParams",
            serverParams: {
                command: "npx",
                args: ["-y", "agentphone-mcp"],
                env: {
                    AGENTPHONE_API_KEY: AGENTPHONE_API_KEY,
                },
            },
        }),
    ],
});

export { rootAgent };
import { LlmAgent, MCPToolset } from "@google/adk";

const AGENTPHONE_API_KEY = "你的_AGENTPHONE_API_KEY";

const rootAgent = new LlmAgent({
    model: "gemini-2.5-pro",
    name: "agentphone_agent",
    instruction: "帮助用户拨打电话、发送短信和管理电话号码",
    tools: [
        new MCPToolset({
            type: "StreamableHTTPConnectionParams",
            url: "https://mcp.agentphone.to/mcp",
            transportOptions: {
                requestInit: {
                    headers: {
                        Authorization: `Bearer ${AGENTPHONE_API_KEY}`,
                    },
                },
            },
        }),
    ],
});

export { rootAgent };

可用工具

账号 (Account)

工具名 描述
account_overview 账号完整快照:包含智能体、号码、Webhook 状态、限制使用额度。
get_usage 详细使用统计:套餐限制、号码配额、消息/通话量。

电话号码 (Phone numbers)

工具名 描述
list_numbers 列出账号中的所有电话号码。
buy_number 购买新的电话号码,可选择国家和区号。
release_number 将电话号码永久释放回电信商池。

短信/消息 (SMS / Messages)

工具名 描述
get_messages 获取特定电话号码的短信。
list_conversations 列出所有号码的短信对话线程。
get_conversation 获取具有完整消息历史记录的特定对话。

语音通话 (Voice calls)

工具名 描述
list_calls 列出所有号码的最近通话。
list_calls_for_number 列出特定电话号码的通话。
get_call 获取通话详情和转录(支持长轮询选项)。
make_call 使用 Webhook 处理对话,拨打呼出电话。
make_conversation_call 拨打自主 AI 通话,并返回完整的转录文本。

智能体 (Agents)

工具名 描述
list_agents 列出所有带有电话号码和语音配置的智能体。
create_agent 创建具有可配置语音和系统提示语的新智能体。
update_agent 更新智能体配置。
delete_agent 删除一个智能体。
get_agent 获取智能体详情,包括号码和语音配置。
attach_number 向智能体分配电话号码。
list_voices 列出可用的语音选项。

Webhook

工具名 描述
get_webhook 获取项目级 Webhook 配置。
set_webhook 为呼入消息和通话事件设置项目级 Webhook。
delete_webhook 移除项目级 Webhook。
get_agent_webhook 获取特定智能体的 Webhook。
set_agent_webhook 设置智能体特定的 Webhook(会覆盖项目级设置)。
delete_agent_webhook 移除智能体特定的 Webhook。

配置

AgentPhone MCP 服务器可以使用环境变量进行配置:

变量名 描述 默认值
AGENTPHONE_API_KEY 你的 AgentPhone API 密钥 必填(stdio 模式下)
AGENTPHONE_BASE_URL 覆盖 API 基础 URL https://api.agentphone.to

对于远程 HTTP 模式,请通过 Authorization: Bearer Header 传递 API 密钥,而不是通过环境变量。

其他资源