元cli
用于Meta Marketing API的CLI和MCP服务器。
从您的终端或任何使用MCP的人工智能代理创建活动、上传创意、配置目标和管理广告。
安装
curl -fsSL https://raw.githubusercontent.com/enriquefft/meta-cli/main/install.sh | sh或者使用Go:
go install github.com/enriquefft/meta-cli/cmd/meta@latest更新
# Check for a new version (no download)
meta update --check
# Upgrade to the latest release in place
meta update
# Pin to a specific version
meta update --version 0.3.0meta update 重新运行该官员 install.sh 脚本已固定到目标 标签,因此升级过程与新安装相同——相同 校验和,相同的安装目录,相同的二进制路径。CLI不 复制任何下载或验证逻辑。
如果您是通过安装的 go install,跑 go install github.com/enriquefft/meta-cli/cmd/meta@latest 升级。 meta update 检测此情况并打印相同的提示,而不是 运行安装脚本。
快速开始
# Configure your Meta access token
meta config set access_token
# Verify authentication
meta auth status
# List your ad accounts
meta accounts list
# Create a campaign (paused by default)
meta campaigns create \
--name "Summer Sale" \
--objective OUTCOME_SALES \
--daily-budget 50.00
# Find targeting interests
meta targeting search --query "e-commerce" --type interest
# Full pipeline: campaign → ad set → creative → ad
meta campaigns create --name "Launch" --objective OUTCOME_TRAFFIC --daily-budget 25.00
meta adsets create --campaign-id --name "US 25-45" --countries US --age-min 25 --age-max 45
meta creatives create --name "Hero Video" --page-id
--video-id --message "Shop now" --link "https://example.com"
meta ads create --adset-id --creative-id --name "Ad v1"MCP服务器
启动MCP服务器以进行AI代理集成:
meta serve添加到您的MCP客户端配置(Claude Desktop、Cursor等):
{
"mcpServers": {
"meta": {
"command": "meta",
"args": ["serve"]
}
}
}可用工具
| 工具 | 说明 |
|---|---|
meta_auth_status | 验证令牌有效性和权限 |
meta_list_accounts | 列出可访问的广告帐户 |
meta_list_pages | 列出管理的Facebook页面 |
meta_upload_video | 将视频资产上传到广告帐户 |
meta_upload_image | 将图像资产上传到广告帐户(也用作视频缩略图) |
meta_video_status | 检查视频编码状态 |
meta_search_targeting | 搜索兴趣、行为、人口统计 |
meta_create_campaign | 创建具有目标和预算的活动 |
meta_create_adset | 创建带有目标和时间表的广告集 |
meta_create_creative | 利用媒体和文案打造广告创意 |
meta_create_ad | 将创意链接到广告集 |
该服务器内置了指导AI代理完成完整广告创建工作流程的指令。
命令
meta config [get|set|unset] Manage configuration
meta auth status Verify access token
meta accounts list List ad accounts
meta pages list List Facebook Pages
meta assets upload-video Upload video for creatives
meta assets upload-image Upload image for creatives (used as video thumbnail)
meta assets status Check video encoding status
meta campaigns create Create advertising campaign
meta adsets create Create ad set with targeting
meta creatives create Create ad creative
meta ads create Create ad linking creative to ad set
meta targeting search Search targeting interests/behaviors
meta serve Start MCP server (stdio)全球旗帜
-a, --account Override default ad account
-f, --format Output format: json, table, csv
--fields
Comma-separated fields to include
--dry-run Validate without creating resources
-v, --verbose Enable debug logging
--no-color Disable colored output配置
配置文件: ~/.config/meta-cli/config.yaml
access_token: "EAA..."
default_account: "act_123456789"
api_version: "v21.0"
output_format: "json"环境变量覆盖配置文件:
META_ACCESS_TOKEN=EAA...
META_AD_ACCOUNT=act_123456789
META_API_VERSION=v21.0
META_OUTPUT_FORMAT=json解析顺序:标志>环境变量>配置文件>默认值。
从源头构建
需要Go 1.26+和 仅仅.
just build # Build to bin/meta
just test # Run tests
just lint # Run golangci-lint
just install # Install to $GOBIN建筑
CLI (cobra) │ MCP (mcp-go) ← thin shells: parse input, call domain, format output
────────┼────────
internal/meta/ ← domain operations (single source of truth)
│
internal/graph/ ← HTTP transport, retry, rate limiting, uploads
│
Meta Marketing API- 深度模块设计 --很少有具有宽接口的模块隐藏了大量的复杂性
- 域拥有抽象 —
internal/meta/定义Client接口;internal/graph/实施它 - shell中没有业务逻辑 --CLI和MCP是精简的翻译层
- 边界处的预算转换 --用户输入美元,域名说美分
许可证
麻省理工学院
