css-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.
css_mcp-0.1.1/.envrc ADDED
@@ -0,0 +1 @@
1
+ layout uv
@@ -0,0 +1,63 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+
28
+ # IDE
29
+ .idea/
30
+ .vscode/
31
+ *.swp
32
+ *.swo
33
+ *~
34
+
35
+ # Testing
36
+ .pytest_cache/
37
+ .coverage
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+
42
+ # Type checking
43
+ .mypy_cache/
44
+ .dmypy.json
45
+ dmypy.json
46
+
47
+ # Ruff
48
+ .ruff_cache/
49
+
50
+ # Distribution
51
+ *.manifest
52
+ *.spec
53
+
54
+ # Logs
55
+ *.log
56
+
57
+ # Cache
58
+ .css_mcp_cache/
59
+ .cache/
60
+
61
+ # OS
62
+ .DS_Store
63
+ Thumbs.db
@@ -0,0 +1,106 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ CSS MCP Server is an MCP (Model Context Protocol) server for CSS analysis and documentation, designed for the FastBlocks ecosystem. It provides 9 tools for analyzing programmatically generated CSS from style adapters like Kelp UI and WebAwesome.
8
+
9
+ ## Development Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ uv sync --group dev
14
+
15
+ # Run tests
16
+ pytest
17
+
18
+ # Type check
19
+ mypy css_mcp
20
+
21
+ # Lint
22
+ ruff check css_mcp
23
+
24
+ # Run the server locally
25
+ css-mcp
26
+ # or
27
+ python -m css_mcp.server
28
+ ```
29
+
30
+ ## Architecture
31
+
32
+ The server is built on FastMCP and follows a modular architecture:
33
+
34
+ ```
35
+ css_mcp/
36
+ ├── server.py # MCP server entry point, tool registration
37
+ ├── tools.py # Tool implementations with Pydantic input models
38
+ ├── analyzer.py # Core CSS analysis engine (150+ metrics)
39
+ ├── mdn_fetcher.py # MDN Web Docs documentation fetcher
40
+ ├── compat.py # Browser compatibility checker
41
+ └── config.py # Configuration with environment variable support
42
+ ```
43
+
44
+ ### Key Components
45
+
46
+ **CSSAnalyzer** (`analyzer.py`): The core analysis engine that parses CSS using tinycss2 and computes 150+ metrics including:
47
+ - Complexity scores (0-100)
48
+ - Specificity analysis with distribution
49
+ - Selector patterns (ID, class, element, universal)
50
+ - Property categorization (layout, typography, flexbox, grid, etc.)
51
+ - Quality metrics (duplicates, empty rules, !important usage)
52
+
53
+ **MDNFetcher** (`mdn_fetcher.py`): Fetches CSS property documentation from MDN Web Docs with built-in fallback metadata for common properties.
54
+
55
+ **BrowserCompatChecker** (`compat.py`): Built-in browser compatibility data for major CSS properties across Chrome, Firefox, Safari, and Edge.
56
+
57
+ ## MCP Tools
58
+
59
+ | Tool | Purpose |
60
+ |------|---------|
61
+ | `analyze_css` | Full CSS analysis with 150+ metrics |
62
+ | `analyze_css_summary` | Quick summary (faster) |
63
+ | `get_docs` | MDN documentation for CSS properties |
64
+ | `get_browser_compatibility` | Browser support checking |
65
+ | `search_properties` | Search CSS properties |
66
+ | `get_properties_by_category` | Properties by category |
67
+ | `analyze_project_css` | Project-wide CSS analysis |
68
+ | `list_capabilities` | List available tools |
69
+ | `health_check` | Server health status |
70
+
71
+ ## Configuration
72
+
73
+ Environment variables (prefix: `CSS_MCP_`):
74
+
75
+ | Variable | Default | Description |
76
+ |----------|---------|-------------|
77
+ | `CSS_MCP_HTTP_PORT` | 3050 | Server port |
78
+ | `CSS_MCP_HTTP_HOST` | localhost | Server host |
79
+ | `CSS_MCP_DEBUG` | false | Enable debug mode |
80
+
81
+ ## Dependencies
82
+
83
+ - **fastmcp**: MCP server framework
84
+ - **tinycss2**: CSS parsing
85
+ - **cssselect**: Selector parsing
86
+ - **httpx**: Async HTTP for MDN fetching
87
+ - **pydantic**: Data validation
88
+ - **mcp-common**: Shared MCP utilities
89
+ - **oneiric**: Configuration management
90
+
91
+ ## FastBlocks Integration
92
+
93
+ This server is designed for analyzing CSS generated by FastBlocks style adapters:
94
+ - Kelp UI (custom lightweight framework)
95
+ - WebAwesome (Font Awesome components)
96
+ - Vanilla (minimal semantic styling)
97
+
98
+ When analyzing generated CSS, use `CSSAnalyzer` directly:
99
+
100
+ ```python
101
+ from css_mcp.analyzer import CSSAnalyzer
102
+
103
+ analyzer = CSSAnalyzer()
104
+ metrics = analyzer.analyze(css_content)
105
+ suggestions = analyzer.get_suggestions()
106
+ ```
css_mcp-0.1.1/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Robert Leslie and Wedgwood Web Works
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
css_mcp-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: css-mcp
3
+ Version: 0.1.1
4
+ Summary: CSS analysis and documentation MCP server for FastBlocks ecosystem
5
+ Project-URL: Homepage, https://github.com/lesleslie/css-mcp
6
+ Project-URL: Repository, https://github.com/lesleslie/css-mcp
7
+ Author-email: Les Leslie <les@lesleslie.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Python: >=3.13
16
+ Requires-Dist: cssselect>=1.2.0
17
+ Requires-Dist: fastmcp>=0.6.0
18
+ Requires-Dist: httpx>=0.27.0
19
+ Requires-Dist: mcp-common>=0.1.0
20
+ Requires-Dist: oneiric>=0.1.0
21
+ Requires-Dist: pydantic>=2.0.0
22
+ Requires-Dist: tinycss2>=1.3.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: mypy>=1.9.0; extra == 'dev'
25
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
26
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
27
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # CSS MCP Server
32
+
33
+ CSS Analysis and Documentation MCP Server for the FastBlocks ecosystem.
34
+
35
+ ## Features
36
+
37
+ - **CSS Analysis**: 150+ metrics for CSS complexity, specificity, and quality
38
+ - **MDN Documentation**: Fetch CSS property docs from MDN Web Docs
39
+ - **Browser Compatibility**: Check cross-browser support for CSS properties
40
+ - **Project Analysis**: Analyze all CSS files in a project
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ # Using uv
46
+ uv pip install css-mcp
47
+
48
+ # Using pip
49
+ pip install css-mcp
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ ### Start Server
55
+
56
+ ```bash
57
+ # Via CLI
58
+ css-mcp
59
+
60
+ # Via Python module
61
+ python -m css_mcp.server
62
+ ```
63
+
64
+ ### Environment Variables
65
+
66
+ | Variable | Default | Description |
67
+ |----------|---------|-------------|
68
+ | `CSS_MCP_HTTP_PORT` | 3050 | Server port |
69
+ | `CSS_MCP_HTTP_HOST` | localhost | Server host |
70
+ | `CSS_MCP_DEBUG` | false | Enable debug mode |
71
+
72
+ ## Available Tools
73
+
74
+ | Tool | Description |
75
+ |------|-------------|
76
+ | `analyze_css` | Full CSS analysis with 150+ metrics |
77
+ | `analyze_css_summary` | Quick CSS summary (faster) |
78
+ | `get_docs` | MDN documentation for CSS properties |
79
+ | `get_browser_compatibility` | Check browser support for properties |
80
+ | `search_properties` | Search for CSS properties |
81
+ | `get_properties_by_category` | Get properties by category |
82
+ | `analyze_project_css` | Analyze all CSS in a project |
83
+ | `list_capabilities` | List available capabilities |
84
+ | `health_check` | Check server health |
85
+
86
+ ## Integration with FastBlocks
87
+
88
+ This server is designed for analyzing programmatically generated CSS from FastBlocks style adapters:
89
+
90
+ - **Kelp UI**: Custom lightweight CSS framework
91
+ - **WebAwesome**: Font Awesome's component library
92
+ - **Vanilla**: Minimal semantic styling
93
+
94
+ ### Example: Analyze Generated CSS
95
+
96
+ ```python
97
+ from css_mcp.analyzer import CSSAnalyzer
98
+
99
+ # Analyze CSS generated by FastBlocks style adapter
100
+ analyzer = CSSAnalyzer()
101
+ metrics = analyzer.analyze(kelp_css)
102
+
103
+ # Get complexity score
104
+ print(f"Complexity: {metrics.complexity_score}/100")
105
+
106
+ # Get optimization suggestions
107
+ suggestions = analyzer.get_suggestions()
108
+ ```
109
+
110
+ ## Metrics
111
+
112
+ The analyzer provides 150+ metrics including:
113
+
114
+ ### Basic Metrics
115
+ - Total rules, selectors, properties
116
+ - File size (bytes, gzipped)
117
+ - Lines of code
118
+
119
+ ### Selector Metrics
120
+ - ID, class, element, universal selectors
121
+ - Pseudo-classes and pseudo-elements
122
+ - Combinators (descendant, child, sibling)
123
+ - Selector depth
124
+
125
+ ### Specificity Metrics
126
+ - Average, min, max specificity
127
+ - High specificity rules
128
+ - Specificity distribution
129
+
130
+ ### Property Metrics
131
+ - Unique properties
132
+ - Category distribution (layout, typography, etc.)
133
+ - Vendor prefixes
134
+ - `!important` usage
135
+ - CSS custom properties
136
+
137
+ ### Quality Metrics
138
+ - Duplicate selectors
139
+ - Duplicate properties
140
+ - Empty rules
141
+ - Complexity score
142
+ - Efficiency scores
143
+
144
+ ## Browser Compatibility
145
+
146
+ Built-in compatibility data for common CSS properties across:
147
+ - Chrome
148
+ - Firefox
149
+ - Safari
150
+ - Edge
151
+
152
+ ## Development
153
+
154
+ ```bash
155
+ # Install dev dependencies
156
+ uv sync --group dev
157
+
158
+ # Run tests
159
+ pytest
160
+
161
+ # Type check
162
+ mypy css_mcp
163
+
164
+ # Lint
165
+ ruff check css_mcp
166
+ ```
167
+
168
+ ## License
169
+
170
+ MIT
@@ -0,0 +1,140 @@
1
+ # CSS MCP Server
2
+
3
+ CSS Analysis and Documentation MCP Server for the FastBlocks ecosystem.
4
+
5
+ ## Features
6
+
7
+ - **CSS Analysis**: 150+ metrics for CSS complexity, specificity, and quality
8
+ - **MDN Documentation**: Fetch CSS property docs from MDN Web Docs
9
+ - **Browser Compatibility**: Check cross-browser support for CSS properties
10
+ - **Project Analysis**: Analyze all CSS files in a project
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Using uv
16
+ uv pip install css-mcp
17
+
18
+ # Using pip
19
+ pip install css-mcp
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Start Server
25
+
26
+ ```bash
27
+ # Via CLI
28
+ css-mcp
29
+
30
+ # Via Python module
31
+ python -m css_mcp.server
32
+ ```
33
+
34
+ ### Environment Variables
35
+
36
+ | Variable | Default | Description |
37
+ |----------|---------|-------------|
38
+ | `CSS_MCP_HTTP_PORT` | 3050 | Server port |
39
+ | `CSS_MCP_HTTP_HOST` | localhost | Server host |
40
+ | `CSS_MCP_DEBUG` | false | Enable debug mode |
41
+
42
+ ## Available Tools
43
+
44
+ | Tool | Description |
45
+ |------|-------------|
46
+ | `analyze_css` | Full CSS analysis with 150+ metrics |
47
+ | `analyze_css_summary` | Quick CSS summary (faster) |
48
+ | `get_docs` | MDN documentation for CSS properties |
49
+ | `get_browser_compatibility` | Check browser support for properties |
50
+ | `search_properties` | Search for CSS properties |
51
+ | `get_properties_by_category` | Get properties by category |
52
+ | `analyze_project_css` | Analyze all CSS in a project |
53
+ | `list_capabilities` | List available capabilities |
54
+ | `health_check` | Check server health |
55
+
56
+ ## Integration with FastBlocks
57
+
58
+ This server is designed for analyzing programmatically generated CSS from FastBlocks style adapters:
59
+
60
+ - **Kelp UI**: Custom lightweight CSS framework
61
+ - **WebAwesome**: Font Awesome's component library
62
+ - **Vanilla**: Minimal semantic styling
63
+
64
+ ### Example: Analyze Generated CSS
65
+
66
+ ```python
67
+ from css_mcp.analyzer import CSSAnalyzer
68
+
69
+ # Analyze CSS generated by FastBlocks style adapter
70
+ analyzer = CSSAnalyzer()
71
+ metrics = analyzer.analyze(kelp_css)
72
+
73
+ # Get complexity score
74
+ print(f"Complexity: {metrics.complexity_score}/100")
75
+
76
+ # Get optimization suggestions
77
+ suggestions = analyzer.get_suggestions()
78
+ ```
79
+
80
+ ## Metrics
81
+
82
+ The analyzer provides 150+ metrics including:
83
+
84
+ ### Basic Metrics
85
+ - Total rules, selectors, properties
86
+ - File size (bytes, gzipped)
87
+ - Lines of code
88
+
89
+ ### Selector Metrics
90
+ - ID, class, element, universal selectors
91
+ - Pseudo-classes and pseudo-elements
92
+ - Combinators (descendant, child, sibling)
93
+ - Selector depth
94
+
95
+ ### Specificity Metrics
96
+ - Average, min, max specificity
97
+ - High specificity rules
98
+ - Specificity distribution
99
+
100
+ ### Property Metrics
101
+ - Unique properties
102
+ - Category distribution (layout, typography, etc.)
103
+ - Vendor prefixes
104
+ - `!important` usage
105
+ - CSS custom properties
106
+
107
+ ### Quality Metrics
108
+ - Duplicate selectors
109
+ - Duplicate properties
110
+ - Empty rules
111
+ - Complexity score
112
+ - Efficiency scores
113
+
114
+ ## Browser Compatibility
115
+
116
+ Built-in compatibility data for common CSS properties across:
117
+ - Chrome
118
+ - Firefox
119
+ - Safari
120
+ - Edge
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ # Install dev dependencies
126
+ uv sync --group dev
127
+
128
+ # Run tests
129
+ pytest
130
+
131
+ # Type check
132
+ mypy css_mcp
133
+
134
+ # Lint
135
+ ruff check css_mcp
136
+ ```
137
+
138
+ ## License
139
+
140
+ MIT
@@ -0,0 +1,14 @@
1
+ """CSS MCP Server - CSS analysis and documentation for FastBlocks ecosystem."""
2
+
3
+ __version__ = "0.1.0"
4
+ __author__ = "Les Leslie"
5
+
6
+ from css_mcp.analyzer import CSSAnalyzer, CSSMetrics, CSSProperty
7
+ from css_mcp.config import CSSMCPConfig
8
+
9
+ __all__ = [
10
+ "CSSAnalyzer",
11
+ "CSSMetrics",
12
+ "CSSProperty",
13
+ "CSSMCPConfig",
14
+ ]
@@ -0,0 +1,6 @@
1
+ """Entry point for running CSS MCP as a module."""
2
+
3
+ from css_mcp.server import main
4
+
5
+ if __name__ == "__main__":
6
+ main()