openai-ads-mcp
An MCP server for the OpenAI Ads (ChatGPT Ads) Advertiser API, providing tools for agent-led performance marketing such as finding dead ads, auditing near-duplicate copy, and auditing ad-group context hints.
README
openai-ads-mcp
An MCP server for the OpenAI Ads (ChatGPT Ads) Advertiser API, built for agent-led performance marketing. It exposes a small set of high-leverage, useful-work tools — find dead ads, audit near-duplicate copy, audit ad-group context hints, and (optionally) act on the findings — rather than a 1:1 mirror of the REST API.
Built with FastMCP, httpx, and Pydantic. Managed with uv,
linted/formatted with ruff, type-checked with ty.
Quickstart
uv sync # create .venv and install
cp .env.example .env # then set OPENAI_ADS_API_KEY
uv run python -m openai_ads_mcp # run over stdio (default)
Or point an MCP client at it with fastmcp run src/openai_ads_mcp/server.py:mcp.
MCP client configuration
Real agents launch the server over stdio and pass configuration in the env block of
the client's config — no .env file or shared working directory required. The examples below
go in .mcp.json (Claude Code), claude_desktop_config.json (Claude Desktop), or the
equivalent mcpServers block for any other client.
Project-scoped (agent runs inside the checkout)
This is the form in this repo's .mcp.json. ${CLAUDE_PROJECT_DIR:-.} resolves
to the project root, so uv finds the right environment. The key comes from the ambient shell
or a .env here — add it to env to be explicit.
{
"mcpServers": {
"openai-ads": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "${CLAUDE_PROJECT_DIR:-.}", "python", "-m", "openai_ads_mcp"],
"env": {
"OPENAI_ADS_API_KEY": "sk-svcacct-...",
"READ_ONLY": "false"
}
}
}
}
From any directory (absolute path)
Most users run the agent somewhere other than this repo. Point --directory at an absolute
path to the checkout and pass the key in env — this works regardless of the agent's cwd:
{
"mcpServers": {
"openai-ads": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "/abs/path/to/openai-ads-mcp", "python", "-m", "openai_ads_mcp"],
"env": {
"OPENAI_ADS_API_KEY": "sk-svcacct-..."
}
}
}
}
Installed console script
Install once with uv tool install /abs/path/to/openai-ads-mcp (or
uv tool install git+<repo-url>), then reference the openai-ads-mcp script directly — no
--directory needed:
{
"mcpServers": {
"openai-ads": {
"type": "stdio",
"command": "openai-ads-mcp",
"env": {
"OPENAI_ADS_API_KEY": "sk-svcacct-...",
"READ_ONLY": "true"
}
}
}
}
Passing the API key. Put it in the
envblock above — that's the standard MCP mechanism andpydantic-settingsreads it straight from the process environment. There is intentionally no--api-keyCLI flag: secrets inargvare visible to other users viapsand tend to leak into shell history and logs. Useenv, or a.envfile when the agent shares the checkout.
HTTP transport
To run the server once and connect over HTTP instead of spawning it per-client, start it with
MCP_TRANSPORT=http (see the table below) and point the client at the URL:
{
"mcpServers": {
"openai-ads": { "type": "http", "url": "http://127.0.0.1:8000/mcp" }
}
}
Configuration
All configuration is via environment variables — set them in the client's env block (above),
the ambient shell, or a local .env:
| Variable | Default | Purpose |
|---|---|---|
OPENAI_ADS_API_KEY |
— (required) | Advertiser API key; identifies the single ad account. |
OPENAI_ADS_BASE_URL |
https://api.ads.openai.com/v1 |
API base URL. |
READ_ONLY |
false |
When true, write tools are not registered and cannot be called. |
MCP_TRANSPORT |
stdio |
stdio or http. |
MCP_HOST / MCP_PORT |
127.0.0.1 / 8000 |
Bind address for http transport. |
Read-only mode
Set READ_ONLY=true to run a safe, analysis-only server. The write tools are never
registered, so they don't appear in the tool list and can't be invoked — there is no way for a
client to bypass it. The default is false (writes enabled).
Tools
Read (always available)
| Tool | What it does |
|---|---|
account_health |
Validate the key; report account currency, timezone, and read_only. Call first. |
account_overview |
Walk campaign → ad group → ad once; compact tree with statuses and counts. |
ad_performance |
Per-ad insights + conversions over a window, with CTR/CPC/CPM and a dead/underperforming/ok flag. The core "find dead ads" tool. |
copy_audit |
Find near-duplicate titles/bodies and length/guidance issues in a scope. |
context_hints_audit |
Flag ad groups with missing or thin context_hints. |
get_insights |
Escape hatch for raw insight rows at any aggregation level. |
get_campaign / get_ad_group / get_ad |
By-id reads, including serving_issues (which list calls omit). |
Write (only when READ_ONLY=false)
| Tool | What it does |
|---|---|
pause_ads / archive_ads |
Bulk pause (reversible) / archive (irreversible, needs confirm=true), error-isolated per id. |
set_status |
Single activate/pause/archive transition on a campaign, ad group, or ad. |
update_ad_copy |
Update an ad's creative copy (re-sends the full creative for you). |
create_ad_variant |
Upload a creative image and create a new ad in one step. |
create_campaign / create_ad_group |
Create entities with flattened, agent-friendly params. |
update_campaign / update_ad_group |
Update entities (budget/targeting/bidding/context hints). |
A sibling agent skill at skill/openai-ads-optimizer/SKILL.md
teaches an agent how and when to use these tools, plus the OpenAI Ads creative guidance. The server
also serves this skill as an MCP resource (skill://openai-ads-optimizer/SKILL.md), so any connected
client can discover the playbook without a local copy.
Architecture
tools/ → MCP layer (@mcp.tool wrappers, READ_ONLY gate)
services/ → orchestration (hierarchy walk, performance, audits, mutations)
domain/ → pure data shapes + business rules (entities, insights, thresholds, copy audit)
api/ → async httpx client (auth, retry, pagination, errors)
The client mirrors the API's real semantics: reads (and the conversions POST, which has read
semantics) are retried on transient failures; other writes are never retried. It also handles
the API's quirks — no global ad list, until = today rejection, conversions on a separate
endpoint, decimal spend vs. micros bids.
Development
bash scripts/ci.sh # ruff check + format check + ty + pytest
Requires Python 3.14 and uv.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。