Metadata-Version: 2.4
Name: parallel-variable-mcp
Version: 0.1.0
Summary: Official MCP Server for Parallel Variable (平行变量) — Let real digital residents respond to your ideas.
Author-email: Parallel Variable Open Platform <open-platform@parallelvariable.com>
License: MIT
Project-URL: Homepage, https://parallelvariable.com
Project-URL: Console, https://parallelvariable.com/console
Project-URL: Documentation, https://parallelvariable.com/open-platform
Keywords: mcp,model-context-protocol,parallel-variable,simulation,digital-residents,market-research,policy-simulation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 平行变量 Parallel Variable — Official MCP Server

> **平行变量（Parallel Variable）— 让世界，回应你的构想。**  
> **Let the real world respond to your ideas before you launch.**

`parallel-variable-mcp` 是「平行变量」开放平台官方开源的 **Model Context Protocol (MCP)** 标准服务端（JSON-RPC 2.0 over stdio，**零第三方依赖**，仅需 Python 3.10+）。

通过它，你可以在 **Cursor、Claude Desktop、Antigravity、魔搭（ModelScope）、扣子（Coze）** 等任意支持 MCP 的 AI 客户端中，直接调用真实脱敏城市数字居民样本，在正式发布前对商业定价、门店选址、产品改版、品牌公关或社会公共政策进行低成本高保真前测。

- 官网与开放平台：[https://parallelvariable.com](https://parallelvariable.com)
- 领取 API Key / 管理推演点数：[https://parallelvariable.com/console](https://parallelvariable.com/console)
- 公开 API 基地址：`https://api.parallelvariable.com`

---

## 核心特性 / Key Features

- **零重依赖、开箱即用**：100% Python 标准库实现，无笨重 SDK 依赖，启动即用。
- **黑盒安全边界**：仅调用公网 `https://api.parallelvariable.com/api/open-platform/v1/*` 公开接口；API Key 仅通过环境变量读取，绝不写入磁盘或打印到日志。
- **防误扣费护栏**：`pv_run_simulation` 在工具描述中强制约束 AI 助手在扣费启动前，先向用户展示样本量、步进周期与预估点数消耗并获得明确确认。
- **异步不阻塞**：启动推演后立即返回 `pipeline_id` 与排队位置，随时通过 `pv_get_simulation_results` 拉取进度、去重统计、舆情热搜潜质、分龄切片与脱敏居民真实原话。

---

## 典型场景示例 / Use Cases

1. **商业定价与新店前测**：「在朝阳区开一家精品咖啡店，首杯拿铁 19.9 元，抽 100 位 22–40 岁在职女性测 7 天自然到店与真实评价。」
2. **产品改版与会员提价**：「将内容 App 连续包月从 15 元调整至 22 元，对比不同收入与学历人群的续费与吐槽倾向。」
3. **品牌公关与社会事件推演**：「某新能源车企因电池续航缩水引发舆论争议，发布不同回应方案后 14 天内的公众态度与热搜潜质变化。」
4. **公共政策前测（需政企/科研白名单）**：「博物馆取消预约制 / 地铁高峰票价微调，分青/中/银发三代人群观察支持率与行动意愿。」

---

## 快速安装 / Quick Start

### 方式一：本地可编辑安装（推荐）
```bash
cd integrations/parallel-variable-mcp
pip install -e .
```
安装后可直接运行命令 `parallel-variable-mcp`。

### 方式二：零安装直接以模块运行
```bash
PYTHONPATH=integrations/parallel-variable-mcp/src \
PARALLEL_VARIABLE_API_KEY="pv_sk_your_api_key" \
python3 -m parallel_variable_mcp
```

### 环境变量 / Environment Variables
| 变量名 | 必填 | 默认值 | 说明 |
|---|---|---|---|
| `PARALLEL_VARIABLE_API_KEY` | 是 | 无 | 在 [控制台](https://parallelvariable.com/console) 生成的个人/企业 API Key |
| `PARALLEL_VARIABLE_BASE_URL` | 否 | `https://api.parallelvariable.com` | 开放平台公开 API 基地址 |

---

## 客户端一键配置 / Client Configuration

### 1. Cursor (`~/.cursor/mcp.json` 或项目 `.cursor/mcp.json`)
```json
{
  "mcpServers": {
    "parallel-variable": {
      "command": "parallel-variable-mcp",
      "env": {
        "PARALLEL_VARIABLE_API_KEY": "pv_sk_your_api_key"
      }
    }
  }
}
```

### 2. Claude Desktop (`claude_desktop_config.json`)
```json
{
  "mcpServers": {
    "parallel-variable": {
      "command": "python3",
      "args": ["-m", "parallel_variable_mcp"],
      "env": {
        "PARALLEL_VARIABLE_API_KEY": "pv_sk_your_api_key"
      }
    }
  }
}
```

### 3. Antigravity / 魔搭（ModelScope）MCP 配置
```json
{
  "mcpServers": {
    "parallel-variable": {
      "command": "parallel-variable-mcp",
      "args": [],
      "env": {
        "PARALLEL_VARIABLE_API_KEY": "pv_sk_your_api_key",
        "PARALLEL_VARIABLE_BASE_URL": "https://api.parallelvariable.com"
      }
    }
  }
}
```

---

## 7 个标准工具清单 / Available MCP Tools

| Tool 名称 | 是否免费 | 说明 |
|---|---|---|
| `pv_list_regions` | 免费 | 查询已开放的数字居民区域列表（如 `110105` 北京朝阳） |
| `pv_get_targeting_options` | 免费 | 查询标准人群定向筛选字典（性别、人群标签、学历、婚姻、收入档位） |
| `pv_get_account_status` | 免费 | 查询当前推演点数余额、年度点数包、套餐版本、样本/并发上限与政策白名单状态 |
| `pv_clarify_scenario` | 免费 | 拆解商业或社会构想，返回推荐步进单位/步数、观测目标、推荐最小年龄与能力边界 |
| `pv_estimate_population` | 免费 | 实时预估指定地区与筛选条件下覆盖的居民人数及防窄化提示 |
| `pv_run_simulation` | **扣费（需确认）** | 创建并启动推演流水线，立即返回 `pipeline_id` 与排队位置（不阻塞超时） |
| `pv_get_simulation_results` | 免费 | 随时查询推演进度、去重统计、社会舆情/分龄切片汇总及精选脱敏居民真实原话 |

---

## 安全与开源协议 / Security & License

- **开源协议**：MIT License（见 [LICENSE](./LICENSE)）。
- **隐私与安全**：本仓库仅作为公网 API 的开源黑盒客户端，不包含任何服务端内部逻辑、模型 Prompt 或私有密钥；所有居民反馈均已在平台侧完成三层脱敏，不包含任何真实个人身份信息（PII）。
