microsoft-ads-mcp
MCP server for Microsoft Advertising (Bing Ads) REST API enabling agent-led campaign management and reporting. It provides tools to manage campaigns, ad groups, keywords, ads, budgets, and pull performance reports.
README
microsoft-ads-mcp
An MCP server for the Microsoft Advertising (Bing Ads) REST API, built for agent-led campaign management and reporting. It exposes a focused set of useful-work tools — walk the campaign tree, add keywords/ads, manage budgets and status, and pull performance reports that are actually downloaded and parsed for you — rather than a 1:1 mirror of the API surface.
Built with FastMCP and the official Microsoft
msads REST SDK (which ships OpenAPI-generated Pydantic
v2 models). Managed with uv, linted/formatted with ruff, type-checked with ty.
This is a ground-up rewrite of the original single-file
server.py, restructured to mirror the architecture of its sibling projectopenai-ads-mcp.
Why REST / msads (not the legacy SOAP bingads SDK)
Microsoft is retiring the SOAP API: new features are REST-only from Oct 1, 2026, and SOAP
is fully deprecated on Jan 31, 2027 (migration guide).
The REST SDK msads gives typed Pydantic models, structured HTTP exceptions, and the same
OAuth/ServiceClient entry points — so this server is built on it directly.
SDK quirks worth knowing
msadsis synchronous (requests/urllib3). Tools here are therefore plain sync functions; FastMCP runs them in a worker thread, so the event loop is never blocked. We do not wrap the SDK in async.msadsdoes not declare itspython-dateutildependency, even thoughopenapi_clientimports it. We pinpython-dateutilexplicitly inpyproject.toml.- The package installs as the
bingads.*(auth +ServiceClient) andopenapi_client.*(models + exceptions) import namespaces — there is no top-levelmsadsmodule.
Quickstart
uv sync # create .venv and install
cp .env.example .env # then set the credentials below
uv run python -m microsoft_ads_mcp # run over stdio (default)
Configuration
Set via environment variables or a local .env (see .env.example):
| Variable | Required | Notes |
|---|---|---|
MICROSOFT_ADS_DEVELOPER_TOKEN |
yes | From the developer portal |
MICROSOFT_ADS_CLIENT_ID |
yes | Azure AD app (client) id |
MICROSOFT_ADS_REFRESH_TOKEN |
recommended | Run non-interactively; else mint one via the auth tools |
MICROSOFT_ADS_CLIENT_SECRET |
no | Only for web/confidential app registrations |
MICROSOFT_ADS_ACCOUNT_ID / MICROSOFT_ADS_CUSTOMER_ID |
no | Discovered via search_accounts if unset |
MICROSOFT_ADS_ENVIRONMENT |
no | production (default) or sandbox |
READ_ONLY |
no | true registers no write tools at all (default false) |
Refresh tokens are persisted to ~/.config/microsoft-ads/tokens.json, created with 0600
permissions (owner read/write only).
Authentication
If you have no refresh token yet, mint one once (interactive):
- Call
get_auth_url()→ open the URL, sign in. - Copy the redirect URL and call
complete_auth(redirect_url). - The refresh token is saved and reused/auto-refreshed thereafter.
MCP client configuration
{
"mcpServers": {
"microsoft-ads": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "${CLAUDE_PROJECT_DIR:-.}", "python", "-m", "microsoft_ads_mcp"],
"env": {
"MICROSOFT_ADS_DEVELOPER_TOKEN": "...",
"MICROSOFT_ADS_CLIENT_ID": "...",
"MICROSOFT_ADS_REFRESH_TOKEN": "...",
"READ_ONLY": "false"
}
}
}
}
Tools
Call account_health first to validate credentials and learn whether writes are enabled.
Read — account_health, search_accounts, account_overview, get_campaigns,
get_ad_groups, get_keywords, get_ads, get_budgets.
Reporting — run_performance_report (submit → poll → download → parse, returns rows),
covering campaign / keyword / search-query / geographic reports.
Write (only when READ_ONLY=false) — create_campaign, update_campaign_status,
create_ad_group, add_keywords, create_responsive_search_ad.
Architecture
src/microsoft_ads_mcp/
config.py # pydantic-settings; all env config
server.py # builds FastMCP, lifespan-manages the client, registers tools
api/
auth.py # OAuth flow + hardened token store
client.py # wraps msads ServiceClient(s); the single dispatch point
errors.py # translate openapi_client exceptions -> MsAdsApiError
domain/
entities.py # lean Pydantic summary/report models for tool outputs
services/
campaigns.py # hierarchy + list reads
mutations.py # create/update flows
reporting.py # submit/poll/download/parse
tools/
health.py read_tools.py write_tools.py reporting_tools.py # registered, READ_ONLY-gated
Development
uv run ruff check . && uv run ruff format --check .
uv run ty check
uv run pytest -q
# or all at once:
bash scripts/ci.sh
License
MIT — see LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。