bea-mcp 1.0.0__tar.gz

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,21 @@
1
+ # macOS
2
+ .DS_Store
3
+ **/.DS_Store
4
+
5
+ # 编辑器
6
+ .vscode/
7
+ .idea/
8
+ *.swp
9
+
10
+ # 临时与备份
11
+ _*_backup/
12
+ *.tmp
13
+ *.log
14
+ __MACOSX/
15
+
16
+ # Python
17
+ __pycache__/
18
+ *.pyc
19
+ *.egg-info/
20
+ dist/
21
+ build/
bea_mcp-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.5
2
+ Name: bea-mcp
3
+ Version: 1.0.0
4
+ Summary: 双极情绪美学(BEA)MCP Server:W(T) 危极指数、A/B 对比、评分卡工具,供所有 MCP 客户端调用
5
+ Project-URL: Homepage, https://github.com/Maxing0000/bipolar-emotion-aesthetics
6
+ Project-URL: Calculator, https://maxing0000.github.io/bipolar-emotion-aesthetics/
7
+ Author: Xingkong Benkong
8
+ License: CC-BY-4.0
9
+ Keywords: aesthetics,agent,bea,design,mcp
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: mcp<2,>=1.2.0
12
+ Description-Content-Type: text/markdown
13
+
14
+ # BEA MCP Server
15
+
16
+ 把**双极情绪美学(BEA)**的计算工具暴露给所有 MCP 客户端(Claude Desktop、Cursor、WorkBuddy 等)。
17
+ 一次安装,你的 AI 助手直接获得「计算 W(T)、A/B 方案对比、评分卡诊断」能力。
18
+
19
+ ## 四个工具
20
+
21
+ | 工具 | 作用 |
22
+ |---|---|
23
+ | `bea_list_categories` | 列出内置品类(phone/car/brand/ui)与维度权重表 |
24
+ | `bea_wt_calc` | 计算危极指数 W(T):范式落点 + 极性画像 + 目标区间对照 |
25
+ | `bea_wt_compare` | A/B 双方案对比:双画像 + 差异维度 + 目标接近度裁决 |
26
+ | `bea_scoresheet` | 评分卡:四维打分(各 25 分)+ 短板定位 + 六步法修复指引 |
27
+
28
+ ## 安装
29
+
30
+ ```bash
31
+ # 方式一:从 GitHub 直接安装(推荐)
32
+ pip install "git+https://github.com/Maxing0000/bipolar-emotion-aesthetics#subdirectory=mcp-server"
33
+
34
+ # 方式二:本地源码
35
+ git clone https://github.com/Maxing0000/bipolar-emotion-aesthetics
36
+ cd bipolar-emotion-aesthetics/mcp-server
37
+ pip install .
38
+ ```
39
+
40
+ 要求 Python ≥ 3.10,唯一依赖是官方 `mcp` SDK。
41
+
42
+ ## 客户端配置
43
+
44
+ **Claude Desktop**(`claude_desktop_config.json`):
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "bea-aesthetics": {
50
+ "command": "python3",
51
+ "args": ["-m", "bea_mcp.server"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ **Cursor / WorkBuddy**(MCP 配置同理,command 用安装环境的 python 绝对路径更稳):
58
+
59
+ ```json
60
+ {
61
+ "mcpServers": {
62
+ "bea-aesthetics": {
63
+ "command": "/path/to/venv/bin/python",
64
+ "args": ["-m", "bea_mcp.server"]
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## 使用示例(对 AI 说)
71
+
72
+ - 「用 BEA 算一下这款手机设计:形状线条 2、质感触觉 4、色彩 6、构图比例 3、光影 3、细节线条 4,目标 0.28」
73
+ - 「A/B 对比两个 LOGO 方案,帮我裁决哪个更接近亲和精致」
74
+ - 「评分卡:张力 20、秩序 22、阈值 23、语境 21,看看有没有短板」
75
+
76
+ ## 说明
77
+
78
+ - 数据表与仓库 `../bipolar-emotion-aesthetics/scripts/` 的 wt_calc.py / scoresheet.py 保持一致(CI 同步校验)
79
+ - 0–10 刻度与 W(T) 为协作参照刻度,非心理物理常数
80
+ - 理论全文见仓库 `../docs/theory-book.html`;交互计算器见 [在线版](https://maxing0000.github.io/bipolar-emotion-aesthetics/)
81
+ - 许可:CC BY 4.0,使用请署名「星空本空 / BEA」
@@ -0,0 +1,68 @@
1
+ # BEA MCP Server
2
+
3
+ 把**双极情绪美学(BEA)**的计算工具暴露给所有 MCP 客户端(Claude Desktop、Cursor、WorkBuddy 等)。
4
+ 一次安装,你的 AI 助手直接获得「计算 W(T)、A/B 方案对比、评分卡诊断」能力。
5
+
6
+ ## 四个工具
7
+
8
+ | 工具 | 作用 |
9
+ |---|---|
10
+ | `bea_list_categories` | 列出内置品类(phone/car/brand/ui)与维度权重表 |
11
+ | `bea_wt_calc` | 计算危极指数 W(T):范式落点 + 极性画像 + 目标区间对照 |
12
+ | `bea_wt_compare` | A/B 双方案对比:双画像 + 差异维度 + 目标接近度裁决 |
13
+ | `bea_scoresheet` | 评分卡:四维打分(各 25 分)+ 短板定位 + 六步法修复指引 |
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ # 方式一:从 GitHub 直接安装(推荐)
19
+ pip install "git+https://github.com/Maxing0000/bipolar-emotion-aesthetics#subdirectory=mcp-server"
20
+
21
+ # 方式二:本地源码
22
+ git clone https://github.com/Maxing0000/bipolar-emotion-aesthetics
23
+ cd bipolar-emotion-aesthetics/mcp-server
24
+ pip install .
25
+ ```
26
+
27
+ 要求 Python ≥ 3.10,唯一依赖是官方 `mcp` SDK。
28
+
29
+ ## 客户端配置
30
+
31
+ **Claude Desktop**(`claude_desktop_config.json`):
32
+
33
+ ```json
34
+ {
35
+ "mcpServers": {
36
+ "bea-aesthetics": {
37
+ "command": "python3",
38
+ "args": ["-m", "bea_mcp.server"]
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ **Cursor / WorkBuddy**(MCP 配置同理,command 用安装环境的 python 绝对路径更稳):
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "bea-aesthetics": {
50
+ "command": "/path/to/venv/bin/python",
51
+ "args": ["-m", "bea_mcp.server"]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ## 使用示例(对 AI 说)
58
+
59
+ - 「用 BEA 算一下这款手机设计:形状线条 2、质感触觉 4、色彩 6、构图比例 3、光影 3、细节线条 4,目标 0.28」
60
+ - 「A/B 对比两个 LOGO 方案,帮我裁决哪个更接近亲和精致」
61
+ - 「评分卡:张力 20、秩序 22、阈值 23、语境 21,看看有没有短板」
62
+
63
+ ## 说明
64
+
65
+ - 数据表与仓库 `../bipolar-emotion-aesthetics/scripts/` 的 wt_calc.py / scoresheet.py 保持一致(CI 同步校验)
66
+ - 0–10 刻度与 W(T) 为协作参照刻度,非心理物理常数
67
+ - 理论全文见仓库 `../docs/theory-book.html`;交互计算器见 [在线版](https://maxing0000.github.io/bipolar-emotion-aesthetics/)
68
+ - 许可:CC BY 4.0,使用请署名「星空本空 / BEA」
@@ -0,0 +1,3 @@
1
+ """BEA MCP Server — 双极情绪美学的 MCP 工具服务。"""
2
+
3
+ __version__ = "1.0.0"
@@ -0,0 +1,229 @@
1
+ #!/usr/bin/env python3
2
+ """BEA MCP Server:把双极情绪美学的计算工具暴露给所有 MCP 客户端。
3
+
4
+ 提供四个工具:
5
+ bea_wt_calc W(T) 危极指数计算:范式落点 + 极性画像 + 目标对照
6
+ bea_wt_compare A/B 双方案对比:双画像 + 差异维度 + 目标接近度裁决
7
+ bea_scoresheet 评分卡:四维打分 + 短板定位 + 六步法修复映射
8
+ bea_list_categories 列出内置品类与维度权重表
9
+
10
+ 数据表与仓库 bipolar-emotion-aesthetics/scripts/ 中的 wt_calc.py、scoresheet.py 保持一致
11
+ (tests/test_mcp_sync.py 做同步校验)。分值为协作刻度,不是心理物理常数。
12
+
13
+ 运行:python -m bea_mcp.server (stdio 传输)
14
+ """
15
+ import json
16
+
17
+ from mcp.server.fastmcp import FastMCP
18
+
19
+ # ---------------------------------------------------------------- 数据表(与 scripts/wt_calc.py 同步)
20
+
21
+ CATEGORY_WEIGHTS = {
22
+ "phone": {"形状线条": 0.25, "质感触觉": 0.25, "色彩": 0.15, "构图比例": 0.15, "光影": 0.10, "细节线条": 0.10},
23
+ "car": {"形体曲面动势": 0.30, "特征线条": 0.25, "灯组图形": 0.15, "比例姿态": 0.15, "材质光影": 0.15},
24
+ "brand": {"图形形状": 0.25, "色彩": 0.25, "字体": 0.20, "版式构图": 0.20, "质感": 0.10},
25
+ "ui": {"布局留白": 0.25, "色彩对比": 0.20, "组件形": 0.20, "动效": 0.20, "字体图标": 0.15},
26
+ }
27
+
28
+ PARADIGM_RANGES = [
29
+ (0.15, "治愈松弛"),
30
+ (0.30, "亲和精致"),
31
+ (0.48, "均衡典雅"),
32
+ (0.60, "崇高震撼(需单元素高强度支撑)"),
33
+ (0.66, "冷峻克制"),
34
+ (0.85, "先锋反叛"),
35
+ (float("inf"), "逼近越阈——非美区"),
36
+ ]
37
+
38
+ DIMENSIONS = ["张力", "秩序", "阈值", "语境"]
39
+ FULL_NAMES = {"张力": "双极张力", "秩序": "结构秩序", "阈值": "阈值安全", "语境": "语境适配"}
40
+ FIX_MAP = {
41
+ "张力": "回第四步「配比与强调」:调整主辅极比例(主导极 60%–90%),检查强调点数量(一视域 ≤2 个);张力过低补危极细节锚点,过高降高权重维度 t 值。",
42
+ "秩序": "回第三步「秩序组织」:叠加五种秩序手段(对称/比例/节奏/层级/呼应),确立至少一条贯穿全局的统一要素(共同色板/栅格/母题)。",
43
+ "阈值": "回第五步「校阈」:本能红线一票否决;认知阈靠补秩序/降复杂度右移;文化阈做符号审计(audit-templates.md 模板 8)。",
44
+ "语境": "回第二步「范式选择」:重做受众三问(阈值/距离时长/第一情绪),检查符号层文化联想与使用场景是否错配。",
45
+ }
46
+
47
+ # ---------------------------------------------------------------- 计算逻辑
48
+
49
+ def paradigm_of(wt: float) -> str:
50
+ for upper, name in PARADIGM_RANGES:
51
+ if wt < upper:
52
+ return name
53
+ return PARADIGM_RANGES[-1][1]
54
+
55
+
56
+ def compute_wt(weights: dict, tvals: dict):
57
+ contribs = {dim: w * tvals[dim] / 10 for dim, w in weights.items()}
58
+ return sum(contribs.values()), contribs
59
+
60
+
61
+ def _profile_block(weights, tvals, label=None):
62
+ total, contribs = compute_wt(weights, tvals)
63
+ lines = []
64
+ if label:
65
+ lines.append(f"—— {label} ——")
66
+ lines.append(f"{'维度':<12}{'权重':>6}{'t':>5}{'贡献':>8} 画像")
67
+ for dim, w in weights.items():
68
+ t = tvals[dim]
69
+ bar = "█" * int(round(t))
70
+ lines.append(f"{dim:<12}{w:>6.2f}{t:>5.1f}{contribs[dim]:>8.3f} T{bar:<10}")
71
+ lines.append("-" * 56)
72
+ lines.append(f"W(T) = {total:.3f} 范式落点:{paradigm_of(total)}")
73
+ return total, lines
74
+
75
+
76
+ def _target_line(total, target):
77
+ diff = total - target
78
+ if abs(diff) <= 0.05:
79
+ return f"对照目标 {target:.2f}:落入区间(±0.05)"
80
+ advise = "减锐增柔(降低高权重维度的 t)" if diff > 0 else "加锐减柔(提高高权重维度的 t)"
81
+ return f"对照目标 {target:.2f}:偏差 {diff:+.3f},建议{advise}"
82
+
83
+
84
+ def _resolve_weights(category, weights):
85
+ if weights:
86
+ w = {k: float(v) for k, v in weights.items()}
87
+ if abs(sum(w.values()) - 1) > 0.001:
88
+ raise ValueError(f"权重合计 {sum(w.values()):.3f} ≠ 1")
89
+ return w
90
+ if category not in CATEGORY_WEIGHTS:
91
+ raise ValueError(f"未知品类 {category!r},可用:{'/'.join(sorted(CATEGORY_WEIGHTS))}(或传 weights 自定义)")
92
+ return CATEGORY_WEIGHTS[category]
93
+
94
+
95
+ def _check_tvals(weights, tvals, label=""):
96
+ missing = [d for d in weights if d not in tvals]
97
+ if missing:
98
+ raise ValueError(f"{label}缺少维度:{'、'.join(missing)}(该品类要求全部维度:{'、'.join(weights)})")
99
+ for k, v in tvals.items():
100
+ if not 0 <= float(v) <= 10:
101
+ raise ValueError(f"{label}维度 {k} 的强度 {v} 超出 0-10")
102
+
103
+
104
+ # ---------------------------------------------------------------- MCP 服务
105
+
106
+ mcp = FastMCP(
107
+ "bea-aesthetics",
108
+ instructions=(
109
+ "双极情绪美学(BEA)计算工具集。BEA 认为美感=可控张力下的情绪奖赏:每个形式元素都在"
110
+ "亲极(柔和安全)与危极(锐利警觉)之间定位,W(T) 是各维度危极强度的品类加权和。"
111
+ "先用 bea_list_categories 查品类维度,再用 bea_wt_calc 计算落点;两方案取舍用 bea_wt_compare;"
112
+ "成稿验收用 bea_scoresheet(四维各 25 分,≥80 成熟,<15 为短板)。"
113
+ "0-10 刻度与 W(T) 为协作参照,非心理物理常数。"
114
+ ),
115
+ )
116
+
117
+
118
+ @mcp.tool()
119
+ def bea_list_categories() -> str:
120
+ """列出 BEA 内置品类及其维度权重表(phone/car/brand/ui),供计算前查询维度名称与权重。"""
121
+ lines = ["可用品类与维度(权重):"]
122
+ for cat, dims in CATEGORY_WEIGHTS.items():
123
+ lines.append(f" {cat}: " + ", ".join(f"{k}={v}" for k, v in dims.items()))
124
+ lines.append("\n范式锚点:0.1 治愈|0.2 亲和精致|0.4 均衡典雅|0.55 崇高|0.62 冷峻|0.7 先锋|>0.85 越阈")
125
+ return "\n".join(lines)
126
+
127
+
128
+ @mcp.tool()
129
+ def bea_wt_calc(category: str, t: dict, target: float = 0.0, weights: dict = None) -> str:
130
+ """计算 BEA 危极指数 W(T):输入品类与各维度危极强度(0-10),输出 W(T)、范式落点、极性画像与目标对照。
131
+
132
+ Args:
133
+ category: 品类,phone/car/brand/ui 之一(自定义权重时随意填)
134
+ t: 各维度危极强度,如 {"形状线条": 2, "质感触觉": 4, "色彩": 2, "构图比例": 3, "光影": 3, "细节线条": 3}
135
+ target: 可选,目标 W(T)(如 0.28),用于对照判定;0 表示不对照
136
+ weights: 可选,自定义权重表(合计须为 1),提供时忽略 category
137
+ """
138
+ try:
139
+ w = _resolve_weights(category, weights)
140
+ tv = {k: float(v) for k, v in t.items()}
141
+ _check_tvals(w, tv)
142
+ except ValueError as e:
143
+ return f"输入错误:{e}"
144
+ total, lines = _profile_block(w, tv)
145
+ if target:
146
+ lines.append(_target_line(total, target))
147
+ return "\n".join(lines)
148
+
149
+
150
+ @mcp.tool()
151
+ def bea_wt_compare(category: str, t_a: dict, t_b: dict, target: float = 0.0, weights: dict = None) -> str:
152
+ """A/B 双方案对比:分别计算 W(T) 与画像,输出差异维度排序与目标接近度裁决。
153
+
154
+ Args:
155
+ category: 品类,phone/car/brand/ui 之一
156
+ t_a: 方案 A 各维度危极强度(0-10)
157
+ t_b: 方案 B 各维度危极强度(0-10)
158
+ target: 可选,目标 W(T);提供时裁决哪个方案更接近目标
159
+ weights: 可选,自定义权重表(合计须为 1)
160
+ """
161
+ try:
162
+ w = _resolve_weights(category, weights)
163
+ ta = {k: float(v) for k, v in t_a.items()}
164
+ tb = {k: float(v) for k, v in t_b.items()}
165
+ _check_tvals(w, ta, "A ")
166
+ _check_tvals(w, tb, "B ")
167
+ except ValueError as e:
168
+ return f"输入错误:{e}"
169
+ total_a, lines = _profile_block(w, ta, "方案 A")
170
+ total_b, lines_b = _profile_block(w, tb, "方案 B")
171
+ lines += [""] + lines_b + ["", "=" * 56]
172
+ lines.append(f"A/B 对比:A={total_a:.3f}({paradigm_of(total_a)}) vs B={total_b:.3f}({paradigm_of(total_b)})")
173
+ diffs = sorted(((d, tb[d] - ta[d]) for d in w), key=lambda x: -abs(x[1]))
174
+ main = [f"{d} {x:+.0f}" for d, x in diffs if abs(x) >= 1]
175
+ if main:
176
+ lines.append("拉开差距的维度:" + "、".join(main))
177
+ sharper, softer = ("B", "A") if total_b > total_a else ("A", "B")
178
+ lines.append(f"解读:{sharper} 更锐(张力更高),{softer} 更柔。")
179
+ if target:
180
+ da, db = abs(total_a - target), abs(total_b - target)
181
+ closer = "A" if da < db else ("B" if db < da else "两者持平")
182
+ lines.append(f"对照目标 {target:.2f}:{closer} 更接近(A 差 {da:.3f},B 差 {db:.3f})。")
183
+ return "\n".join(lines)
184
+
185
+
186
+ @mcp.tool()
187
+ def bea_scoresheet(scores: dict) -> str:
188
+ """BEA 评分卡:四维打分(各 25 分),输出总分、短板定位与六步法修复指引。≥80 成熟,任一维 <15 为短板。
189
+
190
+ Args:
191
+ scores: 四维得分,如 {"张力": 20, "秩序": 22, "阈值": 23, "语境": 21}
192
+ """
193
+ try:
194
+ sc = {k: float(v) for k, v in scores.items()}
195
+ missing = [d for d in DIMENSIONS if d not in sc]
196
+ if missing:
197
+ raise ValueError(f"缺少维度:{'、'.join(missing)}(应为:{'/'.join(DIMENSIONS)})")
198
+ for d in DIMENSIONS:
199
+ if not 0 <= sc[d] <= 25:
200
+ raise ValueError(f"{FULL_NAMES[d]} 得分 {sc[d]} 超出 0-25")
201
+ except (ValueError, AttributeError) as e:
202
+ return f"输入错误:{e}"
203
+
204
+ total = sum(sc[d] for d in DIMENSIONS)
205
+ shorts = [d for d in DIMENSIONS if sc[d] < 15]
206
+ lines = ["BEA 评分卡", "-" * 44]
207
+ for d in DIMENSIONS:
208
+ v = sc[d]
209
+ bar = "█" * int(round(v))
210
+ flag = " ⚠ 短板" if v < 15 else ""
211
+ lines.append(f"{FULL_NAMES[d]:<6}{v:>6.1f}/25 {bar:<25}{flag}")
212
+ lines.append("-" * 44)
213
+ verdict = "成熟作品(≥80)" if total >= 80 else "未成熟(<80)"
214
+ lines.append(f"总分 {total:.1f}/100 {verdict}")
215
+ if shorts:
216
+ lines.append("\n短板修复指引(回六步法对应环节):")
217
+ for d in shorts:
218
+ lines.append(f" · {FULL_NAMES[d]}:{FIX_MAP[d]}")
219
+ else:
220
+ lines.append("无短板维度(均 ≥15)。")
221
+ return "\n".join(lines)
222
+
223
+
224
+ def main():
225
+ mcp.run() # stdio 传输
226
+
227
+
228
+ if __name__ == "__main__":
229
+ main()
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "bea-mcp"
7
+ version = "1.0.0"
8
+ description = "双极情绪美学(BEA)MCP Server:W(T) 危极指数、A/B 对比、评分卡工具,供所有 MCP 客户端调用"
9
+ readme = "README.md"
10
+ license = { text = "CC-BY-4.0" }
11
+ authors = [{ name = "Xingkong Benkong" }]
12
+ requires-python = ">=3.10"
13
+ dependencies = ["mcp>=1.2.0,<2"]
14
+ keywords = ["aesthetics", "design", "mcp", "bea", "agent"]
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/Maxing0000/bipolar-emotion-aesthetics"
18
+ Calculator = "https://maxing0000.github.io/bipolar-emotion-aesthetics/"
19
+
20
+ [project.scripts]
21
+ bea-mcp = "bea_mcp.server:main"
22
+
23
+ [tool.hatch.build.targets.wheel]
24
+ packages = ["bea_mcp"]