parallel-variable-mcp 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ """Parallel Variable (平行变量) official open-source MCP Server."""
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["__version__"]
@@ -0,0 +1,6 @@
1
+ """CLI entry point for `python -m parallel_variable_mcp`."""
2
+
3
+ from .server import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())
@@ -0,0 +1,271 @@
1
+ """Zero-dependency HTTP client for Parallel Variable Public Open Platform API v1."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import logging
7
+ import os
8
+ import urllib.error
9
+ import urllib.parse
10
+ import urllib.request
11
+ from typing import Any, Callable
12
+
13
+ DEFAULT_BASE_URL = "https://api.parallelvariable.com"
14
+ CONSOLE_URL = "https://parallelvariable.com/console"
15
+ API_PREFIX = "/api/open-platform/v1"
16
+
17
+ logger = logging.getLogger("parallel_variable_mcp")
18
+
19
+ TransportFn = Callable[[str, str, dict[str, str], bytes | None, float], tuple[int, str]]
20
+
21
+
22
+ class ParallelVariableApiError(RuntimeError):
23
+ """Structured error returned by the Parallel Variable public API or client."""
24
+
25
+ def __init__(
26
+ self,
27
+ *,
28
+ status_code: int,
29
+ code: str,
30
+ message: str,
31
+ details: dict[str, Any] | None = None,
32
+ ) -> None:
33
+ super().__init__(message)
34
+ self.status_code = status_code
35
+ self.code = code
36
+ self.message = message
37
+ self.details = details or {}
38
+
39
+ def to_dict(self) -> dict[str, Any]:
40
+ payload: dict[str, Any] = {
41
+ "status_code": self.status_code,
42
+ "code": self.code,
43
+ "message": self.message,
44
+ }
45
+ if self.details:
46
+ payload["details"] = self.details
47
+ return payload
48
+
49
+
50
+ class MissingApiKeyError(ParallelVariableApiError):
51
+ """Raised when PARALLEL_VARIABLE_API_KEY is not configured."""
52
+
53
+ def __init__(self) -> None:
54
+ super().__init__(
55
+ status_code=401,
56
+ code="API_KEY_NOT_CONFIGURED",
57
+ message=(
58
+ "未配置 PARALLEL_VARIABLE_API_KEY 环境变量。"
59
+ f"请前往平行变量开放平台控制台免费领取或管理您的 API Key:{CONSOLE_URL}"
60
+ ),
61
+ details={"console_url": CONSOLE_URL},
62
+ )
63
+
64
+
65
+ def _default_transport(
66
+ method: str,
67
+ url: str,
68
+ headers: dict[str, str],
69
+ body_bytes: bytes | None,
70
+ timeout: float,
71
+ ) -> tuple[int, str]:
72
+ req = urllib.request.Request(url=url, data=body_bytes, headers=headers, method=method)
73
+ try:
74
+ with urllib.request.urlopen(req, timeout=timeout) as resp:
75
+ status = getattr(resp, "status", resp.getcode())
76
+ raw = resp.read().decode("utf-8", errors="replace")
77
+ return int(status), raw
78
+ except urllib.error.HTTPError as exc:
79
+ raw = exc.read().decode("utf-8", errors="replace") if exc.fp else ""
80
+ return int(exc.code), raw
81
+ except urllib.error.URLError as exc:
82
+ raise ParallelVariableApiError(
83
+ status_code=503,
84
+ code="NETWORK_ERROR",
85
+ message=f"无法连接到平行变量开放平台服务,请检查网络或 BASE_URL 配置:{exc.reason}",
86
+ ) from None
87
+ except TimeoutError:
88
+ raise ParallelVariableApiError(
89
+ status_code=504,
90
+ code="REQUEST_TIMEOUT",
91
+ message="请求平行变量开放平台超时,请稍后重试。",
92
+ ) from None
93
+
94
+
95
+ def _redact_secret(text: str, secret: str) -> str:
96
+ if not secret or not text:
97
+ return text
98
+ return text.replace(secret, "[REDACTED]")
99
+
100
+
101
+ def _normalize_base_url(raw: str | None) -> str:
102
+ base = (raw or DEFAULT_BASE_URL).strip().rstrip("/")
103
+ if not base:
104
+ base = DEFAULT_BASE_URL
105
+ parsed = urllib.parse.urlparse(base)
106
+ if parsed.scheme not in {"http", "https"} or not parsed.netloc:
107
+ raise ParallelVariableApiError(
108
+ status_code=400,
109
+ code="INVALID_BASE_URL",
110
+ message="PARALLEL_VARIABLE_BASE_URL 格式非法,必须为有效的 http(s) 地址。",
111
+ )
112
+ return base
113
+
114
+
115
+ class ParallelVariableClient:
116
+ """Black-box public API v1 client. Never logs or exposes API keys."""
117
+
118
+ def __init__(
119
+ self,
120
+ *,
121
+ api_key: str | None = None,
122
+ base_url: str | None = None,
123
+ timeout: float = 30.0,
124
+ transport: TransportFn | None = None,
125
+ ) -> None:
126
+ self._api_key = (
127
+ api_key if api_key is not None else os.environ.get("PARALLEL_VARIABLE_API_KEY", "")
128
+ ).strip()
129
+ self.base_url = _normalize_base_url(
130
+ base_url if base_url is not None else os.environ.get("PARALLEL_VARIABLE_BASE_URL")
131
+ )
132
+ self.timeout = float(timeout)
133
+ self._transport = transport or _default_transport
134
+
135
+ def _require_api_key(self) -> str:
136
+ if not self._api_key:
137
+ raise MissingApiKeyError()
138
+ return self._api_key
139
+
140
+ def request(
141
+ self,
142
+ method: str,
143
+ path: str,
144
+ *,
145
+ query: dict[str, Any] | None = None,
146
+ json_body: dict[str, Any] | None = None,
147
+ ) -> dict[str, Any]:
148
+ api_key = self._require_api_key()
149
+ clean_path = path if path.startswith("/") else "/" + path
150
+ if not clean_path.startswith(API_PREFIX):
151
+ clean_path = API_PREFIX + clean_path
152
+
153
+ url = self.base_url + clean_path
154
+ if query:
155
+ filtered = {k: v for k, v in query.items() if v is not None}
156
+ if filtered:
157
+ url = url + "?" + urllib.parse.urlencode(filtered)
158
+
159
+ headers = {
160
+ "Accept": "application/json",
161
+ "Authorization": f"Bearer {api_key}",
162
+ "User-Agent": "parallel-variable-mcp/0.1.0",
163
+ }
164
+ body_bytes: bytes | None = None
165
+ if json_body is not None:
166
+ headers["Content-Type"] = "application/json; charset=utf-8"
167
+ body_bytes = json.dumps(json_body, ensure_ascii=False).encode("utf-8")
168
+
169
+ logger.debug("pv_api_request method=%s path=%s", method.upper(), clean_path)
170
+ status_code, raw_text = self._transport(method.upper(), url, headers, body_bytes, self.timeout)
171
+ safe_text = _redact_secret(raw_text, api_key)
172
+
173
+ parsed: dict[str, Any] | None = None
174
+ if safe_text:
175
+ try:
176
+ obj = json.loads(safe_text)
177
+ if isinstance(obj, dict):
178
+ parsed = obj
179
+ except json.JSONDecodeError:
180
+ parsed = None
181
+
182
+ if status_code >= 400:
183
+ err_obj = parsed.get("error") if isinstance(parsed, dict) else None
184
+ code = "API_ERROR"
185
+ message = f"请求失败(HTTP {status_code})"
186
+ details: dict[str, Any] = {}
187
+ if isinstance(err_obj, dict):
188
+ code = str(err_obj.get("code") or code)
189
+ message = _redact_secret(str(err_obj.get("message") or message), api_key)
190
+ for k, v in err_obj.items():
191
+ if k not in {"code", "message"}:
192
+ details[k] = v
193
+ if isinstance(parsed, dict) and isinstance(parsed.get("data"), dict):
194
+ details["data"] = parsed["data"]
195
+
196
+ if code in {"INSUFFICIENT_MINIMUM_START_BALANCE", "INSUFFICIENT_BALANCE"}:
197
+ details.setdefault("console_url", CONSOLE_URL)
198
+ message = f"{message} 请前往控制台充值:{CONSOLE_URL}"
199
+ elif code == "POLICY_WHITELIST_REQUIRED":
200
+ details.setdefault("console_url", CONSOLE_URL)
201
+ message = f"{message} 如需开通政企/科研公共政策推演白名单,请联系平行变量开放平台:{CONSOLE_URL}"
202
+ elif code == "UNAUTHENTICATED":
203
+ details.setdefault("console_url", CONSOLE_URL)
204
+ message = f"API Key 无效或已失效,请前往控制台检查或重新生成:{CONSOLE_URL}"
205
+
206
+ logger.warning("pv_api_error method=%s path=%s status=%s code=%s", method.upper(), clean_path, status_code, code)
207
+ raise ParallelVariableApiError(
208
+ status_code=status_code,
209
+ code=code,
210
+ message=message,
211
+ details=details,
212
+ )
213
+
214
+ if parsed is None:
215
+ raise ParallelVariableApiError(
216
+ status_code=502,
217
+ code="INVALID_API_RESPONSE",
218
+ message="开放平台返回了非预期响应格式。",
219
+ )
220
+
221
+ data = parsed.get("data")
222
+ if isinstance(data, dict):
223
+ return data
224
+ return parsed
225
+
226
+ # ------------------------------------------------------------------
227
+ # Public Open Platform v1 Endpoints
228
+ # ------------------------------------------------------------------
229
+ def list_regions(self) -> dict[str, Any]:
230
+ return self.request("GET", "/regions")
231
+
232
+ def get_targeting_options(self) -> dict[str, Any]:
233
+ return self.request("GET", "/targeting/options")
234
+
235
+ def get_account_balance(self) -> dict[str, Any]:
236
+ return self.request("GET", "/account/balance")
237
+
238
+ def get_account_entitlements(self) -> dict[str, Any]:
239
+ return self.request("GET", "/account/entitlements")
240
+
241
+ def clarify_scenario(self, payload: dict[str, Any]) -> dict[str, Any]:
242
+ return self.request("POST", "/scenarios/clarify", json_body=payload)
243
+
244
+ def estimate_population(self, payload: dict[str, Any]) -> dict[str, Any]:
245
+ return self.request("POST", "/populations/plan", json_body=payload)
246
+
247
+ def create_pipeline(self, payload: dict[str, Any]) -> dict[str, Any]:
248
+ return self.request("POST", "/pipelines", json_body=payload)
249
+
250
+ def confirm_population(self, pipeline_id: str) -> dict[str, Any]:
251
+ return self.request("POST", f"/pipelines/{urllib.parse.quote(pipeline_id, safe='')}/confirm-population")
252
+
253
+ def launch_pipeline(self, pipeline_id: str) -> dict[str, Any]:
254
+ return self.request("POST", f"/pipelines/{urllib.parse.quote(pipeline_id, safe='')}/launch")
255
+
256
+ def get_pipeline(self, pipeline_id: str) -> dict[str, Any]:
257
+ return self.request("GET", f"/pipelines/{urllib.parse.quote(pipeline_id, safe='')}")
258
+
259
+ def get_pipeline_observations(
260
+ self,
261
+ pipeline_id: str,
262
+ *,
263
+ day_index: int | None = None,
264
+ limit: int = 100,
265
+ offset: int = 0,
266
+ ) -> dict[str, Any]:
267
+ return self.request(
268
+ "GET",
269
+ f"/pipelines/{urllib.parse.quote(pipeline_id, safe='')}/observations",
270
+ query={"day_index": day_index, "limit": limit, "offset": offset},
271
+ )
@@ -0,0 +1,661 @@
1
+ """Standard MCP (Model Context Protocol) JSON-RPC 2.0 over stdio server for Parallel Variable."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import logging
7
+ import sys
8
+ from typing import Any, BinaryIO, TextIO
9
+
10
+ from . import __version__
11
+ from .client import CONSOLE_URL, ParallelVariableApiError, ParallelVariableClient
12
+
13
+ SERVER_NAME = "parallel-variable-mcp"
14
+ SUPPORTED_PROTOCOL_VERSIONS = ("2025-03-26", "2024-11-05")
15
+
16
+ logger = logging.getLogger("parallel_variable_mcp")
17
+
18
+
19
+ TOOL_DEFINITIONS: list[dict[str, Any]] = [
20
+ {
21
+ "name": "pv_list_regions",
22
+ "description": (
23
+ "查询平行变量(Parallel Variable)开放平台当前已开放的数字居民区域列表"
24
+ "(如 110105 北京朝阳等)。免费调用,不消耗推演点数。"
25
+ ),
26
+ "inputSchema": {
27
+ "type": "object",
28
+ "properties": {},
29
+ "additionalProperties": False,
30
+ },
31
+ },
32
+ {
33
+ "name": "pv_get_targeting_options",
34
+ "description": (
35
+ "查询平行变量开放平台支持的人群定向筛选标准字典(性别 gender、人群标签 audience_tags、"
36
+ "学历 education_levels、婚姻状态 marital_statuses、收入档位 income_bands 及组合规则)。"
37
+ "免费调用,不消耗推演点数。"
38
+ ),
39
+ "inputSchema": {
40
+ "type": "object",
41
+ "properties": {},
42
+ "additionalProperties": False,
43
+ },
44
+ },
45
+ {
46
+ "name": "pv_get_account_status",
47
+ "description": (
48
+ "查询当前平行变量账号的推演点数余额(1 点 = ¥1)、年度点数包、套餐版本(体验版/企业专业版)、"
49
+ "样本上限、并发上限、A/B 对照权限及高敏公共政策推演白名单状态。免费调用。"
50
+ ),
51
+ "inputSchema": {
52
+ "type": "object",
53
+ "properties": {},
54
+ "additionalProperties": False,
55
+ },
56
+ },
57
+ {
58
+ "name": "pv_clarify_scenario",
59
+ "description": (
60
+ "使用平行变量开放平台拆解用户的商业构想、产品定价或社会公共事件推演需求,"
61
+ "返回结构化场景分类(scenario_category)、推荐步进单位与步数(recommended_step_unit/count)、"
62
+ "推荐观测目标(recommended_observation_goals)、推荐最小年龄及是否受 1.0 能力支持。"
63
+ "免费调用,建议在发起推演前优先调用。"
64
+ ),
65
+ "inputSchema": {
66
+ "type": "object",
67
+ "properties": {
68
+ "description": {
69
+ "type": "string",
70
+ "description": "用户的商业/产品/政策/社会事件构想描述(中文或英文)。",
71
+ },
72
+ "region_code": {
73
+ "type": "string",
74
+ "description": "可选,目标区域编码(如 110105)。",
75
+ },
76
+ "answers": {
77
+ "type": "object",
78
+ "description": "可选,补充澄清问答键值对。",
79
+ },
80
+ },
81
+ "required": ["description"],
82
+ "additionalProperties": False,
83
+ },
84
+ },
85
+ {
86
+ "name": "pv_estimate_population",
87
+ "description": (
88
+ "免费实时预估在指定地区与人群筛选条件下覆盖的真实数字居民人数(matched_count)及防窄化提示。"
89
+ "不消耗任何推演点数,建议在确认发起推演前调用。"
90
+ ),
91
+ "inputSchema": {
92
+ "type": "object",
93
+ "properties": {
94
+ "region_code": {
95
+ "type": "string",
96
+ "description": "目标区域编码(如 110105)。",
97
+ },
98
+ "requested_sample_size": {
99
+ "type": "integer",
100
+ "minimum": 1,
101
+ "description": "期望抽样人数,用于判断是否足够满足样本量。",
102
+ },
103
+ "age_min": {"type": "integer", "minimum": 0, "maximum": 120},
104
+ "age_max": {"type": "integer", "minimum": 0, "maximum": 120},
105
+ "gender": {"type": "string", "enum": ["ALL", "MALE", "FEMALE"]},
106
+ "audience_tags": {
107
+ "type": "array",
108
+ "items": {"type": "string", "enum": ["STUDENT", "WORKING_AGE_ADULT", "RETIRED"]},
109
+ },
110
+ "education_levels": {
111
+ "type": "array",
112
+ "items": {"type": "string", "enum": ["HIGH_SCHOOL_OR_BELOW", "COLLEGE", "BACHELOR_OR_ABOVE"]},
113
+ },
114
+ "marital_statuses": {
115
+ "type": "array",
116
+ "items": {"type": "string", "enum": ["SINGLE", "MARRIED", "DIVORCED_OR_WIDOWED"]},
117
+ },
118
+ "income_bands": {
119
+ "type": "array",
120
+ "items": {"type": "string", "enum": ["VERY_LOW", "LOW", "LOWER_MIDDLE", "MIDDLE", "UPPER_MIDDLE", "HIGH"]},
121
+ },
122
+ },
123
+ "required": ["region_code"],
124
+ "additionalProperties": False,
125
+ },
126
+ },
127
+ {
128
+ "name": "pv_run_simulation",
129
+ "description": (
130
+ "【重要:扣费操作,调用前必须先向用户展示本次推演的样本量(sample_size)、"
131
+ "步进单位与步数(step_unit + observation_days)以及预估推演点数消耗,并获得用户明确确认后再调用!】"
132
+ "创建平行变量数字居民推演流水线并立即提交排队启动(内部依次调用 POST /v1/pipelines 与 "
133
+ "POST /v1/pipelines/{id}/launch),立即返回 pipeline_id 与排队信息,不会阻塞等待推演结束。"
134
+ "启动后请使用 pv_get_simulation_results 查询实时进度与居民反馈结果。"
135
+ ),
136
+ "inputSchema": {
137
+ "type": "object",
138
+ "properties": {
139
+ "description": {
140
+ "type": "string",
141
+ "description": "完整的推演方案或事件描述。",
142
+ },
143
+ "region_code": {
144
+ "type": "string",
145
+ "description": "目标区域编码(如 110105)。",
146
+ "default": "110105",
147
+ },
148
+ "sample_size": {
149
+ "type": "integer",
150
+ "minimum": 1,
151
+ "description": "目标抽样数字居民数量。",
152
+ },
153
+ "observation_days": {
154
+ "type": "integer",
155
+ "minimum": 1,
156
+ "maximum": 31,
157
+ "description": "推演总步数(1~31,配合 step_unit 表示天/周/月)。",
158
+ },
159
+ "step_unit": {
160
+ "type": "string",
161
+ "enum": ["DAY", "WEEK", "MONTH"],
162
+ "description": "推演步进单位:DAY(天)、WEEK(周)、MONTH(月)。",
163
+ },
164
+ "scenario_category": {
165
+ "type": "string",
166
+ "description": "可选,由 pv_clarify_scenario 返回的场景类型编码。",
167
+ },
168
+ "observation_goals": {
169
+ "type": "array",
170
+ "items": {"type": "string"},
171
+ "maxItems": 8,
172
+ "description": "可选,最多 8 条中文观测目标。",
173
+ },
174
+ "price_yuan": {
175
+ "type": "number",
176
+ "minimum": 0,
177
+ "description": "可选,商业场景价格(元);非商业社会事件请勿传此字段。",
178
+ },
179
+ "age_min": {"type": "integer", "minimum": 0, "maximum": 120},
180
+ "age_max": {"type": "integer", "minimum": 0, "maximum": 120},
181
+ "gender": {"type": "string", "enum": ["ALL", "MALE", "FEMALE"]},
182
+ "audience_tags": {
183
+ "type": "array",
184
+ "items": {"type": "string", "enum": ["STUDENT", "WORKING_AGE_ADULT", "RETIRED"]},
185
+ },
186
+ "education_levels": {
187
+ "type": "array",
188
+ "items": {"type": "string", "enum": ["HIGH_SCHOOL_OR_BELOW", "COLLEGE", "BACHELOR_OR_ABOVE"]},
189
+ },
190
+ "marital_statuses": {
191
+ "type": "array",
192
+ "items": {"type": "string", "enum": ["SINGLE", "MARRIED", "DIVORCED_OR_WIDOWED"]},
193
+ },
194
+ "income_bands": {
195
+ "type": "array",
196
+ "items": {"type": "string", "enum": ["VERY_LOW", "LOW", "LOWER_MIDDLE", "MIDDLE", "UPPER_MIDDLE", "HIGH"]},
197
+ },
198
+ "auto_confirm_insufficient_population": {
199
+ "type": "boolean",
200
+ "default": False,
201
+ "description": "若命中人群少于 sample_size,是否自动按实际人数确认并继续启动(默认 false)。",
202
+ },
203
+ },
204
+ "required": ["description", "region_code", "sample_size", "observation_days"],
205
+ "additionalProperties": False,
206
+ },
207
+ },
208
+ {
209
+ "name": "pv_get_simulation_results",
210
+ "description": (
211
+ "查询指定推演任务(pipeline_id)的实时进度、账务消耗与观测结果。"
212
+ "支持运行中随时查看进度;完成或有首批观测数据时,自动返回去重统计(unique_resident_summary)、"
213
+ "社会舆情与分龄切片汇总(social_summary)以及精选脱敏数字居民真实原话。"
214
+ ),
215
+ "inputSchema": {
216
+ "type": "object",
217
+ "properties": {
218
+ "pipeline_id": {
219
+ "type": "string",
220
+ "description": "pv_run_simulation 返回的 pipeline_id。",
221
+ },
222
+ "day_index": {
223
+ "type": "integer",
224
+ "minimum": 1,
225
+ "maximum": 31,
226
+ "description": "可选,仅查看指定步进索引的居民观测明细。",
227
+ },
228
+ "quote_limit": {
229
+ "type": "integer",
230
+ "minimum": 1,
231
+ "maximum": 50,
232
+ "default": 10,
233
+ "description": "返回的精选脱敏居民原话条数上限(默认 10)。",
234
+ },
235
+ },
236
+ "required": ["pipeline_id"],
237
+ "additionalProperties": False,
238
+ },
239
+ },
240
+ ]
241
+
242
+
243
+ def _pick_non_none(source: dict[str, Any], keys: tuple[str, ...]) -> dict[str, Any]:
244
+ return {k: source[k] for k in keys if k in source and source[k] is not None}
245
+
246
+
247
+ def _extract_featured_quotes(observations_data: dict[str, Any], quote_limit: int) -> list[dict[str, Any]]:
248
+ raw_items = observations_data.get("items")
249
+ if not isinstance(raw_items, list):
250
+ raw_items = observations_data.get("observations")
251
+ if not isinstance(raw_items, list):
252
+ return []
253
+
254
+ featured: list[dict[str, Any]] = []
255
+ for item in raw_items:
256
+ if not isinstance(item, dict):
257
+ continue
258
+ said = item.get("what_resident_said")
259
+ quotes: list[str] = []
260
+ if isinstance(said, list):
261
+ quotes = [str(s).strip() for s in said if str(s).strip()]
262
+ elif isinstance(said, str) and said.strip():
263
+ quotes = [said.strip()]
264
+ if not quotes:
265
+ continue
266
+ featured.append(
267
+ {
268
+ "day_index": item.get("day_index"),
269
+ "bucket": item.get("bucket"),
270
+ "resident_profile": item.get("resident_profile") or {},
271
+ "what_resident_did": item.get("what_resident_did"),
272
+ "what_resident_said": quotes,
273
+ "social_reaction": item.get("social_reaction"),
274
+ "system_explanation": item.get("system_explanation"),
275
+ }
276
+ )
277
+ if len(featured) >= quote_limit:
278
+ break
279
+ return featured
280
+
281
+
282
+ class ParallelVariableMcpServer:
283
+ """Stateless JSON-RPC 2.0 MCP server wrapping ParallelVariableClient."""
284
+
285
+ def __init__(self, client: ParallelVariableClient | None = None) -> None:
286
+ self.client = client or ParallelVariableClient()
287
+ self.initialized = False
288
+
289
+ def execute_tool(self, name: str, arguments: dict[str, Any] | None) -> dict[str, Any]:
290
+ args = arguments if isinstance(arguments, dict) else {}
291
+
292
+ if name == "pv_list_regions":
293
+ return self.client.list_regions()
294
+
295
+ if name == "pv_get_targeting_options":
296
+ return self.client.get_targeting_options()
297
+
298
+ if name == "pv_get_account_status":
299
+ balance = self.client.get_account_balance()
300
+ entitlements = self.client.get_account_entitlements()
301
+ total_spendable_fen = balance.get("total_spendable_fen", balance.get("available_fen", 0))
302
+ return {
303
+ "points_display": balance.get("points_display") or f"{float(total_spendable_fen) / 100.0:.2f} 点",
304
+ "total_spendable_fen": total_spendable_fen,
305
+ "cash_available_fen": balance.get("cash_available_fen", balance.get("available_fen", 0)),
306
+ "annual_grant_remaining_fen": balance.get("annual_grant_remaining_fen", 0),
307
+ "annual_grant_expires_at": balance.get("annual_grant_expires_at"),
308
+ "min_start_balance_fen": balance.get("min_start_balance_fen", 1000),
309
+ "plan_tier": entitlements.get("plan_tier"),
310
+ "plan_expires_at": entitlements.get("plan_expires_at"),
311
+ "max_sample_size": entitlements.get("max_sample_size"),
312
+ "max_concurrent_pipelines": entitlements.get("max_concurrent_pipelines"),
313
+ "ab_experiment_enabled": entitlements.get("ab_experiment_enabled"),
314
+ "policy_simulation_enabled": entitlements.get("policy_simulation_enabled"),
315
+ "balance": balance,
316
+ "entitlements": entitlements,
317
+ "console_url": CONSOLE_URL,
318
+ }
319
+
320
+ if name == "pv_clarify_scenario":
321
+ desc = str(args.get("description") or "").strip()
322
+ if not desc:
323
+ raise ParallelVariableApiError(
324
+ status_code=422,
325
+ code="INVALID_ARGUMENT",
326
+ message="description 不能为空。",
327
+ )
328
+ payload: dict[str, Any] = {"description": desc}
329
+ if args.get("region_code"):
330
+ payload["region_code"] = str(args["region_code"]).strip()
331
+ if isinstance(args.get("answers"), dict):
332
+ payload["answers"] = args["answers"]
333
+ return self.client.clarify_scenario(payload)
334
+
335
+ if name == "pv_estimate_population":
336
+ region_code = str(args.get("region_code") or "").strip()
337
+ if not region_code:
338
+ raise ParallelVariableApiError(
339
+ status_code=422,
340
+ code="INVALID_ARGUMENT",
341
+ message="region_code 不能为空。",
342
+ )
343
+ payload = _pick_non_none(
344
+ args,
345
+ (
346
+ "region_code",
347
+ "requested_sample_size",
348
+ "age_min",
349
+ "age_max",
350
+ "gender",
351
+ "audience_tags",
352
+ "education_levels",
353
+ "marital_statuses",
354
+ "income_bands",
355
+ ),
356
+ )
357
+ return self.client.estimate_population(payload)
358
+
359
+ if name == "pv_run_simulation":
360
+ desc = str(args.get("description") or "").strip()
361
+ region_code = str(args.get("region_code") or "110105").strip()
362
+ if not desc:
363
+ raise ParallelVariableApiError(
364
+ status_code=422,
365
+ code="INVALID_ARGUMENT",
366
+ message="description 不能为空。",
367
+ )
368
+ payload = _pick_non_none(
369
+ {**args, "description": desc, "region_code": region_code},
370
+ (
371
+ "description",
372
+ "region_code",
373
+ "sample_size",
374
+ "observation_days",
375
+ "step_unit",
376
+ "scenario_category",
377
+ "observation_goals",
378
+ "price_yuan",
379
+ "age_min",
380
+ "age_max",
381
+ "gender",
382
+ "audience_tags",
383
+ "education_levels",
384
+ "marital_statuses",
385
+ "income_bands",
386
+ ),
387
+ )
388
+ created = self.client.create_pipeline(payload)
389
+ pipeline_id = str(created.get("pipeline_id") or "")
390
+ state = str(created.get("state") or "")
391
+
392
+ if state == "PAUSED_INSUFFICIENT_POPULATION" and bool(args.get("auto_confirm_insufficient_population")):
393
+ confirmed = self.client.confirm_population(pipeline_id)
394
+ created = {**created, **confirmed}
395
+ state = str(created.get("state") or "")
396
+
397
+ if state == "SNAPSHOT_READY" and pipeline_id:
398
+ launched = self.client.launch_pipeline(pipeline_id)
399
+ return {
400
+ "pipeline_id": pipeline_id,
401
+ "state": launched.get("state", "QUEUED"),
402
+ "launched": True,
403
+ "region_code": created.get("region_code", region_code),
404
+ "requested_sample_size": created.get("requested_sample_size", args.get("sample_size")),
405
+ "final_sample_size": created.get("final_sample_size", created.get("actual_count")),
406
+ "observation_days": created.get("observation_days", args.get("observation_days")),
407
+ "step_unit": created.get("step_unit", args.get("step_unit", "DAY")),
408
+ "queue": launched.get("queue"),
409
+ "next_step": "推演任务已提交排队,请调用 pv_get_simulation_results(pipeline_id) 查看实时进度与居民反馈。",
410
+ }
411
+
412
+ return {
413
+ "pipeline_id": pipeline_id,
414
+ "state": state,
415
+ "launched": False,
416
+ "matched_count": created.get("matched_count"),
417
+ "actual_count": created.get("actual_count"),
418
+ "requested_sample_size": created.get("requested_sample_size", args.get("sample_size")),
419
+ "details": created,
420
+ "next_step": (
421
+ "命中人数少于目标样本量,未自动启动;可放宽人群条件,或设置 "
422
+ "auto_confirm_insufficient_population=true 按实际人数启动。"
423
+ if state == "PAUSED_INSUFFICIENT_POPULATION"
424
+ else "未匹配到符合条件的数字居民,请调整地区或放宽人群筛选条件。"
425
+ ),
426
+ }
427
+
428
+ if name == "pv_get_simulation_results":
429
+ pipeline_id = str(args.get("pipeline_id") or "").strip()
430
+ if not pipeline_id:
431
+ raise ParallelVariableApiError(
432
+ status_code=422,
433
+ code="INVALID_ARGUMENT",
434
+ message="pipeline_id 不能为空。",
435
+ )
436
+ quote_limit = max(1, min(int(args.get("quote_limit") or 10), 50))
437
+ day_index = args.get("day_index")
438
+
439
+ pipeline = self.client.get_pipeline(pipeline_id)
440
+ observations: dict[str, Any] | None = None
441
+ obs_error: str | None = None
442
+ state = str(pipeline.get("state") or "")
443
+ if state not in {"NO_MATCHED_POPULATION", "PAUSED_INSUFFICIENT_POPULATION", "SNAPSHOT_READY"}:
444
+ try:
445
+ observations = self.client.get_pipeline_observations(
446
+ pipeline_id,
447
+ day_index=int(day_index) if day_index is not None else None,
448
+ limit=max(quote_limit * 5, 100),
449
+ offset=0,
450
+ )
451
+ except ParallelVariableApiError as exc:
452
+ obs_error = exc.code
453
+
454
+ result: dict[str, Any] = {
455
+ "pipeline_id": pipeline_id,
456
+ "state": state,
457
+ "region_code": pipeline.get("region_code"),
458
+ "final_sample_size": pipeline.get("final_sample_size", pipeline.get("actual_count")),
459
+ "observation_days": pipeline.get("observation_days"),
460
+ "completed_days": pipeline.get("completed_days"),
461
+ "step_unit": pipeline.get("step_unit", "DAY"),
462
+ "stage_timings_ms": pipeline.get("stage_timings_ms"),
463
+ "observation_summary": pipeline.get("observation_summary"),
464
+ "billing": pipeline.get("billing"),
465
+ "queue": pipeline.get("queue"),
466
+ "unique_resident_summary": (observations or {}).get("unique_resident_summary"),
467
+ "social_summary": (observations or {}).get("social_summary"),
468
+ "featured_resident_quotes": _extract_featured_quotes(observations or {}, quote_limit),
469
+ }
470
+ if obs_error:
471
+ result["observations_status"] = obs_error
472
+ return result
473
+
474
+ raise ParallelVariableApiError(
475
+ status_code=404,
476
+ code="UNKNOWN_TOOL",
477
+ message=f"未找到名为 {name} 的工具。",
478
+ )
479
+
480
+ def handle_message(self, msg: dict[str, Any]) -> dict[str, Any] | None:
481
+ if not isinstance(msg, dict):
482
+ return {
483
+ "jsonrpc": "2.0",
484
+ "id": None,
485
+ "error": {"code": -32600, "message": "Invalid Request"},
486
+ }
487
+
488
+ method = msg.get("method")
489
+ req_id = msg.get("id")
490
+ params = msg.get("params") if isinstance(msg.get("params"), dict) else {}
491
+
492
+ # Notifications have no id and expect no response
493
+ if method == "notifications/initialized":
494
+ self.initialized = True
495
+ return None
496
+ if isinstance(method, str) and method.startswith("notifications/"):
497
+ return None
498
+
499
+ if method == "initialize":
500
+ client_version = str(params.get("protocolVersion") or "")
501
+ protocol_version = (
502
+ client_version
503
+ if client_version in SUPPORTED_PROTOCOL_VERSIONS
504
+ else SUPPORTED_PROTOCOL_VERSIONS[0]
505
+ )
506
+ return {
507
+ "jsonrpc": "2.0",
508
+ "id": req_id,
509
+ "result": {
510
+ "protocolVersion": protocol_version,
511
+ "capabilities": {
512
+ "tools": {"listChanged": False},
513
+ },
514
+ "serverInfo": {
515
+ "name": SERVER_NAME,
516
+ "version": __version__,
517
+ },
518
+ },
519
+ }
520
+
521
+ if method == "ping":
522
+ return {"jsonrpc": "2.0", "id": req_id, "result": {}}
523
+
524
+ if method == "tools/list":
525
+ return {
526
+ "jsonrpc": "2.0",
527
+ "id": req_id,
528
+ "result": {"tools": TOOL_DEFINITIONS},
529
+ }
530
+
531
+ if method == "tools/call":
532
+ tool_name = str(params.get("name") or "")
533
+ tool_args = params.get("arguments")
534
+ try:
535
+ data = self.execute_tool(tool_name, tool_args)
536
+ return {
537
+ "jsonrpc": "2.0",
538
+ "id": req_id,
539
+ "result": {
540
+ "content": [
541
+ {
542
+ "type": "text",
543
+ "text": json.dumps(data, ensure_ascii=False, indent=2),
544
+ }
545
+ ],
546
+ "isError": False,
547
+ },
548
+ }
549
+ except ParallelVariableApiError as exc:
550
+ return {
551
+ "jsonrpc": "2.0",
552
+ "id": req_id,
553
+ "result": {
554
+ "content": [
555
+ {
556
+ "type": "text",
557
+ "text": json.dumps(exc.to_dict(), ensure_ascii=False, indent=2),
558
+ }
559
+ ],
560
+ "isError": True,
561
+ },
562
+ }
563
+ except Exception:
564
+ logger.exception("pv_mcp_unexpected_tool_error tool=%s", tool_name)
565
+ return {
566
+ "jsonrpc": "2.0",
567
+ "id": req_id,
568
+ "result": {
569
+ "content": [
570
+ {
571
+ "type": "text",
572
+ "text": json.dumps(
573
+ {"code": "INTERNAL_ERROR", "message": "MCP 工具执行发生内部异常。"},
574
+ ensure_ascii=False,
575
+ ),
576
+ }
577
+ ],
578
+ "isError": True,
579
+ },
580
+ }
581
+
582
+ return {
583
+ "jsonrpc": "2.0",
584
+ "id": req_id,
585
+ "error": {"code": -32601, "message": f"Method not found: {method}"},
586
+ }
587
+
588
+ def serve_stdio(
589
+ self,
590
+ stdin: TextIO | BinaryIO | None = None,
591
+ stdout: TextIO | BinaryIO | None = None,
592
+ ) -> int:
593
+ in_stream = stdin if stdin is not None else sys.stdin
594
+ out_stream = stdout if stdout is not None else sys.stdout
595
+ is_binary_out = not hasattr(out_stream, "encoding") or isinstance(out_stream, BinaryIO)
596
+
597
+ def _write_json(payload: dict[str, Any]) -> None:
598
+ line = json.dumps(payload, ensure_ascii=False) + "\n"
599
+ if is_binary_out:
600
+ out_stream.write(line.encode("utf-8")) # type: ignore[arg-type]
601
+ else:
602
+ out_stream.write(line) # type: ignore[arg-type]
603
+ out_stream.flush()
604
+
605
+ while True:
606
+ raw_line = in_stream.readline()
607
+ if not raw_line:
608
+ break
609
+ line_str = raw_line.decode("utf-8", errors="replace") if isinstance(raw_line, bytes) else raw_line
610
+ stripped = line_str.strip()
611
+ if not stripped:
612
+ continue
613
+
614
+ # Support optional Content-Length framing as well as standard NDJSON
615
+ if stripped.lower().startswith("content-length:"):
616
+ try:
617
+ length = int(stripped.split(":", 1)[1].strip())
618
+ except ValueError:
619
+ continue
620
+ while True:
621
+ hdr = in_stream.readline()
622
+ if not hdr:
623
+ return 0
624
+ hdr_str = hdr.decode("utf-8", errors="replace") if isinstance(hdr, bytes) else hdr
625
+ if not hdr_str.strip():
626
+ break
627
+ body_raw = in_stream.read(length)
628
+ body_str = body_raw.decode("utf-8", errors="replace") if isinstance(body_raw, bytes) else body_raw
629
+ else:
630
+ body_str = stripped
631
+
632
+ try:
633
+ msg = json.loads(body_str)
634
+ except json.JSONDecodeError:
635
+ _write_json(
636
+ {
637
+ "jsonrpc": "2.0",
638
+ "id": None,
639
+ "error": {"code": -32700, "message": "Parse error"},
640
+ }
641
+ )
642
+ continue
643
+
644
+ resp = self.handle_message(msg)
645
+ if resp is not None:
646
+ _write_json(resp)
647
+ return 0
648
+
649
+
650
+ def main() -> int:
651
+ logging.basicConfig(
652
+ stream=sys.stderr,
653
+ level=logging.WARNING,
654
+ format="%(asctime)s %(levelname)s %(name)s %(message)s",
655
+ )
656
+ server = ParallelVariableMcpServer()
657
+ return server.serve_stdio()
658
+
659
+
660
+ if __name__ == "__main__":
661
+ raise SystemExit(main())
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: parallel-variable-mcp
3
+ Version: 0.1.0
4
+ Summary: Official MCP Server for Parallel Variable (平行变量) — Let real digital residents respond to your ideas.
5
+ Author-email: Parallel Variable Open Platform <open-platform@parallelvariable.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://parallelvariable.com
8
+ Project-URL: Console, https://parallelvariable.com/console
9
+ Project-URL: Documentation, https://parallelvariable.com/open-platform
10
+ Keywords: mcp,model-context-protocol,parallel-variable,simulation,digital-residents,market-research,policy-simulation
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # 平行变量 Parallel Variable — Official MCP Server
25
+
26
+ > **平行变量(Parallel Variable)— 让世界,回应你的构想。**
27
+ > **Let the real world respond to your ideas before you launch.**
28
+
29
+ `parallel-variable-mcp` 是「平行变量」开放平台官方开源的 **Model Context Protocol (MCP)** 标准服务端(JSON-RPC 2.0 over stdio,**零第三方依赖**,仅需 Python 3.10+)。
30
+
31
+ 通过它,你可以在 **Cursor、Claude Desktop、Antigravity、魔搭(ModelScope)、扣子(Coze)** 等任意支持 MCP 的 AI 客户端中,直接调用真实脱敏城市数字居民样本,在正式发布前对商业定价、门店选址、产品改版、品牌公关或社会公共政策进行低成本高保真前测。
32
+
33
+ - 官网与开放平台:[https://parallelvariable.com](https://parallelvariable.com)
34
+ - 领取 API Key / 管理推演点数:[https://parallelvariable.com/console](https://parallelvariable.com/console)
35
+ - 公开 API 基地址:`https://api.parallelvariable.com`
36
+
37
+ ---
38
+
39
+ ## 核心特性 / Key Features
40
+
41
+ - **零重依赖、开箱即用**:100% Python 标准库实现,无笨重 SDK 依赖,启动即用。
42
+ - **黑盒安全边界**:仅调用公网 `https://api.parallelvariable.com/api/open-platform/v1/*` 公开接口;API Key 仅通过环境变量读取,绝不写入磁盘或打印到日志。
43
+ - **防误扣费护栏**:`pv_run_simulation` 在工具描述中强制约束 AI 助手在扣费启动前,先向用户展示样本量、步进周期与预估点数消耗并获得明确确认。
44
+ - **异步不阻塞**:启动推演后立即返回 `pipeline_id` 与排队位置,随时通过 `pv_get_simulation_results` 拉取进度、去重统计、舆情热搜潜质、分龄切片与脱敏居民真实原话。
45
+
46
+ ---
47
+
48
+ ## 典型场景示例 / Use Cases
49
+
50
+ 1. **商业定价与新店前测**:「在朝阳区开一家精品咖啡店,首杯拿铁 19.9 元,抽 100 位 22–40 岁在职女性测 7 天自然到店与真实评价。」
51
+ 2. **产品改版与会员提价**:「将内容 App 连续包月从 15 元调整至 22 元,对比不同收入与学历人群的续费与吐槽倾向。」
52
+ 3. **品牌公关与社会事件推演**:「某新能源车企因电池续航缩水引发舆论争议,发布不同回应方案后 14 天内的公众态度与热搜潜质变化。」
53
+ 4. **公共政策前测(需政企/科研白名单)**:「博物馆取消预约制 / 地铁高峰票价微调,分青/中/银发三代人群观察支持率与行动意愿。」
54
+
55
+ ---
56
+
57
+ ## 快速安装 / Quick Start
58
+
59
+ ### 方式一:本地可编辑安装(推荐)
60
+ ```bash
61
+ cd integrations/parallel-variable-mcp
62
+ pip install -e .
63
+ ```
64
+ 安装后可直接运行命令 `parallel-variable-mcp`。
65
+
66
+ ### 方式二:零安装直接以模块运行
67
+ ```bash
68
+ PYTHONPATH=integrations/parallel-variable-mcp/src \
69
+ PARALLEL_VARIABLE_API_KEY="pv_sk_your_api_key" \
70
+ python3 -m parallel_variable_mcp
71
+ ```
72
+
73
+ ### 环境变量 / Environment Variables
74
+ | 变量名 | 必填 | 默认值 | 说明 |
75
+ |---|---|---|---|
76
+ | `PARALLEL_VARIABLE_API_KEY` | 是 | 无 | 在 [控制台](https://parallelvariable.com/console) 生成的个人/企业 API Key |
77
+ | `PARALLEL_VARIABLE_BASE_URL` | 否 | `https://api.parallelvariable.com` | 开放平台公开 API 基地址 |
78
+
79
+ ---
80
+
81
+ ## 客户端一键配置 / Client Configuration
82
+
83
+ ### 1. Cursor (`~/.cursor/mcp.json` 或项目 `.cursor/mcp.json`)
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "parallel-variable": {
88
+ "command": "parallel-variable-mcp",
89
+ "env": {
90
+ "PARALLEL_VARIABLE_API_KEY": "pv_sk_your_api_key"
91
+ }
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ### 2. Claude Desktop (`claude_desktop_config.json`)
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "parallel-variable": {
102
+ "command": "python3",
103
+ "args": ["-m", "parallel_variable_mcp"],
104
+ "env": {
105
+ "PARALLEL_VARIABLE_API_KEY": "pv_sk_your_api_key"
106
+ }
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ ### 3. Antigravity / 魔搭(ModelScope)MCP 配置
113
+ ```json
114
+ {
115
+ "mcpServers": {
116
+ "parallel-variable": {
117
+ "command": "parallel-variable-mcp",
118
+ "args": [],
119
+ "env": {
120
+ "PARALLEL_VARIABLE_API_KEY": "pv_sk_your_api_key",
121
+ "PARALLEL_VARIABLE_BASE_URL": "https://api.parallelvariable.com"
122
+ }
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 7 个标准工具清单 / Available MCP Tools
131
+
132
+ | Tool 名称 | 是否免费 | 说明 |
133
+ |---|---|---|
134
+ | `pv_list_regions` | 免费 | 查询已开放的数字居民区域列表(如 `110105` 北京朝阳) |
135
+ | `pv_get_targeting_options` | 免费 | 查询标准人群定向筛选字典(性别、人群标签、学历、婚姻、收入档位) |
136
+ | `pv_get_account_status` | 免费 | 查询当前推演点数余额、年度点数包、套餐版本、样本/并发上限与政策白名单状态 |
137
+ | `pv_clarify_scenario` | 免费 | 拆解商业或社会构想,返回推荐步进单位/步数、观测目标、推荐最小年龄与能力边界 |
138
+ | `pv_estimate_population` | 免费 | 实时预估指定地区与筛选条件下覆盖的居民人数及防窄化提示 |
139
+ | `pv_run_simulation` | **扣费(需确认)** | 创建并启动推演流水线,立即返回 `pipeline_id` 与排队位置(不阻塞超时) |
140
+ | `pv_get_simulation_results` | 免费 | 随时查询推演进度、去重统计、社会舆情/分龄切片汇总及精选脱敏居民真实原话 |
141
+
142
+ ---
143
+
144
+ ## 安全与开源协议 / Security & License
145
+
146
+ - **开源协议**:MIT License(见 [LICENSE](./LICENSE))。
147
+ - **隐私与安全**:本仓库仅作为公网 API 的开源黑盒客户端,不包含任何服务端内部逻辑、模型 Prompt 或私有密钥;所有居民反馈均已在平台侧完成三层脱敏,不包含任何真实个人身份信息(PII)。
@@ -0,0 +1,10 @@
1
+ parallel_variable_mcp/__init__.py,sha256=-uVuQxT_-8IsYh9ac147DUCZcjM6X9tyPwXNU4__UBQ,121
2
+ parallel_variable_mcp/__main__.py,sha256=k-gWU03rIsSM440o-1Uut96ijhdcsgRUbGew_KDkt3Q,144
3
+ parallel_variable_mcp/client.py,sha256=giUUKJzSt45a0B6cW4j1EzNUce7TFKGhXxv91ILlYP0,10137
4
+ parallel_variable_mcp/server.py,sha256=2Qd5lWyB6F_1ZeUJ-crhSoavrzMxLvIXAdKMNPbmKRs,28311
5
+ parallel_variable_mcp-0.1.0.dist-info/licenses/LICENSE,sha256=VsASeSoysmJRMnIo3jcQilHjPKcdsXsDun3Bp3cL0As,1089
6
+ parallel_variable_mcp-0.1.0.dist-info/METADATA,sha256=jJs8V0seBopf44TLgOARN5TO_tRKrI6d_vFU_4dlp40,6757
7
+ parallel_variable_mcp-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ parallel_variable_mcp-0.1.0.dist-info/entry_points.txt,sha256=Fv2rw6ac0B4TXxDiPHLeo0ae-FHHrlRUcBT6MBnUt8k,76
9
+ parallel_variable_mcp-0.1.0.dist-info/top_level.txt,sha256=o4ST9R5sEUWLpy3kGv0-L5nfJtp-OAqDfRJJI7jij7Q,22
10
+ parallel_variable_mcp-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ parallel-variable-mcp = parallel_variable_mcp.server:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Parallel Variable (平行变量)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ parallel_variable_mcp