polish-studio-mcp 0.1.1__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
+ MIT License
2
+
3
+ Copyright (c) 2026 Polish Studio contributors
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,5 @@
1
+ include LICENSE README.md THIRD_PARTY.md
2
+ recursive-include assets *.svg
3
+ recursive-include tests *.py
4
+ include server.json
5
+ recursive-include examples *
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: polish-studio-mcp
3
+ Version: 0.1.1
4
+ Summary: Local deterministic design-token audit and redesign MCP server
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/ahmedsaeed1-eng/polish-studio-mcp
7
+ Project-URL: Issues, https://github.com/ahmedsaeed1-eng/polish-studio-mcp/issues
8
+ Keywords: design-system,accessibility,css,mcp
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: mcp<2,>=1.29
13
+ Requires-Dist: pydantic<3,>=2.7
14
+ Dynamic: license-file
15
+
16
+ <!-- mcp-name: io.github.ahmedsaeed1-eng/polish-studio-mcp -->
17
+
18
+ # Polish Studio MCP
19
+
20
+ ![Polish Studio — visual systems workshop](assets/logo.svg)
21
+
22
+ A local design-token workshop for web developers using coding agents.
23
+
24
+ **Audit the system → propose a direction → adapt the CSS → verify the rendered interface.**
25
+
26
+ ---
27
+
28
+ ## Studio notes / Case 001
29
+
30
+ **Dashboard redesign, illustrative example**
31
+
32
+ ![A token-based dashboard mockup showing a before and proposed visual direction](assets/case-study.svg)
33
+
34
+ The illustration is an original conceptual mockup, not a screenshot or an automatically rendered transformation. The following measurements are reproduced by the included [demo](examples/demo.py) using the actual scoring algorithm.
35
+
36
+ | Design decision | Before | Proposed |
37
+ |---|---:|---:|
38
+ | Body type | 13px | 16px |
39
+ | Primary heading | 18px | 32px |
40
+ | Spacing examples | 5, 10, 15px | 4, 8, 12, 16, 24…64px |
41
+ | Routine motion | 600ms | 180ms |
42
+ | Reduced-motion support | no | yes |
43
+ | Limited token rubric | 56.67 / 100 | 100 / 100 |
44
+
45
+ The proposal prioritizes the text contrast and reduced-motion failures, followed by typography and spacing. A coding agent can adapt these values to an existing project without changing business logic. The rubric is a limited token checklist, not a universal design quality or accessibility score.
46
+
47
+ `v0.1.1` / Python 3.10+ / MCP over stdio / [MIT](LICENSE)
48
+
49
+ [![GitHub stars](https://img.shields.io/github/stars/ahmedsaeed1-eng/polish-studio-mcp?style=flat-square&color=D78B5C)](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/stargazers) ![MCP stdio](https://img.shields.io/badge/transport-MCP%20stdio-252C38?style=flat-square) ![8 tests passed locally](https://img.shields.io/badge/local%20tests-8%20passed-245B42?style=flat-square) [![CI](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/actions/workflows/ci.yml) [![MIT](https://img.shields.io/badge/license-MIT-087f8c?style=flat-square)](LICENSE) ![Runtime offline](https://img.shields.io/badge/runtime-offline-648577?style=flat-square)
50
+
51
+ ## The toolkit
52
+
53
+ A polished interface comes from consistent visual decisions, not arbitrary decoration. Polish Studio is a local Model Context Protocol server that evaluates explicitly provided design tokens and produces actionable design improvements for existing web applications.
54
+
55
+ - **Contrast:** deterministic text and focus contrast ratios with prioritized fixes.
56
+ - **Typography:** role hierarchy, reading size, line height and headline scale.
57
+ - **Rhythm:** spacing, radius consistency, motion duration and content density.
58
+ - **Responsive foundations:** bounded containers and mobile grid reflow.
59
+ - **Design proposals:** 54 distinct combinations of dashboard, landing and e-commerce systems across three densities, three moods and light/dark themes.
60
+ - **CSS:** namespaced design variables, optional components and accessible-motion foundations.
61
+
62
+ No API key, browser, remote site inspection or runtime network access is required. The server only handles explicitly passed structured information. It does not edit projects, execute commands, read arbitrary files or access websites.
63
+
64
+ ## Install the workshop
65
+
66
+ Clone this repository and install from its directory into a virtual environment:
67
+
68
+ ```sh
69
+ python -m venv .venv
70
+ # macOS/Linux: source .venv/bin/activate
71
+ # Windows PowerShell: .venv\Scripts\Activate.ps1
72
+ python -m pip install .
73
+ ```
74
+
75
+ After installation, `polish-studio-mcp`, `polish-studio`, or `python -m polish_studio` starts the stdio server. It waits for an MCP client; it does not expose an HTTP port. Use the absolute path to the environment's Python interpreter in your MCP client, so the client does not depend on shell activation.
76
+
77
+ ### Codex
78
+
79
+ ```sh
80
+ codex mcp add polish-studio -- /absolute/path/to/.venv/bin/python -m polish_studio
81
+ codex mcp list
82
+ ```
83
+
84
+ Or configure `~/.codex/config.toml`:
85
+
86
+ ```toml
87
+ [mcp_servers.polish-studio]
88
+ command = "/absolute/path/to/.venv/bin/python"
89
+ args = ["-m", "polish_studio"]
90
+ ```
91
+
92
+ On Windows substitute e.g. `C:/dev/polish-studio-mcp/.venv/Scripts/python.exe`.
93
+
94
+ ### Claude Code
95
+
96
+ ```sh
97
+ claude mcp add --transport stdio polish-studio -- /absolute/path/to/.venv/bin/python -m polish_studio
98
+ claude mcp list
99
+ ```
100
+
101
+ Use the same Windows interpreter substitution. Reopen the agent session if necessary, then check MCP tool discovery. See [Codex MCP docs](https://developers.openai.com/codex/mcp) and [Claude Code MCP docs](https://code.claude.com/docs/en/mcp). Configuration examples follow the documented syntax; actual Codex/Claude host sessions have not been independently tested. An official SDK client integration test verifies the stdio protocol.
102
+
103
+ ## Working with a coding agent
104
+
105
+ Tell your coding agent:
106
+
107
+ > Review my existing design tokens. Call audit_design using the supplied colors, type sizes, spacing, radius, layout and motion settings. Show high-priority issues first. Use propose_design for a calm, balanced dashboard. Compare both systems and adapt the returned CSS to my current components, preserving behavior. Verify the rendered site at desktop and mobile sizes and with keyboard navigation.
108
+
109
+ The server provides the analysis and proposal only. Your coding agent reviews and applies changes to the actual project within its permissions.
110
+
111
+ ### Tool catalog
112
+
113
+ | Tool | Input | Output |
114
+ |---|---|---|
115
+ | `audit_design` | Design tokens and brief | Weighted rubric, measured contrast ratios, prioritized actions |
116
+ | `propose_design` | Brief | Complete tokens, rubric, CSS, integration checklist |
117
+ | `generate_css` | Design tokens | Namespaced CSS; optional grid, focus, shadow and motion classes |
118
+
119
+ Brief structure:
120
+
121
+ ```json
122
+ {"brief":{"kind":"dashboard","density":"balanced","mood":"calm","theme":"light"}}
123
+ ```
124
+
125
+ Accepted kinds: `dashboard`, `landing`, `ecommerce`. Densities: `compact`, `balanced`, `airy`. Moods: `calm`, `bold`, `warm`. Themes: `light`, `dark`.
126
+
127
+ Example audit input:
128
+
129
+ ```json
130
+ {
131
+ "brief": {"kind":"dashboard","density":"balanced","mood":"calm","theme":"light"},
132
+ "tokens": {
133
+ "background":"#f6f8fb", "surface":"#ffffff", "text":"#17212f",
134
+ "muted":"#475569", "accent":"#2649b5", "on_accent":"#ffffff", "focus":"#2649b5",
135
+ "fonts":{"caption":12,"body":16,"h3":20,"h2":25,"h1":32},
136
+ "spacing":[4,8,12,16,24,32,48,64], "radius":[4,8,12],
137
+ "motion_ms":180,"reduced_motion":true,"line_height":1.6,
138
+ "columns":4,"mobile_columns":1,"content_width":1440,
139
+ "body_font":"system","heading_font":"system"
140
+ }
141
+ }
142
+ ```
143
+
144
+ Colors must be six-digit hex values. Sizes, columns and scales are bounded numbers; fonts are predefined family roles. Raw CSS is not accepted.
145
+
146
+ ## Reading the measurements
147
+
148
+ | Category | Maximum points |
149
+ |---|---:|
150
+ | Text and focus contrast | 35 |
151
+ | Typography | 20 |
152
+ | Spacing | 15 |
153
+ | Shape | 10 |
154
+ | Motion | 10 |
155
+ | Layout | 10 |
156
+
157
+ Category points equal its weight multiplied by the fraction of checks passed. Actions are sorted by explicit priority, then category and stable identifier. The normal text target is 4.5:1; the focus token target against background and surface is 3:1. Other thresholds are documented project heuristics.
158
+
159
+ **100 rubric points means the supplied values satisfy this limited checklist.** It does not mean a site is fully professional, accessible or certified. Rendered contrast over imagery, target sizes, keyboard order, semantic markup, actual font rendering, actual component state colors, browser zoom, responsive wrapping and actual reduced-motion behavior require separate review.
160
+
161
+ ## Reproduce and test
162
+
163
+ ```sh
164
+ python -m unittest discover -s tests -v
165
+ python examples/demo.py
166
+ ```
167
+
168
+ Tests include reference contrast ratios, every preset combination, priority ordering, input rejection, responsive CSS and a live stdio round-trip for all three tools. CI is configured for Linux and Windows with Python 3.10/3.12. No platform-specific claims are made until CI runs.
169
+
170
+ ## License
171
+
172
+ MIT. See [LICENSE](LICENSE) and [third-party acknowledgments](THIRD_PARTY.md).
@@ -0,0 +1,157 @@
1
+ <!-- mcp-name: io.github.ahmedsaeed1-eng/polish-studio-mcp -->
2
+
3
+ # Polish Studio MCP
4
+
5
+ ![Polish Studio — visual systems workshop](assets/logo.svg)
6
+
7
+ A local design-token workshop for web developers using coding agents.
8
+
9
+ **Audit the system → propose a direction → adapt the CSS → verify the rendered interface.**
10
+
11
+ ---
12
+
13
+ ## Studio notes / Case 001
14
+
15
+ **Dashboard redesign, illustrative example**
16
+
17
+ ![A token-based dashboard mockup showing a before and proposed visual direction](assets/case-study.svg)
18
+
19
+ The illustration is an original conceptual mockup, not a screenshot or an automatically rendered transformation. The following measurements are reproduced by the included [demo](examples/demo.py) using the actual scoring algorithm.
20
+
21
+ | Design decision | Before | Proposed |
22
+ |---|---:|---:|
23
+ | Body type | 13px | 16px |
24
+ | Primary heading | 18px | 32px |
25
+ | Spacing examples | 5, 10, 15px | 4, 8, 12, 16, 24…64px |
26
+ | Routine motion | 600ms | 180ms |
27
+ | Reduced-motion support | no | yes |
28
+ | Limited token rubric | 56.67 / 100 | 100 / 100 |
29
+
30
+ The proposal prioritizes the text contrast and reduced-motion failures, followed by typography and spacing. A coding agent can adapt these values to an existing project without changing business logic. The rubric is a limited token checklist, not a universal design quality or accessibility score.
31
+
32
+ `v0.1.1` / Python 3.10+ / MCP over stdio / [MIT](LICENSE)
33
+
34
+ [![GitHub stars](https://img.shields.io/github/stars/ahmedsaeed1-eng/polish-studio-mcp?style=flat-square&color=D78B5C)](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/stargazers) ![MCP stdio](https://img.shields.io/badge/transport-MCP%20stdio-252C38?style=flat-square) ![8 tests passed locally](https://img.shields.io/badge/local%20tests-8%20passed-245B42?style=flat-square) [![CI](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/actions/workflows/ci.yml) [![MIT](https://img.shields.io/badge/license-MIT-087f8c?style=flat-square)](LICENSE) ![Runtime offline](https://img.shields.io/badge/runtime-offline-648577?style=flat-square)
35
+
36
+ ## The toolkit
37
+
38
+ A polished interface comes from consistent visual decisions, not arbitrary decoration. Polish Studio is a local Model Context Protocol server that evaluates explicitly provided design tokens and produces actionable design improvements for existing web applications.
39
+
40
+ - **Contrast:** deterministic text and focus contrast ratios with prioritized fixes.
41
+ - **Typography:** role hierarchy, reading size, line height and headline scale.
42
+ - **Rhythm:** spacing, radius consistency, motion duration and content density.
43
+ - **Responsive foundations:** bounded containers and mobile grid reflow.
44
+ - **Design proposals:** 54 distinct combinations of dashboard, landing and e-commerce systems across three densities, three moods and light/dark themes.
45
+ - **CSS:** namespaced design variables, optional components and accessible-motion foundations.
46
+
47
+ No API key, browser, remote site inspection or runtime network access is required. The server only handles explicitly passed structured information. It does not edit projects, execute commands, read arbitrary files or access websites.
48
+
49
+ ## Install the workshop
50
+
51
+ Clone this repository and install from its directory into a virtual environment:
52
+
53
+ ```sh
54
+ python -m venv .venv
55
+ # macOS/Linux: source .venv/bin/activate
56
+ # Windows PowerShell: .venv\Scripts\Activate.ps1
57
+ python -m pip install .
58
+ ```
59
+
60
+ After installation, `polish-studio-mcp`, `polish-studio`, or `python -m polish_studio` starts the stdio server. It waits for an MCP client; it does not expose an HTTP port. Use the absolute path to the environment's Python interpreter in your MCP client, so the client does not depend on shell activation.
61
+
62
+ ### Codex
63
+
64
+ ```sh
65
+ codex mcp add polish-studio -- /absolute/path/to/.venv/bin/python -m polish_studio
66
+ codex mcp list
67
+ ```
68
+
69
+ Or configure `~/.codex/config.toml`:
70
+
71
+ ```toml
72
+ [mcp_servers.polish-studio]
73
+ command = "/absolute/path/to/.venv/bin/python"
74
+ args = ["-m", "polish_studio"]
75
+ ```
76
+
77
+ On Windows substitute e.g. `C:/dev/polish-studio-mcp/.venv/Scripts/python.exe`.
78
+
79
+ ### Claude Code
80
+
81
+ ```sh
82
+ claude mcp add --transport stdio polish-studio -- /absolute/path/to/.venv/bin/python -m polish_studio
83
+ claude mcp list
84
+ ```
85
+
86
+ Use the same Windows interpreter substitution. Reopen the agent session if necessary, then check MCP tool discovery. See [Codex MCP docs](https://developers.openai.com/codex/mcp) and [Claude Code MCP docs](https://code.claude.com/docs/en/mcp). Configuration examples follow the documented syntax; actual Codex/Claude host sessions have not been independently tested. An official SDK client integration test verifies the stdio protocol.
87
+
88
+ ## Working with a coding agent
89
+
90
+ Tell your coding agent:
91
+
92
+ > Review my existing design tokens. Call audit_design using the supplied colors, type sizes, spacing, radius, layout and motion settings. Show high-priority issues first. Use propose_design for a calm, balanced dashboard. Compare both systems and adapt the returned CSS to my current components, preserving behavior. Verify the rendered site at desktop and mobile sizes and with keyboard navigation.
93
+
94
+ The server provides the analysis and proposal only. Your coding agent reviews and applies changes to the actual project within its permissions.
95
+
96
+ ### Tool catalog
97
+
98
+ | Tool | Input | Output |
99
+ |---|---|---|
100
+ | `audit_design` | Design tokens and brief | Weighted rubric, measured contrast ratios, prioritized actions |
101
+ | `propose_design` | Brief | Complete tokens, rubric, CSS, integration checklist |
102
+ | `generate_css` | Design tokens | Namespaced CSS; optional grid, focus, shadow and motion classes |
103
+
104
+ Brief structure:
105
+
106
+ ```json
107
+ {"brief":{"kind":"dashboard","density":"balanced","mood":"calm","theme":"light"}}
108
+ ```
109
+
110
+ Accepted kinds: `dashboard`, `landing`, `ecommerce`. Densities: `compact`, `balanced`, `airy`. Moods: `calm`, `bold`, `warm`. Themes: `light`, `dark`.
111
+
112
+ Example audit input:
113
+
114
+ ```json
115
+ {
116
+ "brief": {"kind":"dashboard","density":"balanced","mood":"calm","theme":"light"},
117
+ "tokens": {
118
+ "background":"#f6f8fb", "surface":"#ffffff", "text":"#17212f",
119
+ "muted":"#475569", "accent":"#2649b5", "on_accent":"#ffffff", "focus":"#2649b5",
120
+ "fonts":{"caption":12,"body":16,"h3":20,"h2":25,"h1":32},
121
+ "spacing":[4,8,12,16,24,32,48,64], "radius":[4,8,12],
122
+ "motion_ms":180,"reduced_motion":true,"line_height":1.6,
123
+ "columns":4,"mobile_columns":1,"content_width":1440,
124
+ "body_font":"system","heading_font":"system"
125
+ }
126
+ }
127
+ ```
128
+
129
+ Colors must be six-digit hex values. Sizes, columns and scales are bounded numbers; fonts are predefined family roles. Raw CSS is not accepted.
130
+
131
+ ## Reading the measurements
132
+
133
+ | Category | Maximum points |
134
+ |---|---:|
135
+ | Text and focus contrast | 35 |
136
+ | Typography | 20 |
137
+ | Spacing | 15 |
138
+ | Shape | 10 |
139
+ | Motion | 10 |
140
+ | Layout | 10 |
141
+
142
+ Category points equal its weight multiplied by the fraction of checks passed. Actions are sorted by explicit priority, then category and stable identifier. The normal text target is 4.5:1; the focus token target against background and surface is 3:1. Other thresholds are documented project heuristics.
143
+
144
+ **100 rubric points means the supplied values satisfy this limited checklist.** It does not mean a site is fully professional, accessible or certified. Rendered contrast over imagery, target sizes, keyboard order, semantic markup, actual font rendering, actual component state colors, browser zoom, responsive wrapping and actual reduced-motion behavior require separate review.
145
+
146
+ ## Reproduce and test
147
+
148
+ ```sh
149
+ python -m unittest discover -s tests -v
150
+ python examples/demo.py
151
+ ```
152
+
153
+ Tests include reference contrast ratios, every preset combination, priority ordering, input rejection, responsive CSS and a live stdio round-trip for all three tools. CI is configured for Linux and Windows with Python 3.10/3.12. No platform-specific claims are made until CI runs.
154
+
155
+ ## License
156
+
157
+ MIT. See [LICENSE](LICENSE) and [third-party acknowledgments](THIRD_PARTY.md).
@@ -0,0 +1,7 @@
1
+ # Third-party references
2
+
3
+ Polish Studio uses the official [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) (MIT) and [Pydantic](https://github.com/pydantic/pydantic) (MIT). These are installed as dependencies; their sources are not bundled here.
4
+
5
+ Contrast uses the relative luminance and contrast ratio formulas defined by the [W3C WCAG 2.2 specification](https://www.w3.org/TR/WCAG22/#dfn-contrast-ratio). Typography, spacing, motion, radius and density thresholds are project-specific design heuristics, not accessibility standards.
6
+
7
+ All project source, preset palettes and SVG brand artwork are original to this repository.
@@ -0,0 +1,46 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 510" role="img" aria-labelledby="title desc">
2
+ <title id="title">Polish Studio sample visual design comparison</title>
3
+ <desc id="desc">An illustrative dashboard mockup, with demo rubric scores of 56.67 before and 100 after. These are token scores, not a rendered audit.</desc>
4
+ <rect width="1000" height="510" rx="16" fill="#EBE7DD"/>
5
+ <g font-family="system-ui,sans-serif">
6
+ <text x="32" y="36" font-size="12" letter-spacing="2" fill="#475569">STUDIO NOTES / 001 — ILLUSTRATIVE DASHBOARD</text>
7
+ <g transform="translate(28 65)">
8
+ <text x="0" y="0" font-size="17" font-weight="700" fill="#17212f">BEFORE</text>
9
+ <text x="0" y="30" font-size="15" fill="#475569">56.67 / 100 token rubric</text>
10
+ <rect y="50" width="454" height="300" rx="6" fill="#f6f8fb" stroke="#cbd5e1"/>
11
+ <rect x="12" y="63" width="430" height="42" fill="#ffffff"/>
12
+ <text x="20" y="89" font-size="18" fill="#8899aa">Overview</text>
13
+ <rect x="17" y="116" width="420" height="76" rx="2" fill="#fff"/>
14
+ <text x="26" y="134" font-size="10" fill="#8899aa">Monthly activity</text>
15
+ <text x="26" y="159" font-size="18" fill="#8899aa">12,580</text>
16
+ <text x="26" y="176" font-size="13" fill="#8899aa">Visits</text>
17
+ <rect x="17" y="202" width="420" height="142" fill="#fff"/>
18
+ <text x="26" y="223" font-size="16" fill="#8899aa">Recent activity</text>
19
+ <path d="M29 246h396M29 273h396M29 300h396M29 328h396" stroke="#e2e8f0"/>
20
+ <text x="26" y="261" font-size="13" fill="#8899aa">Page views</text>
21
+ <text x="26" y="288" font-size="13" fill="#8899aa">Conversion</text>
22
+ <text x="26" y="315" font-size="13" fill="#8899aa">Orders</text>
23
+ <text x="0" y="379" fill="#80351f" font-size="14">LOW CONTRAST · TIGHT SPACING</text>
24
+ <text x="0" y="402" fill="#475569" font-size="12">13px body · 18px H1 · 600ms motion</text>
25
+ </g>
26
+ <g transform="translate(518 65)">
27
+ <text x="0" y="0" font-size="17" font-weight="700" fill="#17212f">PROPOSED</text>
28
+ <text x="0" y="30" font-size="15" fill="#475569">100 / 100 limited token rubric</text>
29
+ <rect y="50" width="454" height="300" rx="6" fill="#f6f8fb" stroke="#cbd5e1"/>
30
+ <text x="20" y="93" font-size="32" font-weight="700" fill="#17212f">Overview</text>
31
+ <rect x="20" y="121" width="414" height="96" rx="12" fill="#dce3ee"/><rect x="20" y="118" width="414" height="96" rx="12" fill="#fff" stroke="#e2e8f0"/>
32
+ <text x="36" y="140" font-size="12" fill="#475569">MONTHLY ACTIVITY</text>
33
+ <text x="36" y="174" font-size="32" font-weight="700" fill="#17212f">12,580</text>
34
+ <text x="36" y="198" font-size="16" fill="#475569">Visits</text>
35
+ <rect x="301" y="153" width="115" height="40" rx="8" fill="#2649b5"/>
36
+ <text x="358" y="179" font-size="14" fill="#fff" font-weight="600" text-anchor="middle">View report</text>
37
+ <rect x="20" y="232" width="414" height="103" rx="12" fill="#dce3ee"/><rect x="20" y="229" width="414" height="103" rx="12" fill="#fff" stroke="#e2e8f0"/>
38
+ <text x="36" y="258" font-size="20" fill="#17212f" font-weight="700">Recent activity</text>
39
+ <path d="M36 273h382" stroke="#e2e8f0"/>
40
+ <text x="36" y="304" font-size="16" fill="#17212f">Page views</text>
41
+ <text x="418" y="304" font-size="16" fill="#2649b5" text-anchor="end">12,580</text>
42
+ <text x="0" y="379" fill="#245B42" font-size="14">STRONGER HIERARCHY · CALMER RHYTHM</text>
43
+ <text x="0" y="402" fill="#475569" font-size="12">16px body · 32px H1 · 180ms motion</text>
44
+ </g>
45
+ </g>
46
+ </svg>
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 820 230" role="img" aria-labelledby="title">
2
+ <title id="title">Polish Studio MCP - visual systems workshop</title>
3
+ <rect width="820" height="230" rx="14" fill="#F6F3EB"/>
4
+ <g transform="translate(50 33)">
5
+ <rect width="164" height="164" rx="5" fill="#252C38"/>
6
+ <path d="M28 128V34h61c25 0 44 17 44 43 0 25-19 42-44 42H55v9" fill="none" stroke="#F6F3EB" stroke-width="19" stroke-linejoin="miter"/>
7
+ <path d="M89 59a18 18 0 1 1 0 36" fill="none" stroke="#D78B5C" stroke-width="7"/>
8
+ <rect x="136" y="20" width="9" height="9" fill="#D78B5C"/>
9
+ </g>
10
+ <g fill="#252C38">
11
+ <text x="248" y="91" font-family="Georgia,serif" font-size="57">Polish Studio.</text>
12
+ <text x="252" y="136" font-family="system-ui,sans-serif" font-size="19" letter-spacing="2">MCP / VISUAL SYSTEMS WORKSHOP</text>
13
+ <path d="M252 158h505" stroke="#C9BCA9"/>
14
+ <text x="252" y="190" font-family="system-ui,sans-serif" font-size="15" letter-spacing="1">AUDIT • DESIGN • REFINE</text>
15
+ </g>
16
+ </svg>
@@ -0,0 +1,12 @@
1
+ """Run a deterministic before/after token review without an MCP host."""
2
+ from polish_studio.design import Brief, Tokens, audit, propose
3
+
4
+ brief = Brief(kind="dashboard", mood="calm")
5
+ before = propose(brief).model_dump()
6
+ before.update(text="#8899aa", spacing=[5, 10, 15], motion_ms=600, reduced_motion=False)
7
+ before["fonts"] = {"caption":10,"body":13,"h3":16,"h2":17,"h1":18}
8
+ report = audit(Tokens(**before), brief)
9
+ print("Before:", report["score"], "/ 100 rubric points")
10
+ for item in report["actions"]:
11
+ print(f'{item["priority"]:6} {item["id"]}: {item["action"]}')
12
+ print("Proposed:", audit(propose(brief), brief)["score"], "/ 100 rubric points")
@@ -0,0 +1,2 @@
1
+ """Polish Studio MCP."""
2
+ __version__ = "0.1.1"
@@ -0,0 +1,4 @@
1
+ from .server import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,216 @@
1
+ """Pure, deterministic design-token checks and proposal generation."""
2
+ from typing import Literal
3
+ from math import isfinite
4
+
5
+ from pydantic import BaseModel, Field, ConfigDict, field_validator
6
+
7
+ Hex = str
8
+ Kind = Literal["dashboard", "landing", "ecommerce"]
9
+ Role = Literal["caption", "body", "h3", "h2", "h1"]
10
+ Priority = Literal["high", "medium", "low"]
11
+ WEIGHTS = {"contrast": 35, "type": 20, "spacing": 15, "shape": 10,
12
+ "motion": 10, "layout": 10}
13
+ ROLE_ORDER = ("caption", "body", "h3", "h2", "h1")
14
+
15
+
16
+ class StrictModel(BaseModel):
17
+ model_config = ConfigDict(extra="forbid", allow_inf_nan=False)
18
+
19
+
20
+ class Brief(StrictModel):
21
+ kind: Kind = "dashboard"
22
+ density: Literal["compact", "balanced", "airy"] = "balanced"
23
+ mood: Literal["calm", "bold", "warm"] = "calm"
24
+ theme: Literal["light", "dark"] = "light"
25
+
26
+
27
+ class Tokens(StrictModel):
28
+ background: Hex
29
+ surface: Hex
30
+ text: Hex
31
+ muted: Hex
32
+ accent: Hex
33
+ on_accent: Hex
34
+ fonts: dict[Role, float]
35
+ spacing: list[float] = Field(min_length=1, max_length=12)
36
+ radius: list[float] = Field(min_length=1, max_length=8)
37
+ motion_ms: float = Field(ge=0, le=3000)
38
+ reduced_motion: bool
39
+ line_height: float = Field(ge=0.5, le=4)
40
+ columns: int = Field(ge=1, le=16)
41
+ mobile_columns: int = Field(ge=1, le=16)
42
+ content_width: int = Field(ge=240, le=2400)
43
+ body_font: Literal["system", "serif", "mono"] = "system"
44
+ heading_font: Literal["system", "serif", "mono"] = "system"
45
+ focus: Hex
46
+
47
+ @field_validator("background", "surface", "text", "muted", "accent", "on_accent", "focus")
48
+ @classmethod
49
+ def color(cls, value: str) -> str:
50
+ if len(value) != 7 or value[0] != "#" or not all(c in "0123456789abcdefABCDEF" for c in value[1:]):
51
+ raise ValueError("Use #RRGGBB hex colors only")
52
+ return value.lower()
53
+
54
+ @field_validator("fonts")
55
+ @classmethod
56
+ def type_sizes(cls, value):
57
+ if set(value) != set(ROLE_ORDER):
58
+ raise ValueError("Provide every role: caption, body, h3, h2, h1")
59
+ if not all(isfinite(n) and 8 <= n <= 128 for n in value.values()):
60
+ raise ValueError("Font sizes must be between 8 and 128 pixels")
61
+ return value
62
+
63
+ @field_validator("spacing", "radius")
64
+ @classmethod
65
+ def scales(cls, value):
66
+ if not all(isfinite(n) and 0 <= n <= 256 for n in value):
67
+ raise ValueError("Scale values must be between 0 and 256 pixels")
68
+ return value
69
+
70
+
71
+ def luminance(h: str) -> float:
72
+ rgb = [int(h[i:i+2], 16)/255 for i in (1, 3, 5)]
73
+ linear = [v/12.92 if v <= .04045 else ((v+.055)/1.055)**2.4 for v in rgb]
74
+ return sum(x*y for x, y in zip(linear, (.2126, .7152, .0722)))
75
+
76
+
77
+ def contrast(a: str, b: str) -> float:
78
+ high, low = sorted((luminance(a), luminance(b)), reverse=True)
79
+ return (high + .05) / (low + .05)
80
+
81
+
82
+ def audit(tokens: Tokens, brief: Brief) -> dict:
83
+ tokens = Tokens.model_validate(tokens.model_dump())
84
+ brief = Brief.model_validate(brief.model_dump())
85
+ issues = []
86
+ checks = {k: [] for k in WEIGHTS}
87
+ def check(group, key, good, priority, detail, action):
88
+ checks[group].append(bool(good))
89
+ if not good:
90
+ issues.append(dict(group=group, id=key, priority=priority, evidence=detail, action=action))
91
+
92
+ ratios = {}
93
+ for fg, bg in (("text","background"), ("text","surface"), ("muted","background"),
94
+ ("muted","surface"), ("on_accent","accent"), ("focus","background"),
95
+ ("focus","surface")):
96
+ ratio = contrast(getattr(tokens,fg), getattr(tokens,bg))
97
+ threshold = 3 if fg == "focus" else 4.5
98
+ key=f"{fg}_on_{bg}"
99
+ ratios[key]=round(ratio, 3)
100
+ check("contrast",key,ratio >= threshold,"high",f"{ratio:.3f}:1; target {threshold}:1",
101
+ f"Adjust {fg} or {bg} to reach {threshold}:1 for the intended role.")
102
+
103
+ f = tokens.fonts
104
+ check("type","body_min", f["body"] >= 16,"medium",f"Body {f['body']}px",
105
+ "Use at least 16px body text as a comfortable baseline.")
106
+ check("type","caption_min",f["caption"] >= 12,"medium",f"Caption {f['caption']}px",
107
+ "Keep secondary text at 12px or above; check actual legibility.")
108
+ check("type","role_order",all(a<b for a,b in zip([f[r] for r in ROLE_ORDER[:-1]], [f[r] for r in ROLE_ORDER[1:]])),
109
+ "medium",str({role: f[role] for role in ROLE_ORDER}),"Use a strictly ascending caption/body/h3/h2/h1 scale.")
110
+ check("type","headline_ratio",1.6 <= f["h1"]/f["body"] <= 4.5,"medium",
111
+ f"H1/body={f['h1']/f['body']:.2f}","Use H1 about 1.6–4.5 times body, based on the page purpose.")
112
+ check("type","line_height",1.4 <= tokens.line_height <= 1.8,"medium",
113
+ f"Body line height {tokens.line_height}","Use body line-height around 1.4–1.8.")
114
+ check("type","reading_role", tokens.body_font != "mono","low",f"Body font {tokens.body_font}",
115
+ "Reserve monospaced fonts for code and numeric data; choose system or serif for prose.")
116
+ s=tokens.spacing
117
+ check("spacing","rhythm",all(x%4==0 for x in s),"medium",f"Scale {s}",
118
+ "Adopt a 4px rhythm, with documented exceptions for hairlines.")
119
+ check("spacing","scale_order", s==sorted(set(s)),"medium",f"Scale {s}",
120
+ "Remove duplicate tokens and order the spacing scale.")
121
+ check("spacing","coverage",len({n for n in s if n > 0})>=5 and any(0<n<=4 for n in s) and max(s)>=24,"medium",f"Scale {s}",
122
+ "Include at least five levels covering 4px to 24px or larger.")
123
+ r=tokens.radius
124
+ check("shape","radius_rhythm",r==sorted(set(r)) and 2<=len(r)<=5,"low",f"Radii {r}",
125
+ "Use a small, ascending family of 2–5 radius values.")
126
+ check("shape","radius_range",max(r)<=32,"low",f"Maximum radius {max(r)}",
127
+ "Keep ordinary surfaces below 32px radius; handle pills as explicit exceptions.")
128
+ check("motion","duration",tokens.motion_ms <= 300,"medium",f"Duration {tokens.motion_ms}ms",
129
+ "Keep routine interface transitions within 300ms; reserve longer motion for specific purposes.")
130
+ check("motion","reduced_motion",tokens.reduced_motion or tokens.motion_ms==0,"high","Reduced motion: "+str(tokens.reduced_motion),
131
+ "Respect prefers-reduced-motion and avoid nonessential animation when requested.")
132
+ check("layout","mobile_columns",tokens.mobile_columns <= min(tokens.columns,2),"medium",
133
+ f"Desktop/mobile {tokens.columns}/{tokens.mobile_columns} columns",
134
+ "Use one or two mobile columns, allowing content to reflow.")
135
+ check("layout","container",640<=tokens.content_width<=1600,"low",f"Content width {tokens.content_width}px",
136
+ "Use a bounded desktop container and fluid mobile width.")
137
+ check("layout","density", max(s) >= (24 if brief.density=="compact" else 32 if brief.density=="balanced" else 48),
138
+ "low",f"Spacing maximum {max(s)} for {brief.density} density",
139
+ "Include a larger section-spacing token suited to the selected density.")
140
+
141
+ points = {k: round(WEIGHTS[k]*sum(v)/len(v),2) for k,v in checks.items()}
142
+ order = {"high":0,"medium":1,"low":2}
143
+ issues.sort(key=lambda i:(order[i["priority"]], list(WEIGHTS).index(i["group"]), i["id"]))
144
+ return {"rubric_points":points,"rubric_maximum":WEIGHTS.copy(),"score":round(sum(points.values()),2),
145
+ "contrast_ratios":ratios,"actions":issues,
146
+ "limits":"Token-only heuristic. Contrast targets are WCAG reference ratios; this cannot establish WCAG compliance, rendered layout, text wrapping or visual quality."}
147
+
148
+
149
+ PALETTES = {
150
+ "calm": ("#2649b5","#ffffff","#a9c1ff","#172557"),
151
+ "warm": ("#a43e20","#ffffff","#ffb99f","#522013"),
152
+ "bold": ("#6435b6","#ffffff","#d7b5ff","#37175b"),
153
+ }
154
+
155
+
156
+ def propose(brief: Brief) -> Tokens:
157
+ brief = Brief.model_validate(brief.model_dump())
158
+ accent, on_accent, dark_accent, dark_on = PALETTES[brief.mood]
159
+ if brief.theme == "dark":
160
+ bg, surface, text, muted, accent, on_accent = "#101828","#1d2939","#f9fafb","#cbd5e1",dark_accent,dark_on
161
+ else:
162
+ bg, surface, text, muted = "#f6f8fb","#ffffff","#17212f","#475569"
163
+ type_scale = {"dashboard": (12,16,20,25,32), "landing": (13,18,24,36,64),
164
+ "ecommerce": (12,16,21,29,42)}[brief.kind]
165
+ spacing = {"compact":[4,8,12,16,24,32], "balanced":[4,8,12,16,24,32,48,64],
166
+ "airy":[4,8,16,24,32,48,72,96]}[brief.density]
167
+ radii = {"dashboard":[4,8,12], "landing":[4,12,20], "ecommerce":[4,8,16]}[brief.kind]
168
+ return Tokens(background=bg,surface=surface,text=text,muted=muted,accent=accent,on_accent=on_accent,focus=accent,
169
+ fonts=dict(zip(ROLE_ORDER,type_scale)),spacing=spacing,radius=radii,motion_ms=180,
170
+ reduced_motion=True,line_height=1.6,columns={"dashboard":4,"landing":2,"ecommerce":4}[brief.kind],
171
+ mobile_columns=1,content_width={"dashboard":1440,"landing":1200,"ecommerce":1280}[brief.kind],
172
+ heading_font="serif" if brief.mood=="warm" and brief.kind=="landing" else "system")
173
+
174
+
175
+ def css(tokens: Tokens) -> str:
176
+ # Revalidate because nested mutable collections can change after construction.
177
+ tokens = Tokens.model_validate(tokens.model_dump())
178
+ # Only strict-enum and numeric/hex values enter these declarations.
179
+ families={"system":"system-ui, sans-serif","serif":"Georgia, serif","mono":"ui-monospace, monospace"}
180
+ lines=[":root {"]
181
+ for key in ("background","surface","text","muted","accent","on_accent","focus"):
182
+ lines.append(f" --ps-{key.replace('_','-')}: {getattr(tokens,key)};")
183
+ for key in ROLE_ORDER:
184
+ lines.append(f" --ps-type-{key}: {tokens.fonts[key] / 16:g}rem;")
185
+ for group, values in (("space",tokens.spacing),("radius",tokens.radius)):
186
+ for i,v in enumerate(values,1):
187
+ lines.append(f" --ps-{group}-{i}: {v:g}px;")
188
+ lines += [f" --ps-body-font: {families[tokens.body_font]};",
189
+ f" --ps-heading-font: {families[tokens.heading_font]};",
190
+ f" --ps-body-leading: {tokens.line_height:g};",
191
+ f" --ps-duration: {tokens.motion_ms:g}ms;",
192
+ f" --ps-content-width: {tokens.content_width}px;",
193
+ f" --ps-columns: {tokens.columns};",
194
+ f" --ps-mobile-columns: {tokens.mobile_columns};","}","",
195
+ ".ps-body { font-family: var(--ps-body-font); font-size: var(--ps-type-body); line-height: var(--ps-body-leading); }",
196
+ ".ps-heading { font-family: var(--ps-heading-font); }",
197
+ ".ps-surface {",
198
+ " color: var(--ps-text);",
199
+ " background: var(--ps-surface);",
200
+ " border-radius: var(--ps-radius-1);",
201
+ " box-shadow: 0 6px 20px rgb(15 23 42 / 0.08);",
202
+ "}",
203
+ ".ps-grid { display: grid; gap: var(--ps-space-1);",
204
+ " grid-template-columns: repeat(var(--ps-columns), minmax(0, 1fr)); }",
205
+ ".ps-container { max-width: var(--ps-content-width); width: 100%; margin-inline: auto; }",
206
+ ".ps-button { background: var(--ps-accent); color: var(--ps-on-accent);",
207
+ " transition: box-shadow var(--ps-duration) ease; }",
208
+ ".ps-button:focus-visible { outline: 2px solid var(--ps-focus); outline-offset: 3px; }",
209
+ ".ps-button:hover { box-shadow: 0 3px 12px rgb(15 23 42 / 0.20); }",
210
+ "@media (max-width: 640px) {",
211
+ " .ps-grid { grid-template-columns: repeat(var(--ps-mobile-columns), minmax(0, 1fr)); }",
212
+ "}",
213
+ "@media (prefers-reduced-motion: reduce) {",
214
+ " .ps-button { transition: none; animation: none; }",
215
+ "}",""]
216
+ return "\n".join(lines)
@@ -0,0 +1,39 @@
1
+ """Local stdio MCP server using the official Python SDK."""
2
+ from typing import Any
3
+ from mcp.server.fastmcp import FastMCP
4
+ from mcp.types import ToolAnnotations
5
+ from .design import Brief, Tokens, audit, propose, css
6
+
7
+ mcp = FastMCP("Polish Studio", instructions="Evaluate explicitly supplied design tokens. Results are design suggestions, not rendered visual audits.")
8
+ READ_ONLY = ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)
9
+
10
+
11
+ @mcp.tool(annotations=READ_ONLY, structured_output=True)
12
+ def audit_design(tokens: Tokens, brief: Brief) -> dict[str, Any]:
13
+ """Assess token contrast, typography, spacing, shape, motion, and layout with prioritized fixes."""
14
+ return audit(tokens, brief)
15
+
16
+
17
+ @mcp.tool(annotations=READ_ONLY, structured_output=True)
18
+ def propose_design(brief: Brief) -> dict[str, Any]:
19
+ """Return a coherent, bounded redesign system for the selected page type, density, mood and theme."""
20
+ tokens = propose(brief)
21
+ return {"tokens": tokens.model_dump(), "audit": audit(tokens, brief),
22
+ "css": css(tokens), "implementation_notes": [
23
+ "Apply these tokens to the existing design system; do not blindly replace component behavior.",
24
+ "Review responsive layouts at 320px, 768px and a desktop width.",
25
+ "Verify actual focus, contrast, text resizing, keyboard operation and reduced motion in the browser."]}
26
+
27
+
28
+ @mcp.tool(annotations=READ_ONLY, structured_output=True)
29
+ def generate_css(tokens: Tokens) -> dict[str, Any]:
30
+ """Generate namespaced CSS variables, responsive grid, focus and reduced-motion effects from validated tokens."""
31
+ return {"css": css(tokens), "notes": "The CSS includes optional ps- classes. Review specificity, component states and layout before integration."}
32
+
33
+
34
+ def main():
35
+ mcp.run(transport="stdio")
36
+
37
+
38
+ if __name__ == "__main__":
39
+ main()
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: polish-studio-mcp
3
+ Version: 0.1.1
4
+ Summary: Local deterministic design-token audit and redesign MCP server
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/ahmedsaeed1-eng/polish-studio-mcp
7
+ Project-URL: Issues, https://github.com/ahmedsaeed1-eng/polish-studio-mcp/issues
8
+ Keywords: design-system,accessibility,css,mcp
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: mcp<2,>=1.29
13
+ Requires-Dist: pydantic<3,>=2.7
14
+ Dynamic: license-file
15
+
16
+ <!-- mcp-name: io.github.ahmedsaeed1-eng/polish-studio-mcp -->
17
+
18
+ # Polish Studio MCP
19
+
20
+ ![Polish Studio — visual systems workshop](assets/logo.svg)
21
+
22
+ A local design-token workshop for web developers using coding agents.
23
+
24
+ **Audit the system → propose a direction → adapt the CSS → verify the rendered interface.**
25
+
26
+ ---
27
+
28
+ ## Studio notes / Case 001
29
+
30
+ **Dashboard redesign, illustrative example**
31
+
32
+ ![A token-based dashboard mockup showing a before and proposed visual direction](assets/case-study.svg)
33
+
34
+ The illustration is an original conceptual mockup, not a screenshot or an automatically rendered transformation. The following measurements are reproduced by the included [demo](examples/demo.py) using the actual scoring algorithm.
35
+
36
+ | Design decision | Before | Proposed |
37
+ |---|---:|---:|
38
+ | Body type | 13px | 16px |
39
+ | Primary heading | 18px | 32px |
40
+ | Spacing examples | 5, 10, 15px | 4, 8, 12, 16, 24…64px |
41
+ | Routine motion | 600ms | 180ms |
42
+ | Reduced-motion support | no | yes |
43
+ | Limited token rubric | 56.67 / 100 | 100 / 100 |
44
+
45
+ The proposal prioritizes the text contrast and reduced-motion failures, followed by typography and spacing. A coding agent can adapt these values to an existing project without changing business logic. The rubric is a limited token checklist, not a universal design quality or accessibility score.
46
+
47
+ `v0.1.1` / Python 3.10+ / MCP over stdio / [MIT](LICENSE)
48
+
49
+ [![GitHub stars](https://img.shields.io/github/stars/ahmedsaeed1-eng/polish-studio-mcp?style=flat-square&color=D78B5C)](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/stargazers) ![MCP stdio](https://img.shields.io/badge/transport-MCP%20stdio-252C38?style=flat-square) ![8 tests passed locally](https://img.shields.io/badge/local%20tests-8%20passed-245B42?style=flat-square) [![CI](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ahmedsaeed1-eng/polish-studio-mcp/actions/workflows/ci.yml) [![MIT](https://img.shields.io/badge/license-MIT-087f8c?style=flat-square)](LICENSE) ![Runtime offline](https://img.shields.io/badge/runtime-offline-648577?style=flat-square)
50
+
51
+ ## The toolkit
52
+
53
+ A polished interface comes from consistent visual decisions, not arbitrary decoration. Polish Studio is a local Model Context Protocol server that evaluates explicitly provided design tokens and produces actionable design improvements for existing web applications.
54
+
55
+ - **Contrast:** deterministic text and focus contrast ratios with prioritized fixes.
56
+ - **Typography:** role hierarchy, reading size, line height and headline scale.
57
+ - **Rhythm:** spacing, radius consistency, motion duration and content density.
58
+ - **Responsive foundations:** bounded containers and mobile grid reflow.
59
+ - **Design proposals:** 54 distinct combinations of dashboard, landing and e-commerce systems across three densities, three moods and light/dark themes.
60
+ - **CSS:** namespaced design variables, optional components and accessible-motion foundations.
61
+
62
+ No API key, browser, remote site inspection or runtime network access is required. The server only handles explicitly passed structured information. It does not edit projects, execute commands, read arbitrary files or access websites.
63
+
64
+ ## Install the workshop
65
+
66
+ Clone this repository and install from its directory into a virtual environment:
67
+
68
+ ```sh
69
+ python -m venv .venv
70
+ # macOS/Linux: source .venv/bin/activate
71
+ # Windows PowerShell: .venv\Scripts\Activate.ps1
72
+ python -m pip install .
73
+ ```
74
+
75
+ After installation, `polish-studio-mcp`, `polish-studio`, or `python -m polish_studio` starts the stdio server. It waits for an MCP client; it does not expose an HTTP port. Use the absolute path to the environment's Python interpreter in your MCP client, so the client does not depend on shell activation.
76
+
77
+ ### Codex
78
+
79
+ ```sh
80
+ codex mcp add polish-studio -- /absolute/path/to/.venv/bin/python -m polish_studio
81
+ codex mcp list
82
+ ```
83
+
84
+ Or configure `~/.codex/config.toml`:
85
+
86
+ ```toml
87
+ [mcp_servers.polish-studio]
88
+ command = "/absolute/path/to/.venv/bin/python"
89
+ args = ["-m", "polish_studio"]
90
+ ```
91
+
92
+ On Windows substitute e.g. `C:/dev/polish-studio-mcp/.venv/Scripts/python.exe`.
93
+
94
+ ### Claude Code
95
+
96
+ ```sh
97
+ claude mcp add --transport stdio polish-studio -- /absolute/path/to/.venv/bin/python -m polish_studio
98
+ claude mcp list
99
+ ```
100
+
101
+ Use the same Windows interpreter substitution. Reopen the agent session if necessary, then check MCP tool discovery. See [Codex MCP docs](https://developers.openai.com/codex/mcp) and [Claude Code MCP docs](https://code.claude.com/docs/en/mcp). Configuration examples follow the documented syntax; actual Codex/Claude host sessions have not been independently tested. An official SDK client integration test verifies the stdio protocol.
102
+
103
+ ## Working with a coding agent
104
+
105
+ Tell your coding agent:
106
+
107
+ > Review my existing design tokens. Call audit_design using the supplied colors, type sizes, spacing, radius, layout and motion settings. Show high-priority issues first. Use propose_design for a calm, balanced dashboard. Compare both systems and adapt the returned CSS to my current components, preserving behavior. Verify the rendered site at desktop and mobile sizes and with keyboard navigation.
108
+
109
+ The server provides the analysis and proposal only. Your coding agent reviews and applies changes to the actual project within its permissions.
110
+
111
+ ### Tool catalog
112
+
113
+ | Tool | Input | Output |
114
+ |---|---|---|
115
+ | `audit_design` | Design tokens and brief | Weighted rubric, measured contrast ratios, prioritized actions |
116
+ | `propose_design` | Brief | Complete tokens, rubric, CSS, integration checklist |
117
+ | `generate_css` | Design tokens | Namespaced CSS; optional grid, focus, shadow and motion classes |
118
+
119
+ Brief structure:
120
+
121
+ ```json
122
+ {"brief":{"kind":"dashboard","density":"balanced","mood":"calm","theme":"light"}}
123
+ ```
124
+
125
+ Accepted kinds: `dashboard`, `landing`, `ecommerce`. Densities: `compact`, `balanced`, `airy`. Moods: `calm`, `bold`, `warm`. Themes: `light`, `dark`.
126
+
127
+ Example audit input:
128
+
129
+ ```json
130
+ {
131
+ "brief": {"kind":"dashboard","density":"balanced","mood":"calm","theme":"light"},
132
+ "tokens": {
133
+ "background":"#f6f8fb", "surface":"#ffffff", "text":"#17212f",
134
+ "muted":"#475569", "accent":"#2649b5", "on_accent":"#ffffff", "focus":"#2649b5",
135
+ "fonts":{"caption":12,"body":16,"h3":20,"h2":25,"h1":32},
136
+ "spacing":[4,8,12,16,24,32,48,64], "radius":[4,8,12],
137
+ "motion_ms":180,"reduced_motion":true,"line_height":1.6,
138
+ "columns":4,"mobile_columns":1,"content_width":1440,
139
+ "body_font":"system","heading_font":"system"
140
+ }
141
+ }
142
+ ```
143
+
144
+ Colors must be six-digit hex values. Sizes, columns and scales are bounded numbers; fonts are predefined family roles. Raw CSS is not accepted.
145
+
146
+ ## Reading the measurements
147
+
148
+ | Category | Maximum points |
149
+ |---|---:|
150
+ | Text and focus contrast | 35 |
151
+ | Typography | 20 |
152
+ | Spacing | 15 |
153
+ | Shape | 10 |
154
+ | Motion | 10 |
155
+ | Layout | 10 |
156
+
157
+ Category points equal its weight multiplied by the fraction of checks passed. Actions are sorted by explicit priority, then category and stable identifier. The normal text target is 4.5:1; the focus token target against background and surface is 3:1. Other thresholds are documented project heuristics.
158
+
159
+ **100 rubric points means the supplied values satisfy this limited checklist.** It does not mean a site is fully professional, accessible or certified. Rendered contrast over imagery, target sizes, keyboard order, semantic markup, actual font rendering, actual component state colors, browser zoom, responsive wrapping and actual reduced-motion behavior require separate review.
160
+
161
+ ## Reproduce and test
162
+
163
+ ```sh
164
+ python -m unittest discover -s tests -v
165
+ python examples/demo.py
166
+ ```
167
+
168
+ Tests include reference contrast ratios, every preset combination, priority ordering, input rejection, responsive CSS and a live stdio round-trip for all three tools. CI is configured for Linux and Windows with Python 3.10/3.12. No platform-specific claims are made until CI runs.
169
+
170
+ ## License
171
+
172
+ MIT. See [LICENSE](LICENSE) and [third-party acknowledgments](THIRD_PARTY.md).
@@ -0,0 +1,21 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ THIRD_PARTY.md
5
+ pyproject.toml
6
+ server.json
7
+ assets/case-study.svg
8
+ assets/logo.svg
9
+ examples/demo.py
10
+ polish_studio/__init__.py
11
+ polish_studio/__main__.py
12
+ polish_studio/design.py
13
+ polish_studio/server.py
14
+ polish_studio_mcp.egg-info/PKG-INFO
15
+ polish_studio_mcp.egg-info/SOURCES.txt
16
+ polish_studio_mcp.egg-info/dependency_links.txt
17
+ polish_studio_mcp.egg-info/entry_points.txt
18
+ polish_studio_mcp.egg-info/requires.txt
19
+ polish_studio_mcp.egg-info/top_level.txt
20
+ tests/test_design.py
21
+ tests/test_mcp.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ polish-studio = polish_studio.server:main
3
+ polish-studio-mcp = polish_studio.server:main
@@ -0,0 +1,2 @@
1
+ mcp<2,>=1.29
2
+ pydantic<3,>=2.7
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "polish-studio-mcp"
7
+ version = "0.1.1"
8
+ description = "Local deterministic design-token audit and redesign MCP server"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ dependencies = ["mcp>=1.29,<2", "pydantic>=2.7,<3"]
14
+
15
+ keywords = ["design-system","accessibility","css","mcp"]
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/ahmedsaeed1-eng/polish-studio-mcp"
19
+ Issues = "https://github.com/ahmedsaeed1-eng/polish-studio-mcp/issues"
20
+
21
+ [project.scripts]
22
+ polish-studio = "polish_studio.server:main"
23
+ polish-studio-mcp = "polish_studio.server:main"
24
+
25
+ [tool.setuptools.packages.find]
26
+ include = ["polish_studio*"]
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.ahmedsaeed1-eng/polish-studio-mcp",
4
+ "title": "Polish Studio MCP",
5
+ "description": "Local deterministic design-token audits, proposals and CSS generation.",
6
+ "repository": {
7
+ "url": "https://github.com/ahmedsaeed1-eng/polish-studio-mcp",
8
+ "source": "github"
9
+ },
10
+ "version": "0.1.1",
11
+ "packages": [
12
+ {
13
+ "registryType": "pypi",
14
+ "registryBaseUrl": "https://pypi.org",
15
+ "identifier": "polish-studio-mcp",
16
+ "version": "0.1.1",
17
+ "runtimeHint": "uvx",
18
+ "transport": {
19
+ "type": "stdio"
20
+ }
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,68 @@
1
+ import unittest
2
+ from pydantic import ValidationError
3
+ from polish_studio.design import Brief, Tokens, audit, contrast, propose, css
4
+
5
+
6
+ class DesignTests(unittest.TestCase):
7
+ def test_reference_contrast(self):
8
+ self.assertAlmostEqual(contrast("#000000", "#ffffff"), 21)
9
+ self.assertAlmostEqual(contrast("#777777", "#ffffff"), 4.478, places=3)
10
+ self.assertEqual(contrast("#112233", "#112233"), 1)
11
+
12
+ def test_all_preset_combinations(self):
13
+ for kind in ("dashboard", "landing", "ecommerce"):
14
+ for density in ("compact", "balanced", "airy"):
15
+ for mood in ("calm", "warm", "bold"):
16
+ for theme in ("light", "dark"):
17
+ brief = Brief(kind=kind,density=density,mood=mood,theme=theme)
18
+ token = propose(brief)
19
+ report = audit(token, brief)
20
+ self.assertEqual(report["score"], 100, (brief,report))
21
+ self.assertEqual(report["actions"], [])
22
+ self.assertEqual(report,audit(token,brief))
23
+
24
+ def test_prioritized_evidence(self):
25
+ brief=Brief()
26
+ data=propose(brief).model_dump()
27
+ data.update(text="#eeeeee", spacing=[3,7,7], reduced_motion=False,motion_ms=900,mobile_columns=4)
28
+ report=audit(Tokens(**data),brief)
29
+ ids={x["id"] for x in report["actions"]}
30
+ self.assertTrue({"text_on_background","rhythm","scale_order","reduced_motion","duration","mobile_columns"}<=ids)
31
+ self.assertLess(report["score"],100)
32
+ self.assertEqual(report["actions"][0]["priority"],"high")
33
+
34
+ def test_reject_unsafe_css_and_nonfinite_numbers(self):
35
+ data=propose(Brief()).model_dump()
36
+ for invalid in ({"accent":"#333;url(https://example.org)"},{"heading_font":"url(x)"},
37
+ {"spacing":[float("nan")]},{"fonts":{"body":16}},{"content_width":99999},
38
+ {"notes":"unexpected"}):
39
+ with self.subTest(invalid=invalid):
40
+ with self.assertRaises(ValidationError):
41
+ Tokens(**(data|invalid))
42
+
43
+ def test_css_responsive_and_motion(self):
44
+ style=css(propose(Brief(theme="dark")))
45
+ self.assertIn("--ps-background: #101828",style)
46
+ self.assertIn("--ps-type-body: 1rem",style)
47
+ self.assertIn("@media (prefers-reduced-motion: reduce)",style)
48
+ self.assertIn("@media (max-width: 640px)",style)
49
+ self.assertIn(":focus-visible",style)
50
+ self.assertNotIn("url(",style)
51
+
52
+ def test_scale_coverage_and_report_isolation(self):
53
+ brief = Brief()
54
+ tokens = propose(brief)
55
+ tokens.spacing = [0, 8, 8, 8, 24]
56
+ tokens.radius = [8]
57
+ report = audit(tokens, brief)
58
+ self.assertTrue({"coverage", "radius_rhythm"} <= {i["id"] for i in report["actions"]})
59
+ report["rubric_maximum"]["contrast"] = -1
60
+ self.assertEqual(audit(propose(brief), brief)["score"], 100)
61
+
62
+ def test_revalidate_mutated_collections(self):
63
+ tokens = propose(Brief())
64
+ tokens.spacing.append(float("nan"))
65
+ with self.assertRaises(ValidationError):
66
+ css(tokens)
67
+ with self.assertRaises(ValidationError):
68
+ audit(tokens, Brief())
@@ -0,0 +1,31 @@
1
+ import sys
2
+ import unittest
3
+ from mcp import ClientSession, StdioServerParameters
4
+ from mcp.client.stdio import stdio_client
5
+ from polish_studio.design import Brief, propose
6
+
7
+
8
+ class ProtocolTests(unittest.IsolatedAsyncioTestCase):
9
+ async def test_stdio_tool_contract(self):
10
+ params=StdioServerParameters(command=sys.executable,args=["-m","polish_studio"])
11
+ async with stdio_client(params) as (read,write):
12
+ async with ClientSession(read,write) as session:
13
+ init=await session.initialize()
14
+ self.assertEqual(init.serverInfo.name,"Polish Studio")
15
+ tools=await session.list_tools()
16
+ self.assertEqual({t.name for t in tools.tools},{"audit_design","propose_design","generate_css"})
17
+ brief={"kind":"landing","mood":"warm","theme":"dark","density":"airy"}
18
+ result=await session.call_tool("propose_design",{"brief":brief})
19
+ self.assertFalse(result.isError)
20
+ payload=result.structuredContent
21
+ self.assertEqual(payload["audit"]["score"],100)
22
+ self.assertIn("--ps-accent",payload["css"])
23
+ audit=await session.call_tool("audit_design",{"tokens":payload["tokens"],"brief":brief})
24
+ self.assertEqual(audit.structuredContent["score"],100)
25
+ style=await session.call_tool("generate_css",{"tokens":payload["tokens"]})
26
+ self.assertFalse(style.isError)
27
+ self.assertEqual(style.structuredContent["css"],payload["css"])
28
+ invalid=propose(Brief()).model_dump()
29
+ invalid["accent"]="url(https://example.org)"
30
+ error=await session.call_tool("generate_css",{"tokens":invalid})
31
+ self.assertTrue(error.isError)