DemandSphere MCP Server
Connects AI assistants to the DemandSphere search intelligence platform, enabling SERP analytics and GenAI visibility tracking through 20 tools across five domains.
README
DemandSphere MCP Server
An MCP (Model Context Protocol) server that connects AI assistants to the DemandSphere search intelligence platform. Supports both traditional SERP analytics (v5.0) and GenAI visibility tracking (v5.1).
What It Does
This server exposes 20 tools across five domains:
| Domain | Tools | API Version |
|---|---|---|
| Site Discovery | list_sites, list_sites_flat |
v5.0 |
| SERP Analytics | serp_analytics (views: performance, trends, engine_comparison, engine_summary), get_keyword_groups, get_local_rankings, get_landing_matches, get_landings_history |
v5.0 |
| GenAI Visibility | get_mentions, get_keyword_citations, get_bulk_citations, get_site_citations, llm_analytics (views: stats, performance, channels, cross_channel, cross_llms), get_llm_filters, get_people_also_ask |
v5.1 |
| Brand Management | list_brands, create_brand, update_brand, delete_brands |
v5.1 |
| ChatGPT Deep Research | search, fetch |
compat |
Quick Start
1. Install
With uv (recommended):
git clone https://github.com/DemandSphereDev/demandsphere-mcp.git
cd demandsphere-mcp
uv sync
With pip:
git clone https://github.com/DemandSphereDev/demandsphere-mcp.git
cd demandsphere-mcp
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
2. Configure API Key
Choose one method:
# Option A: Environment variable
export DEMANDSPHERE_API_KEY="your-api-key"
# Option B: Config file
mkdir -p ~/.config/demandsphere
echo '{"api_key": "your-api-key"}' > ~/.config/demandsphere/config.json
# Option C: .env file in project root
echo 'DEMANDSPHERE_API_KEY=your-api-key' > .env
3. Run
With uv:
# stdio (default — for Claude Code, Claude Desktop, Cursor)
uv run demandsphere-mcp
# HTTP (for hosted/remote deployment)
DEMANDSPHERE_TRANSPORT=streamable-http uv run demandsphere-mcp
With pip (after install):
# stdio
demandsphere-mcp
# HTTP
DEMANDSPHERE_TRANSPORT=streamable-http demandsphere-mcp
4. Connect to Your MCP Client
Claude Desktop / Cursor — add to your MCP config:
With uv:
{
"mcpServers": {
"demandsphere": {
"command": "uv",
"args": ["run", "--directory", "/path/to/demandsphere-mcp", "demandsphere-mcp"],
"env": {
"DEMANDSPHERE_API_KEY": "your-api-key"
}
}
}
}
With pip (after pip install -e .):
{
"mcpServers": {
"demandsphere": {
"command": "demandsphere-mcp",
"env": {
"DEMANDSPHERE_API_KEY": "your-api-key"
}
}
}
}
Claude Code:
claude mcp add demandsphere \
-e DEMANDSPHERE_API_KEY=your-api-key \
-- uv run --directory /path/to/demandsphere-mcp demandsphere-mcp
Security Model
Transport Modes
| Transport | Use Case | Security Boundary |
|---|---|---|
| stdio | Local (Claude Code, Cursor) | OS process isolation; no network exposure |
| Streamable HTTP | Self-hosted / remote | HTTPS via reverse proxy |
API Key Handling
The DemandSphere API uses query-parameter auth. The MCP server holds the key and injects it into every outbound request. The AI model never sees the key.
Important: Because the API key is in the URL query string, it may appear in reverse proxy access logs, CDN logs, or network monitoring tools. If deploying behind a reverse proxy, configure it to strip or redact query strings from access logs.
| Method | Best For |
|---|---|
| Environment variable | Local dev, CI/CD |
Config file (~/.config/demandsphere/) |
Personal machines |
.env file |
Local dev |
Self-Hosting
You can deploy the MCP server yourself on any platform that supports Docker or Python:
Docker:
docker build -t demandsphere-mcp .
docker run -p 127.0.0.1:8765:8765 \
-e DEMANDSPHERE_API_KEY=your-api-key \
demandsphere-mcp
The server is available at http://localhost:8765/mcp. Works with Cloudflare Workers, Railway, Fly.io, Northflank, Render, Google Cloud Run, AWS Fargate, or any container platform. A docker-compose.yml is included with production hardening (cap_drop, read_only, non-root).
Without Docker:
DEMANDSPHERE_TRANSPORT=streamable-http \
DEMANDSPHERE_HOST=0.0.0.0 \
DEMANDSPHERE_API_KEY=your-api-key \
demandsphere-mcp
Put an HTTPS reverse proxy (Caddy, nginx, Cloudflare Tunnel) in front for production use.
Rate Limiting
Client-side token-bucket rate limiter (default: 60 req/min). Response shaping caps result sets at 100 rows per tool call to keep LLM token costs manageable. Both are configurable via environment variables.
Configuration Reference
All settings via environment variables (prefix DEMANDSPHERE_):
| Variable | Default | Description |
|---|---|---|
DEMANDSPHERE_API_KEY |
(required for stdio) | DemandSphere API key |
DEMANDSPHERE_BASE_URL |
https://api.demandsphere.com |
API base URL |
DEMANDSPHERE_TRANSPORT |
stdio |
stdio or streamable-http |
DEMANDSPHERE_HOST |
127.0.0.1 |
HTTP server bind address |
DEMANDSPHERE_PORT |
8765 |
HTTP server port |
DEMANDSPHERE_REQUEST_TIMEOUT |
30.0 |
HTTP timeout (seconds) |
DEMANDSPHERE_MAX_REQUESTS_PER_MINUTE |
60 |
Rate limit cap |
DEMANDSPHERE_MAX_RESULTS_PER_TOOL_CALL |
100 |
Max rows per response |
Project Structure
demandsphere-mcp/
├── pyproject.toml # Package config + deps
├── Dockerfile # Container deployment
├── docker-compose.yml # Production hardening example
├── CHANGELOG.md # Version history
├── CONTRIBUTING.md # Contribution guidelines
├── config.example.json # API key config example
├── examples/
│ ├── mcp-config-uv.json # MCP client config (uv)
│ └── mcp-config-pip.json # MCP client config (pip)
├── tests/
│ ├── test_core.py # Unit tests (validators, shaping, errors)
│ ├── test_hints.py # Hint builder tests
│ ├── test_brands.py # Brand dry_run tests
│ ├── test_consolidated.py # serp_analytics + llm_analytics tests
│ ├── test_prompts.py # MCP Prompt tests
│ └── test_resources.py # MCP Resource tests
└── src/demandsphere_mcp/
├── __init__.py
├── py.typed # PEP 561 type marker
├── server.py # MCP server entry point
├── config.py # Settings (env vars + config file)
├── client.py # Async HTTP client + rate limiter
└── tools/
├── __init__.py
├── utils.py # Error handling, validation, hints
├── sites.py # Site discovery (v5.0)
├── keywords_v50.py # SERP analytics (v5.0)
├── genai_v51.py # GenAI visibility (v5.1)
├── brands_v51.py # Brand management (v5.1)
├── chatgpt_compat.py # ChatGPT Deep Research (search/fetch)
├── prompts.py # MCP Prompts (workflow templates)
└── resources.py # MCP Resources (parameter discovery)
Development
# With uv
uv sync --extra dev
uv run pytest
uv run ruff check src/
uv run mcp dev src/demandsphere_mcp/server.py
# With pip
pip install -e ".[dev]"
pytest
ruff check src/
Upgrades
This project uses semantic versioning. To stay up to date:
- Watch releases on GitHub to be notified of new versions
- Pull latest and re-install:
git pull uv sync # or: pip install -e . - See CHANGELOG.md for what changed in each release
License
MIT
Documentation
Additional documentation including API guides, use case examples, and integration walkthroughs is available at the DemandSphere Help Center (login required).
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。