htmlgen-mcp 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of htmlgen-mcp might be problematic. Click here for more details.
- MCP/__init__.py +6 -0
- MCP/web_agent_server.py +1257 -0
- agents/__init__.py +6 -0
- agents/smart_web_agent.py +2384 -0
- agents/web_tools/__init__.py +84 -0
- agents/web_tools/bootstrap.py +49 -0
- agents/web_tools/browser.py +28 -0
- agents/web_tools/colors.py +137 -0
- agents/web_tools/css.py +1473 -0
- agents/web_tools/edgeone_deploy.py +541 -0
- agents/web_tools/html_templates.py +1770 -0
- agents/web_tools/images.py +600 -0
- agents/web_tools/images_fixed.py +195 -0
- agents/web_tools/js.py +235 -0
- agents/web_tools/navigation.py +386 -0
- agents/web_tools/project.py +34 -0
- agents/web_tools/simple_builder.py +346 -0
- agents/web_tools/simple_css.py +475 -0
- agents/web_tools/simple_js.py +454 -0
- agents/web_tools/simple_templates.py +220 -0
- agents/web_tools/validation.py +65 -0
- htmlgen_mcp-0.2.0.dist-info/METADATA +171 -0
- htmlgen_mcp-0.2.0.dist-info/RECORD +26 -0
- htmlgen_mcp-0.2.0.dist-info/WHEEL +5 -0
- htmlgen_mcp-0.2.0.dist-info/entry_points.txt +2 -0
- htmlgen_mcp-0.2.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"""简单网页工具 - 集成函数"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from .simple_templates import create_simple_html_file, create_blank_html_file, create_landing_page, create_blog_page
|
|
6
|
+
from .simple_css import create_clean_css_file, create_landing_css_file, create_blog_css_file, create_minimal_css_file
|
|
7
|
+
from .simple_js import create_simple_js_file, create_minimal_js_file, create_interactive_js_file
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def create_simple_website(
|
|
11
|
+
project_path: str,
|
|
12
|
+
site_type: str = "basic",
|
|
13
|
+
site_title: str = "我的网站"
|
|
14
|
+
) -> str:
|
|
15
|
+
"""创建完整的简单网站"""
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
project_dir = Path(project_path)
|
|
19
|
+
project_dir.mkdir(parents=True, exist_ok=True)
|
|
20
|
+
|
|
21
|
+
# 创建目录结构
|
|
22
|
+
(project_dir / "assets" / "css").mkdir(parents=True, exist_ok=True)
|
|
23
|
+
(project_dir / "assets" / "js").mkdir(parents=True, exist_ok=True)
|
|
24
|
+
|
|
25
|
+
if site_type == "basic":
|
|
26
|
+
# 基础网站
|
|
27
|
+
create_simple_html_file(
|
|
28
|
+
str(project_dir / "index.html"),
|
|
29
|
+
title=site_title
|
|
30
|
+
)
|
|
31
|
+
create_clean_css_file(str(project_dir / "assets" / "css" / "clean.css"))
|
|
32
|
+
create_simple_js_file(str(project_dir / "assets" / "js" / "main.js"))
|
|
33
|
+
|
|
34
|
+
elif site_type == "landing":
|
|
35
|
+
# 着陆页
|
|
36
|
+
create_landing_page(
|
|
37
|
+
str(project_dir / "index.html"),
|
|
38
|
+
title=site_title,
|
|
39
|
+
description="欢迎来到我们的网站"
|
|
40
|
+
)
|
|
41
|
+
create_landing_css_file(str(project_dir / "assets" / "css" / "landing.css"))
|
|
42
|
+
create_simple_js_file(str(project_dir / "assets" / "js" / "main.js"))
|
|
43
|
+
|
|
44
|
+
elif site_type == "blog":
|
|
45
|
+
# 博客网站
|
|
46
|
+
create_blog_page(
|
|
47
|
+
str(project_dir / "index.html"),
|
|
48
|
+
title=site_title
|
|
49
|
+
)
|
|
50
|
+
create_blog_css_file(str(project_dir / "assets" / "css" / "blog.css"))
|
|
51
|
+
create_interactive_js_file(str(project_dir / "assets" / "js" / "main.js"))
|
|
52
|
+
|
|
53
|
+
elif site_type == "minimal":
|
|
54
|
+
# 极简网站
|
|
55
|
+
create_blank_html_file(
|
|
56
|
+
str(project_dir / "index.html"),
|
|
57
|
+
title=site_title
|
|
58
|
+
)
|
|
59
|
+
create_minimal_css_file(str(project_dir / "assets" / "css" / "clean.css"))
|
|
60
|
+
create_minimal_js_file(str(project_dir / "assets" / "js" / "main.js"))
|
|
61
|
+
|
|
62
|
+
else:
|
|
63
|
+
return f"不支持的网站类型: {site_type}。支持的类型:basic, landing, blog, minimal"
|
|
64
|
+
|
|
65
|
+
return f"简单网站创建成功: {project_path} (类型: {site_type})"
|
|
66
|
+
|
|
67
|
+
except Exception as exc:
|
|
68
|
+
raise RuntimeError(f"创建简单网站失败: {str(exc)}")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def create_simple_page_set(
|
|
72
|
+
project_path: str,
|
|
73
|
+
site_title: str = "我的网站"
|
|
74
|
+
) -> str:
|
|
75
|
+
"""创建一套简单的多页面网站"""
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
project_dir = Path(project_path)
|
|
79
|
+
project_dir.mkdir(parents=True, exist_ok=True)
|
|
80
|
+
|
|
81
|
+
# 创建目录结构
|
|
82
|
+
(project_dir / "assets" / "css").mkdir(parents=True, exist_ok=True)
|
|
83
|
+
(project_dir / "assets" / "js").mkdir(parents=True, exist_ok=True)
|
|
84
|
+
|
|
85
|
+
# 首页
|
|
86
|
+
create_simple_html_file(
|
|
87
|
+
str(project_dir / "index.html"),
|
|
88
|
+
title=f"{site_title} - 首页",
|
|
89
|
+
content=f""" <header>
|
|
90
|
+
<h1>{site_title}</h1>
|
|
91
|
+
<nav>
|
|
92
|
+
<a href="index.html">首页</a>
|
|
93
|
+
<a href="about.html">关于我们</a>
|
|
94
|
+
<a href="services.html">服务</a>
|
|
95
|
+
<a href="contact.html">联系我们</a>
|
|
96
|
+
</nav>
|
|
97
|
+
</header>
|
|
98
|
+
|
|
99
|
+
<main>
|
|
100
|
+
<section class="hero">
|
|
101
|
+
<h2>欢迎访问{site_title}</h2>
|
|
102
|
+
<p>这里是我们的主页,展示我们的核心业务和服务。</p>
|
|
103
|
+
<a href="services.html" class="button">了解我们的服务</a>
|
|
104
|
+
</section>
|
|
105
|
+
|
|
106
|
+
<section>
|
|
107
|
+
<h3>我们的特色</h3>
|
|
108
|
+
<div class="features">
|
|
109
|
+
<div class="feature">
|
|
110
|
+
<h4>专业服务</h4>
|
|
111
|
+
<p>提供专业的解决方案</p>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="feature">
|
|
114
|
+
<h4>优质体验</h4>
|
|
115
|
+
<p>为客户提供优质的用户体验</p>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="feature">
|
|
118
|
+
<h4>可靠支持</h4>
|
|
119
|
+
<p>7x24小时技术支持</p>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
</section>
|
|
123
|
+
</main>
|
|
124
|
+
|
|
125
|
+
<footer>
|
|
126
|
+
<p>© 2024 {site_title}. 保留所有权利。</p>
|
|
127
|
+
</footer>"""
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
# 关于页面
|
|
131
|
+
create_simple_html_file(
|
|
132
|
+
str(project_dir / "about.html"),
|
|
133
|
+
title=f"{site_title} - 关于我们",
|
|
134
|
+
content=f""" <header>
|
|
135
|
+
<h1>{site_title}</h1>
|
|
136
|
+
<nav>
|
|
137
|
+
<a href="index.html">首页</a>
|
|
138
|
+
<a href="about.html">关于我们</a>
|
|
139
|
+
<a href="services.html">服务</a>
|
|
140
|
+
<a href="contact.html">联系我们</a>
|
|
141
|
+
</nav>
|
|
142
|
+
</header>
|
|
143
|
+
|
|
144
|
+
<main>
|
|
145
|
+
<section>
|
|
146
|
+
<h2>关于我们</h2>
|
|
147
|
+
<p>我们是一家专注于提供优质服务的公司。</p>
|
|
148
|
+
|
|
149
|
+
<h3>我们的故事</h3>
|
|
150
|
+
<p>成立于2020年,我们致力于为客户提供最好的解决方案。经过几年的发展,我们已经服务了众多客户,获得了良好的口碑。</p>
|
|
151
|
+
|
|
152
|
+
<h3>我们的团队</h3>
|
|
153
|
+
<p>我们拥有一支专业的团队,包括设计师、开发者、项目经理等,能够为客户提供全方位的服务。</p>
|
|
154
|
+
</section>
|
|
155
|
+
</main>
|
|
156
|
+
|
|
157
|
+
<footer>
|
|
158
|
+
<p>© 2024 {site_title}. 保留所有权利。</p>
|
|
159
|
+
</footer>"""
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# 服务页面
|
|
163
|
+
create_simple_html_file(
|
|
164
|
+
str(project_dir / "services.html"),
|
|
165
|
+
title=f"{site_title} - 服务",
|
|
166
|
+
content=f""" <header>
|
|
167
|
+
<h1>{site_title}</h1>
|
|
168
|
+
<nav>
|
|
169
|
+
<a href="index.html">首页</a>
|
|
170
|
+
<a href="about.html">关于我们</a>
|
|
171
|
+
<a href="services.html">服务</a>
|
|
172
|
+
<a href="contact.html">联系我们</a>
|
|
173
|
+
</nav>
|
|
174
|
+
</header>
|
|
175
|
+
|
|
176
|
+
<main>
|
|
177
|
+
<section>
|
|
178
|
+
<h2>我们的服务</h2>
|
|
179
|
+
<p>我们提供以下专业服务:</p>
|
|
180
|
+
|
|
181
|
+
<div class="services">
|
|
182
|
+
<div class="service">
|
|
183
|
+
<h3>网站设计</h3>
|
|
184
|
+
<p>专业的网站设计服务,为您打造独特的在线形象。</p>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div class="service">
|
|
188
|
+
<h3>应用开发</h3>
|
|
189
|
+
<p>移动应用和Web应用开发,满足您的业务需求。</p>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div class="service">
|
|
193
|
+
<h3>品牌设计</h3>
|
|
194
|
+
<p>完整的品牌视觉设计,提升您的品牌价值。</p>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div class="service">
|
|
198
|
+
<h3>技术咨询</h3>
|
|
199
|
+
<p>专业的技术咨询服务,帮助您做出正确的技术决策。</p>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
</section>
|
|
203
|
+
</main>
|
|
204
|
+
|
|
205
|
+
<footer>
|
|
206
|
+
<p>© 2024 {site_title}. 保留所有权利。</p>
|
|
207
|
+
</footer>"""
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
# 联系页面
|
|
211
|
+
create_simple_html_file(
|
|
212
|
+
str(project_dir / "contact.html"),
|
|
213
|
+
title=f"{site_title} - 联系我们",
|
|
214
|
+
content=f""" <header>
|
|
215
|
+
<h1>{site_title}</h1>
|
|
216
|
+
<nav>
|
|
217
|
+
<a href="index.html">首页</a>
|
|
218
|
+
<a href="about.html">关于我们</a>
|
|
219
|
+
<a href="services.html">服务</a>
|
|
220
|
+
<a href="contact.html">联系我们</a>
|
|
221
|
+
</nav>
|
|
222
|
+
</header>
|
|
223
|
+
|
|
224
|
+
<main>
|
|
225
|
+
<section>
|
|
226
|
+
<h2>联系我们</h2>
|
|
227
|
+
<p>有任何问题或需求,请随时联系我们。</p>
|
|
228
|
+
|
|
229
|
+
<div class="contact-info">
|
|
230
|
+
<h3>联系方式</h3>
|
|
231
|
+
<p><strong>邮箱:</strong>contact@example.com</p>
|
|
232
|
+
<p><strong>电话:</strong>+86 138 0000 0000</p>
|
|
233
|
+
<p><strong>地址:</strong>北京市朝阳区示例街道123号</p>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<form class="contact-form">
|
|
237
|
+
<h3>发送消息</h3>
|
|
238
|
+
|
|
239
|
+
<label for="name">姓名:</label>
|
|
240
|
+
<input type="text" id="name" name="name" required>
|
|
241
|
+
|
|
242
|
+
<label for="email">邮箱:</label>
|
|
243
|
+
<input type="email" id="email" name="email" required>
|
|
244
|
+
|
|
245
|
+
<label for="message">消息:</label>
|
|
246
|
+
<textarea id="message" name="message" rows="5" required></textarea>
|
|
247
|
+
|
|
248
|
+
<button type="submit">发送</button>
|
|
249
|
+
</form>
|
|
250
|
+
</section>
|
|
251
|
+
</main>
|
|
252
|
+
|
|
253
|
+
<footer>
|
|
254
|
+
<p>© 2024 {site_title}. 保留所有权利。</p>
|
|
255
|
+
</footer>"""
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
# 创建样式文件
|
|
259
|
+
create_clean_css_file(str(project_dir / "assets" / "css" / "clean.css"))
|
|
260
|
+
|
|
261
|
+
# 创建增强的CSS (添加特殊样式)
|
|
262
|
+
enhanced_css = """
|
|
263
|
+
/* 增强样式 */
|
|
264
|
+
.hero {
|
|
265
|
+
background-color: #f8f9fa;
|
|
266
|
+
padding: 3rem 1rem;
|
|
267
|
+
text-align: center;
|
|
268
|
+
margin: 2rem 0;
|
|
269
|
+
border-radius: 8px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.features {
|
|
273
|
+
display: grid;
|
|
274
|
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
275
|
+
gap: 2rem;
|
|
276
|
+
margin: 2rem 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.feature {
|
|
280
|
+
padding: 1.5rem;
|
|
281
|
+
background-color: #f8f9fa;
|
|
282
|
+
border-radius: 8px;
|
|
283
|
+
text-align: center;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.services {
|
|
287
|
+
display: grid;
|
|
288
|
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
289
|
+
gap: 2rem;
|
|
290
|
+
margin: 2rem 0;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.service {
|
|
294
|
+
padding: 2rem;
|
|
295
|
+
border: 1px solid #e9ecef;
|
|
296
|
+
border-radius: 8px;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.contact-info {
|
|
300
|
+
background-color: #f8f9fa;
|
|
301
|
+
padding: 2rem;
|
|
302
|
+
border-radius: 8px;
|
|
303
|
+
margin: 2rem 0;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.contact-form {
|
|
307
|
+
max-width: 600px;
|
|
308
|
+
margin: 2rem 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.contact-form label {
|
|
312
|
+
display: block;
|
|
313
|
+
margin: 1rem 0 0.5rem 0;
|
|
314
|
+
font-weight: 600;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.contact-form input,
|
|
318
|
+
.contact-form textarea {
|
|
319
|
+
width: 100%;
|
|
320
|
+
padding: 0.75rem;
|
|
321
|
+
border: 1px solid #ced4da;
|
|
322
|
+
border-radius: 4px;
|
|
323
|
+
font-size: 1rem;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.contact-form button {
|
|
327
|
+
margin-top: 1rem;
|
|
328
|
+
}"""
|
|
329
|
+
|
|
330
|
+
# 追加样式到CSS文件
|
|
331
|
+
with open(project_dir / "assets" / "css" / "clean.css", "a", encoding="utf-8") as f:
|
|
332
|
+
f.write(enhanced_css)
|
|
333
|
+
|
|
334
|
+
# 创建JavaScript文件
|
|
335
|
+
create_simple_js_file(str(project_dir / "assets" / "js" / "main.js"))
|
|
336
|
+
|
|
337
|
+
return f"简单多页面网站创建成功: {project_path} (包含4个页面)"
|
|
338
|
+
|
|
339
|
+
except Exception as exc:
|
|
340
|
+
raise RuntimeError(f"创建多页面网站失败: {str(exc)}")
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
__all__ = [
|
|
344
|
+
"create_simple_website",
|
|
345
|
+
"create_simple_page_set"
|
|
346
|
+
]
|