frontend-dev-mcp 0.1.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,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: frontend-dev-mcp
3
+ Version: 0.1.0
4
+ Summary: Frontend Development MCP Server
5
+ Requires-Dist: mcp[cli]
@@ -0,0 +1,51 @@
1
+ # Frontend Development MCP Server
2
+
3
+ This is a Model Context Protocol (MCP) server built with `FastMCP` that provides general frontend development guidance.
4
+
5
+ ## Tools Available
6
+ - `get_design_system_guide(type)`: Get pros/cons of design systems ('utility-first', 'component-library', 'headless').
7
+ - `get_color_palette(primary_hex)`: Generate a complete color palette from a primary hex code.
8
+ - `get_accessibility_checklist()`: Essential a11y checklist.
9
+ - `get_performance_tips(focus_area)`: Tips for 'images', 'javascript', or 'css'.
10
+
11
+ ## Prompts Available
12
+ - `frontend_project_kickoff`: An interactive prompt to help plan architecture.
13
+
14
+ ## Installation
15
+
16
+ ### Standard Python (venv)
17
+ ```bash
18
+ # Create a virtual environment
19
+ python -m venv .venv
20
+ # Activate it (Windows)
21
+ .venv\\Scripts\\activate
22
+ # Activate it (macOS/Linux)
23
+ source .venv/bin/activate
24
+ # Install dependencies
25
+ pip install -r requirements.txt
26
+ ```
27
+
28
+ ## Running the Server
29
+
30
+ ### With the MCP Inspector
31
+ To run interactively for testing:
32
+ ```bash
33
+ npx @modelcontextprotocol/inspector .venv/Scripts/python server.py
34
+ # Or on macOS/Linux: npx @modelcontextprotocol/inspector .venv/bin/python server.py
35
+ ```
36
+
37
+ ### Claude Desktop Integration
38
+ Add the following to your Claude Desktop `claude_desktop_config.json`:
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "frontend-dev": {
43
+ "command": "C:\\\\absolute\\\\path\\\\to\\\\.venv\\\\Scripts\\\\python.exe",
44
+ "args": [
45
+ "C:\\\\absolute\\\\path\\\\to\\\\server.py"
46
+ ]
47
+ }
48
+ }
49
+ }
50
+ ```
51
+ *(Make sure to use the absolute paths for your machine).*
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: frontend-dev-mcp
3
+ Version: 0.1.0
4
+ Summary: Frontend Development MCP Server
5
+ Requires-Dist: mcp[cli]
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ server.py
4
+ frontend_dev_mcp.egg-info/PKG-INFO
5
+ frontend_dev_mcp.egg-info/SOURCES.txt
6
+ frontend_dev_mcp.egg-info/dependency_links.txt
7
+ frontend_dev_mcp.egg-info/entry_points.txt
8
+ frontend_dev_mcp.egg-info/requires.txt
9
+ frontend_dev_mcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ frontend-mcp = server:mcp.run
@@ -0,0 +1,8 @@
1
+ [project]
2
+ name = "frontend-dev-mcp"
3
+ version = "0.1.0"
4
+ description = "Frontend Development MCP Server"
5
+ dependencies = ["mcp[cli]"]
6
+
7
+ [project.scripts]
8
+ frontend-mcp = "server:mcp.run"
@@ -0,0 +1,232 @@
1
+ import os
2
+ import subprocess
3
+ import colorsys
4
+ from mcp.server.fastmcp import FastMCP
5
+
6
+ mcp = FastMCP("Frontend Development Server")
7
+
8
+ @mcp.tool()
9
+ def get_design_system_guide(type: str) -> str:
10
+ """
11
+ Provides pros/cons of popular design systems and when to use them.
12
+
13
+ Args:
14
+ type: The category of design system (e.g., 'utility-first', 'component-library', 'headless')
15
+ """
16
+ type = type.lower()
17
+ if type == "utility-first":
18
+ return """Utility-First (e.g., Tailwind CSS)
19
+ Pros:
20
+ - Highly customizable without leaving HTML.
21
+ - Small bundle sizes in production.
22
+ - Consistency out of the box.
23
+
24
+ Cons:
25
+ - Cluttered HTML markup.
26
+ - Steep learning curve for the utility classes.
27
+
28
+ When to use:
29
+ When you need complete custom designs, fast prototyping, or have a team that is comfortable learning the utility syntax.
30
+ """
31
+ elif type == "component-library":
32
+ return """Component Libraries (e.g., Material UI, Ant Design, Bootstrap)
33
+ Pros:
34
+ - Faster initial development with pre-built components.
35
+ - Standardized UI/UX.
36
+ - Good documentation and community support.
37
+
38
+ Cons:
39
+ - Harder to deeply customize without fighting the framework.
40
+ - Can lead to a generic "cookie-cutter" look.
41
+ - Potentially large bundle sizes.
42
+
43
+ When to use:
44
+ For enterprise applications, dashboards, or MVPs where speed of delivery is more important than a unique custom design.
45
+ """
46
+ elif type == "headless":
47
+ return """Headless UI Libraries (e.g., Radix UI, Headless UI, React Aria)
48
+ Pros:
49
+ - Complete control over styling while maintaining accessibility and behavior.
50
+ - Solves complex interactive patterns (dropdowns, modals, tabs).
51
+
52
+ Cons:
53
+ - Requires writing all the CSS yourself.
54
+ - Initial setup takes more time than fully styled components.
55
+
56
+ When to use:
57
+ When you need a highly custom, accessible design system from scratch. Often paired with Tailwind CSS.
58
+ """
59
+ else:
60
+ return "Unknown design system type. Try 'utility-first', 'component-library', or 'headless'."
61
+
62
+
63
+ def hex_to_rgb(hex_color: str):
64
+ hex_color = hex_color.lstrip('#')
65
+ if len(hex_color) == 3:
66
+ hex_color = ''.join(c + c for c in hex_color)
67
+ return tuple(int(hex_color[i:i+2], 16) / 255.0 for i in (0, 2, 4))
68
+
69
+ def rgb_to_hex(r, g, b):
70
+ return '#{:02x}{:02x}{:02x}'.format(int(r*255), int(g*255), int(b*255))
71
+
72
+ @mcp.tool()
73
+ def get_color_palette(primary_hex: str) -> str:
74
+ """
75
+ Provides color palette recommendations based on a primary hex code.
76
+
77
+ Args:
78
+ primary_hex: A 3 or 6-character hex string, e.g. '#3498db'
79
+ """
80
+ try:
81
+ r, g, b = hex_to_rgb(primary_hex)
82
+ except ValueError:
83
+ return "Invalid hex color format. Please provide a valid hex color like '#3498db'."
84
+
85
+ h, l, s = colorsys.rgb_to_hls(r, g, b)
86
+
87
+ # Calculate complementary
88
+ comp_h = (h + 0.5) % 1.0
89
+ r_c, g_c, b_c = colorsys.hls_to_rgb(comp_h, l, s)
90
+ complementary_hex = rgb_to_hex(r_c, g_c, b_c)
91
+
92
+ # Calculate analogous
93
+ an1_h = (h + 1/12) % 1.0
94
+ an2_h = (h - 1/12) % 1.0
95
+ r_a1, g_a1, b_a1 = colorsys.hls_to_rgb(an1_h, l, s)
96
+ r_a2, g_a2, b_a2 = colorsys.hls_to_rgb(an2_h, l, s)
97
+ analogous1_hex = rgb_to_hex(r_a1, g_a1, b_a1)
98
+ analogous2_hex = rgb_to_hex(r_a2, g_a2, b_a2)
99
+
100
+ return f"""Based on your primary color {primary_hex}, here are generated recommendations for a complete palette:
101
+
102
+ - Primary: {primary_hex}
103
+ - Secondary (Complementary): {complementary_hex}
104
+ - Analogous 1: {analogous1_hex}
105
+ - Analogous 2: {analogous2_hex}
106
+
107
+ - Background: #F8FAFC (Light Mode) or #0F172A (Dark Mode)
108
+ - Surface: #FFFFFF (Light Mode) or #1E293B (Dark Mode)
109
+ - Text Primary: #0F172A (Light Mode) or #F8FAFC (Dark Mode)
110
+ - Text Secondary: #64748B (Light Mode) or #94A3B8 (Dark Mode)
111
+ - Error: #EF4444
112
+ - Success: #22C55E
113
+
114
+ Tip: Ensure contrast ratios between text and backgrounds meet at least AA standards (4.5:1).
115
+ """
116
+
117
+
118
+ @mcp.tool()
119
+ def get_accessibility_checklist() -> str:
120
+ """Returns an essential frontend accessibility (a11y) checklist."""
121
+ return """Frontend Accessibility (a11y) Checklist:
122
+
123
+ 1. Semantic HTML:
124
+ - Use correct tags (e.g., <button> for actions, <a> for links).
125
+ - Use headings (<h1> to <h6>) in a logical, sequential order.
126
+
127
+ 2. Keyboard Navigation:
128
+ - Ensure all interactive elements are focusable via 'Tab'.
129
+ - Verify focus states are clearly visible (do not outline: none without a fallback).
130
+
131
+ 3. ARIA & Screen Readers:
132
+ - Provide `alt` text for all meaningful images. Use empty `alt=""` for decorative ones.
133
+ - Use `aria-labels` or visually hidden text when interactive elements lack text content (e.g., icon buttons).
134
+
135
+ 4. Color & Contrast:
136
+ - Check text-to-background contrast ratios (aim for 4.5:1 for normal text).
137
+ - Do not rely on color alone to convey information (e.g., error states should have text/icons).
138
+
139
+ 5. Forms:
140
+ - Associate `<label>` elements with their corresponding `<input>` via the `for` attribute.
141
+ - Provide clear error messages and associate them with the invalid input.
142
+ """
143
+
144
+
145
+ @mcp.tool()
146
+ def get_performance_tips(focus_area: str) -> str:
147
+ """
148
+ Returns performance optimization tips for specific frontend areas.
149
+
150
+ Args:
151
+ focus_area: The area to optimize (e.g., 'images', 'javascript', 'css')
152
+ """
153
+ focus = focus_area.lower()
154
+ if focus == "images":
155
+ return """Image Optimization Tips:
156
+ - Use modern formats like WebP or AVIF.
157
+ - Implement lazy loading (loading="lazy").
158
+ - Provide multiple sizes using `srcset` and `<picture>` tags.
159
+ - Compress images before uploading.
160
+ - Serve images via a CDN.
161
+ """
162
+ elif focus == "javascript":
163
+ return """JavaScript Optimization Tips:
164
+ - Code splitting: split bundles and load JS only when needed (e.g., dynamic imports).
165
+ - Tree shaking: remove unused code during the build process.
166
+ - Defer non-critical scripts (`defer` or `async` attributes).
167
+ - Optimize third-party scripts (e.g., analytics, ads).
168
+ - Minimize main thread work by moving heavy computations to Web Workers.
169
+ """
170
+ elif focus == "css":
171
+ return """CSS Optimization Tips:
172
+ - Extract critical CSS and inline it in the `<head>`.
173
+ - Defer non-critical CSS.
174
+ - Minify CSS in production.
175
+ - Avoid deeply nested selectors and overly complex rules.
176
+ - Remove unused CSS (tools like PurgeCSS).
177
+ """
178
+ else:
179
+ return "Unknown focus area. Try 'images', 'javascript', or 'css'."
180
+
181
+
182
+ @mcp.prompt()
183
+ def frontend_project_kickoff() -> str:
184
+ """A prompt to help users start thinking about a new frontend architecture."""
185
+ return """I am starting a new frontend project. Help me plan the architecture by asking me these questions one by one:
186
+
187
+ 1. What is the core purpose and scale of the application (e.g., simple landing page, complex dashboard, e-commerce)?
188
+ 2. What are the key non-functional requirements (e.g., SEO, initial load performance, offline capabilities)?
189
+ 3. What is the team's experience level with different frameworks and paradigms?
190
+ 4. Do we need a custom design system, or should we use an off-the-shelf component library?
191
+ 5. How will state be managed (local vs. global, server state vs. client state)?
192
+
193
+ Wait for my answer to each question before proceeding to the next.
194
+ """
195
+ @mcp.tool()
196
+ def get_agent_skill(skill_name: str) -> str:
197
+ """
198
+ Returns the content of a local agent skill based on the user input.
199
+
200
+ Args:
201
+ skill_name: The name of the skill to retrieve (e.g., 'frontend-design').
202
+ """
203
+ base_dir = os.path.dirname(os.path.abspath(__file__))
204
+ skill_path = os.path.join(base_dir, ".agents", "skills", skill_name, "SKILL.md")
205
+
206
+ if os.path.exists(skill_path):
207
+ with open(skill_path, "r", encoding="utf-8") as f:
208
+ return f.read()
209
+ else:
210
+ return f"Skill '{skill_name}' not found in the .agents/skills directory."
211
+
212
+
213
+ @mcp.tool()
214
+ def ask_gemini_cli(prompt: str) -> str:
215
+ """
216
+ Calls the locally installed Gemini CLI to process a prompt without needing an API key in the code.
217
+
218
+ Args:
219
+ prompt: The question or task to send to the Gemini CLI.
220
+ """
221
+ try:
222
+ caveman_prompt = f"{prompt}\n\n[SYSTEM INSTRUCTION: Answer in 'caveman mode'. Be ultra-concise. Drop articles (a/an/the) and filler words. Keep technical terms exact. Fragments OK.]"
223
+ result = subprocess.run(["gemini", caveman_prompt], capture_output=True, text=True, check=True)
224
+ return result.stdout.strip()
225
+ except subprocess.CalledProcessError as e:
226
+ return f"Error executing Gemini CLI: {e.stderr.strip() or e.stdout.strip()}"
227
+ except FileNotFoundError:
228
+ return "Gemini CLI is not installed or not found in the system PATH. Please install it first."
229
+
230
+
231
+ if __name__ == "__main__":
232
+ mcp.run()
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+