htmlgen-mcp 0.3.7__tar.gz → 0.3.9__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.
Potentially problematic release.
This version of htmlgen-mcp might be problematic. Click here for more details.
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/PKG-INFO +1 -1
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/pyproject.toml +1 -1
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/web_agent_server.py +97 -119
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp.egg-info/PKG-INFO +1 -1
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/README.md +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/setup.cfg +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/__init__.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/__init__.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/ai_content_generator.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/quick_generator.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/smart_web_agent.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/__init__.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/bootstrap.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/browser.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/colors.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/css.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/edgeone_deploy.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/html_templates.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/html_templates_improved.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/images.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/images_fixed.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/js.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/navigation.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/project.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/simple_builder.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/simple_css.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/simple_js.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/simple_templates.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/validation.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/config.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/context_aware_executor.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/improved_progress.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/nas_log_manager.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/nas_storage.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/progress_tools.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/progress_tracker.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/prompt_enhancer.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/sse_optimizations.py +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp.egg-info/SOURCES.txt +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp.egg-info/dependency_links.txt +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp.egg-info/entry_points.txt +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp.egg-info/requires.txt +0 -0
- {htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "htmlgen-mcp"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.9"
|
|
8
8
|
description = "AI-powered HTML website generator with auto-upload functionality via Model Context Protocol"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -44,8 +44,8 @@ DEFAULT_PROJECT_ROOT = os.path.abspath(
|
|
|
44
44
|
)
|
|
45
45
|
# 是否自动生成项目子目录(可通过环境变量控制)
|
|
46
46
|
AUTO_CREATE_PROJECT_DIR = os.environ.get("AUTO_CREATE_PROJECT_DIR", "true").lower() == "true"
|
|
47
|
-
# 默认的文件上传URL
|
|
48
|
-
DEFAULT_UPLOAD_URL = "https://www.mcpcn.cc/api/fileUploadAndDownload/uploadMcpFile"
|
|
47
|
+
# 默认的文件上传URL(可通过环境变量 UPLOAD_URL 覆盖)
|
|
48
|
+
DEFAULT_UPLOAD_URL = os.environ.get("UPLOAD_URL", "https://www.mcpcn.cc/api/fileUploadAndDownload/uploadMcpFile")
|
|
49
49
|
DEFAULT_MODEL = os.environ.get("WEB_AGENT_MODEL", "qwen3-coder-plus-2025-09-23")
|
|
50
50
|
DEFAULT_BASE_URL = os.environ.get(
|
|
51
51
|
"OPENAI_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
|
@@ -82,6 +82,7 @@ _PROGRESS_LOG_BY_ID: dict[str, str] = {}
|
|
|
82
82
|
_PROGRESS_LOG_BY_JOB: dict[str, str] = {}
|
|
83
83
|
_JOB_REGISTRY: dict[str, Dict[str, Any]] = {}
|
|
84
84
|
_CONTEXT_CACHE_BY_ID: dict[str, Dict[str, Any]] = {}
|
|
85
|
+
_CONTEXT_ID_BY_PLAN: dict[str, str] = {}
|
|
85
86
|
|
|
86
87
|
|
|
87
88
|
def _job_state_path(job_id: str) -> Path:
|
|
@@ -140,6 +141,18 @@ def _load_job_states() -> None:
|
|
|
140
141
|
_load_job_states()
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
def _load_job_state_from_disk(job_id: str) -> Optional[Dict[str, Any]]:
|
|
145
|
+
path = _job_state_path(job_id)
|
|
146
|
+
if not path.exists():
|
|
147
|
+
return None
|
|
148
|
+
try:
|
|
149
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
150
|
+
data.setdefault("job_id", job_id)
|
|
151
|
+
return data
|
|
152
|
+
except Exception:
|
|
153
|
+
return None
|
|
154
|
+
|
|
155
|
+
|
|
143
156
|
def _context_cache_path(context_id: str) -> Path:
|
|
144
157
|
return CONTEXT_CACHE_DIR / f"{context_id}.json"
|
|
145
158
|
|
|
@@ -453,8 +466,6 @@ async def execute_plan(
|
|
|
453
466
|
# verbose: bool = False, # 后台执行时详细日志意义不大
|
|
454
467
|
save_output: bool = False,
|
|
455
468
|
progress_log: Optional[str] = None,
|
|
456
|
-
auto_upload: bool = False,
|
|
457
|
-
upload_url: Optional[str] = None,
|
|
458
469
|
) -> Dict[str, Any]:
|
|
459
470
|
"""执行网页构建计划,始终以后台模式运行。
|
|
460
471
|
|
|
@@ -479,21 +490,11 @@ async def execute_plan(
|
|
|
479
490
|
如果都未指定:不记录进度日志
|
|
480
491
|
路径可以是绝对路径或相对于 project_root 的相对路径
|
|
481
492
|
|
|
482
|
-
- auto_upload: 是否在构建完成后自动上传到MCP服务器
|
|
483
|
-
True: 构建完成后自动打包为ZIP并上传,返回访问URL
|
|
484
|
-
False: 仅构建,不上传
|
|
485
|
-
默认为 False
|
|
486
|
-
|
|
487
|
-
- upload_url: 文件上传API地址(可选)
|
|
488
|
-
默认为 "https://www.mcpcn.cc/api/fileUploadAndDownload/uploadMcpFile"
|
|
489
|
-
只在 auto_upload=True 时生效,一般不需要修改
|
|
490
|
-
|
|
491
493
|
执行流程:
|
|
492
494
|
- 任务始终在后台异步执行,立即返回 job_id 和 progress_log 路径
|
|
493
495
|
- 使用 get_progress(job_id=..., limit=...) 可以实时查询执行状态和进度
|
|
494
496
|
- 支持通过进度日志文件追踪详细的执行步骤和结果
|
|
495
|
-
-
|
|
496
|
-
- 🎯 新增:auto_upload=True时,构建完成(100%)后自动上传并返回访问URL
|
|
497
|
+
- 执行完成后可以获取完整的执行报告、生成文件列表,以及自动上传结果
|
|
497
498
|
"""
|
|
498
499
|
try:
|
|
499
500
|
# 如果没有提供project_root,尝试从缓存中获取
|
|
@@ -638,38 +639,26 @@ async def execute_plan(
|
|
|
638
639
|
|
|
639
640
|
_persist_job_state(job_id)
|
|
640
641
|
|
|
641
|
-
# 使用默认URL如果没有提供
|
|
642
|
-
effective_upload_url = upload_url or DEFAULT_UPLOAD_URL
|
|
643
|
-
|
|
644
642
|
asyncio.create_task(
|
|
645
643
|
_run_execution_job(
|
|
646
644
|
job_id,
|
|
647
645
|
agent,
|
|
648
646
|
plan_dict,
|
|
649
647
|
progress_log_path=progress_log_path,
|
|
650
|
-
auto_upload=auto_upload,
|
|
651
|
-
upload_url=effective_upload_url,
|
|
652
648
|
)
|
|
653
649
|
)
|
|
654
650
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
).format(job_id)
|
|
660
|
-
else:
|
|
661
|
-
message = (
|
|
662
|
-
"执行已在后台启动:调用 get_progress(job_id='{}', limit=20) "
|
|
663
|
-
"或传入 progress_log='{}' 可获取实时进度"
|
|
664
|
-
).format(job_id, progress_log_path or "<未启用进度日志>")
|
|
651
|
+
message = (
|
|
652
|
+
"执行已在后台启动(含自动上传):调用 get_progress(job_id='{}', limit=20) "
|
|
653
|
+
"或传入 progress_log='{}' 可获取实时进度与上传结果"
|
|
654
|
+
).format(job_id, progress_log_path or "<未启用进度日志>")
|
|
665
655
|
|
|
666
656
|
return {
|
|
667
657
|
"status": "started",
|
|
668
658
|
"job_id": job_id,
|
|
669
659
|
"plan_id": plan_id,
|
|
670
660
|
"progress_log": progress_log_path,
|
|
671
|
-
"
|
|
672
|
-
"upload_url": upload_url if auto_upload else None,
|
|
661
|
+
"upload_url": DEFAULT_UPLOAD_URL,
|
|
673
662
|
"message": message,
|
|
674
663
|
}
|
|
675
664
|
except Exception as exc:
|
|
@@ -686,8 +675,6 @@ async def _run_execution_job(
|
|
|
686
675
|
plan_dict: Dict[str, Any],
|
|
687
676
|
*,
|
|
688
677
|
progress_log_path: Optional[str],
|
|
689
|
-
auto_upload: bool = False,
|
|
690
|
-
upload_url: str = None,
|
|
691
678
|
) -> None:
|
|
692
679
|
job_info = _JOB_REGISTRY.get(job_id)
|
|
693
680
|
if not job_info:
|
|
@@ -705,52 +692,7 @@ async def _run_execution_job(
|
|
|
705
692
|
job_info["completed_at"] = time.time()
|
|
706
693
|
_persist_job_state(job_id)
|
|
707
694
|
|
|
708
|
-
|
|
709
|
-
if auto_upload and job_info.get("project_directory"):
|
|
710
|
-
try:
|
|
711
|
-
# 记录上传开始
|
|
712
|
-
job_info["upload_status"] = "uploading"
|
|
713
|
-
_persist_job_state(job_id)
|
|
714
|
-
|
|
715
|
-
# 只在不是默认值时传递upload_url
|
|
716
|
-
upload_params = {"folder_path": job_info["project_directory"]}
|
|
717
|
-
if upload_url and upload_url != DEFAULT_UPLOAD_URL:
|
|
718
|
-
upload_params["upload_url"] = upload_url
|
|
719
|
-
|
|
720
|
-
upload_result = await upload_project_to_mcp_server(**upload_params)
|
|
721
|
-
|
|
722
|
-
# 记录上传结果
|
|
723
|
-
job_info["upload_result"] = upload_result
|
|
724
|
-
job_info["upload_status"] = upload_result["status"]
|
|
725
|
-
if upload_result["status"] == "success":
|
|
726
|
-
job_info["website_url"] = upload_result["url"]
|
|
727
|
-
job_info["upload_completed_at"] = time.time()
|
|
728
|
-
|
|
729
|
-
# 添加到进度日志
|
|
730
|
-
if progress_log_path:
|
|
731
|
-
upload_event = {
|
|
732
|
-
"timestamp": time.time(),
|
|
733
|
-
"type": "upload_completed",
|
|
734
|
-
"status": "success",
|
|
735
|
-
"website_url": upload_result["url"],
|
|
736
|
-
"message": upload_result["message"],
|
|
737
|
-
}
|
|
738
|
-
try:
|
|
739
|
-
with open(
|
|
740
|
-
progress_log_path, "a", encoding="utf-8"
|
|
741
|
-
) as log_file:
|
|
742
|
-
log_file.write(
|
|
743
|
-
json.dumps(upload_event, ensure_ascii=False)
|
|
744
|
-
)
|
|
745
|
-
log_file.write("\n")
|
|
746
|
-
except Exception:
|
|
747
|
-
pass
|
|
748
|
-
|
|
749
|
-
_persist_job_state(job_id)
|
|
750
|
-
except Exception as upload_exc:
|
|
751
|
-
job_info["upload_status"] = "failed"
|
|
752
|
-
job_info["upload_error"] = str(upload_exc)
|
|
753
|
-
_persist_job_state(job_id)
|
|
695
|
+
await _handle_auto_upload(job_id, job_info, progress_log_path)
|
|
754
696
|
|
|
755
697
|
except Exception as exc:
|
|
756
698
|
job_info["status"] = "failed"
|
|
@@ -764,37 +706,70 @@ async def _run_execution_job(
|
|
|
764
706
|
_persist_job_state(job_id)
|
|
765
707
|
|
|
766
708
|
|
|
709
|
+
async def _handle_auto_upload(
|
|
710
|
+
job_id: str,
|
|
711
|
+
job_info: Dict[str, Any],
|
|
712
|
+
progress_log_path: Optional[str],
|
|
713
|
+
) -> None:
|
|
714
|
+
project_dir = job_info.get("project_directory")
|
|
715
|
+
if not project_dir:
|
|
716
|
+
return
|
|
717
|
+
|
|
718
|
+
job_info["upload_status"] = "uploading"
|
|
719
|
+
_persist_job_state(job_id)
|
|
720
|
+
|
|
721
|
+
try:
|
|
722
|
+
upload_result = await upload_project_to_mcp_server(
|
|
723
|
+
folder_path=project_dir,
|
|
724
|
+
upload_url=DEFAULT_UPLOAD_URL,
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
job_info["upload_result"] = upload_result
|
|
728
|
+
job_info["upload_status"] = upload_result.get("status")
|
|
729
|
+
|
|
730
|
+
if upload_result.get("status") == "success":
|
|
731
|
+
job_info["website_url"] = upload_result.get("url")
|
|
732
|
+
job_info["upload_completed_at"] = time.time()
|
|
733
|
+
|
|
734
|
+
if progress_log_path:
|
|
735
|
+
upload_event = {
|
|
736
|
+
"timestamp": time.time(),
|
|
737
|
+
"type": "upload_completed",
|
|
738
|
+
"status": "success",
|
|
739
|
+
"website_url": upload_result.get("url"),
|
|
740
|
+
"message": upload_result.get("message"),
|
|
741
|
+
}
|
|
742
|
+
try:
|
|
743
|
+
with open(progress_log_path, "a", encoding="utf-8") as log_file:
|
|
744
|
+
log_file.write(json.dumps(upload_event, ensure_ascii=False))
|
|
745
|
+
log_file.write("\n")
|
|
746
|
+
except Exception:
|
|
747
|
+
pass
|
|
748
|
+
|
|
749
|
+
except Exception as exc:
|
|
750
|
+
job_info["upload_status"] = "failed"
|
|
751
|
+
job_info["upload_error"] = str(exc)
|
|
752
|
+
finally:
|
|
753
|
+
_persist_job_state(job_id)
|
|
754
|
+
|
|
755
|
+
|
|
767
756
|
@mcp.tool()
|
|
768
757
|
async def create_simple_site(
|
|
769
758
|
description: str,
|
|
770
759
|
site_title: str = "我的网站",
|
|
771
|
-
project_root: Optional[str] = None,
|
|
772
|
-
model: Optional[str] = None,
|
|
773
|
-
context_id: Optional[str] = None,
|
|
774
760
|
context_content: Optional[str] = None,
|
|
775
761
|
) -> Dict[str, Any]:
|
|
776
762
|
"""使用AI分析需求,生成简单但美观的网站计划。
|
|
777
763
|
|
|
778
|
-
|
|
764
|
+
参数说明:
|
|
779
765
|
- description: 网站需求描述,例如"个人作品展示网站"、"小餐厅官网"、"博客网站"等
|
|
780
|
-
- site_title:
|
|
781
|
-
- context_content:
|
|
766
|
+
- site_title: 网站标题,默认为"我的网站"
|
|
767
|
+
- context_content: 可选,用于传递网页制作所需的所有原始数据内容
|
|
782
768
|
* 例如:咖啡馆列表、产品介绍、菜单内容、地址信息、营业时间等
|
|
783
769
|
* 这是AI获取具体业务信息的唯一渠道,请务必将查询到的详细信息完整传入
|
|
784
770
|
* 如果有地图查询结果、API返回数据等,都应该放在这个参数中
|
|
785
771
|
* 格式可以是文本、JSON字符串或结构化数据的字符串表示
|
|
786
772
|
|
|
787
|
-
其他参数:
|
|
788
|
-
- project_root: 项目根目录,缺省使用默认目录
|
|
789
|
-
- model: 使用的AI模型,缺省使用默认模型
|
|
790
|
-
- context_id: 可选,引用已缓存的上下文快照以复用历史资料
|
|
791
|
-
|
|
792
|
-
图片配置参数(可选):
|
|
793
|
-
- image_style: 图片风格 (professional|artistic|minimal|vibrant|luxury)
|
|
794
|
-
- image_topics: 用户自定义的图片主题列表,如 ["modern office", "team collaboration"]
|
|
795
|
-
- include_gallery: 是否在网站中包含图片画廊功能
|
|
796
|
-
- image_provider: 图片提供商 (pollinations|dicebear|robohash)
|
|
797
|
-
|
|
798
773
|
返回值说明:
|
|
799
774
|
- status: 操作状态 ("success" 或 "error")
|
|
800
775
|
- plan_id: 生成的计划唯一标识符,用于后续执行
|
|
@@ -813,22 +788,17 @@ async def create_simple_site(
|
|
|
813
788
|
这样AI就能基于真实数据来生成个性化的网站内容。
|
|
814
789
|
"""
|
|
815
790
|
try:
|
|
816
|
-
#
|
|
817
|
-
used_model =
|
|
791
|
+
# 使用默认模型
|
|
792
|
+
used_model = DEFAULT_MODEL
|
|
818
793
|
|
|
819
|
-
#
|
|
820
|
-
|
|
821
|
-
project_directory = _resolve_project_directory(project_root, site_title)
|
|
794
|
+
# 使用新的路径解析逻辑,默认在共享目录下按标题创建项目
|
|
795
|
+
project_directory = _resolve_project_directory(None, site_title)
|
|
822
796
|
|
|
823
797
|
# 处理上下文
|
|
824
798
|
context_data = ""
|
|
825
|
-
actual_context_id =
|
|
799
|
+
actual_context_id: Optional[str] = None
|
|
826
800
|
|
|
827
|
-
if
|
|
828
|
-
# 使用缓存的上下文
|
|
829
|
-
cached_context = _CONTEXT_CACHE_BY_ID[context_id]
|
|
830
|
-
context_data = cached_context.get("content", "")
|
|
831
|
-
elif context_content:
|
|
801
|
+
if context_content:
|
|
832
802
|
# 使用新提供的上下文内容
|
|
833
803
|
context_data = context_content
|
|
834
804
|
# 生成新的上下文ID并缓存
|
|
@@ -919,13 +889,16 @@ async def create_simple_site(
|
|
|
919
889
|
"plan_id": plan_id,
|
|
920
890
|
}
|
|
921
891
|
|
|
892
|
+
if actual_context_id:
|
|
893
|
+
cached_entry["context_id"] = actual_context_id
|
|
894
|
+
|
|
922
895
|
_PLAN_CACHE_BY_ID[plan_id] = cached_entry
|
|
923
896
|
cache_key = (project_directory, description)
|
|
924
897
|
_PLAN_CACHE[cache_key] = cached_entry
|
|
925
898
|
|
|
926
899
|
# 将上下文信息关联到计划
|
|
927
900
|
if actual_context_id:
|
|
928
|
-
|
|
901
|
+
_CONTEXT_ID_BY_PLAN[plan_id] = actual_context_id
|
|
929
902
|
|
|
930
903
|
# 保存计划到文件
|
|
931
904
|
plan_filename = f"simple_site_plan_{plan_id}.json"
|
|
@@ -1029,6 +1002,20 @@ async def get_progress(
|
|
|
1029
1002
|
|
|
1030
1003
|
if job_id:
|
|
1031
1004
|
job_info = _JOB_REGISTRY.get(job_id)
|
|
1005
|
+
if not job_info:
|
|
1006
|
+
disk_state = _load_job_state_from_disk(job_id)
|
|
1007
|
+
if disk_state:
|
|
1008
|
+
_JOB_REGISTRY[job_id] = disk_state
|
|
1009
|
+
job_info = disk_state
|
|
1010
|
+
progress_log_from_state = job_info.get("progress_log")
|
|
1011
|
+
if progress_log_from_state:
|
|
1012
|
+
progress_log_str = str(progress_log_from_state)
|
|
1013
|
+
_PROGRESS_LOG_BY_JOB[job_id] = progress_log_str
|
|
1014
|
+
plan_in_state = job_info.get("plan_id")
|
|
1015
|
+
if plan_in_state:
|
|
1016
|
+
_PROGRESS_LOG_BY_ID.setdefault(
|
|
1017
|
+
plan_in_state, progress_log_str
|
|
1018
|
+
)
|
|
1032
1019
|
if job_info and not plan_id:
|
|
1033
1020
|
plan_id = job_info.get("plan_id")
|
|
1034
1021
|
if job_id in _PROGRESS_LOG_BY_JOB:
|
|
@@ -1122,14 +1109,12 @@ async def get_progress(
|
|
|
1122
1109
|
"report": job_info.get("result", {}).get("report"),
|
|
1123
1110
|
"created_files": job_info.get("result", {}).get("created_files"),
|
|
1124
1111
|
}
|
|
1125
|
-
# 添加上传结果信息
|
|
1126
1112
|
if job_info.get("upload_result"):
|
|
1127
1113
|
job_snapshot["upload_result"] = job_info.get("upload_result")
|
|
1128
1114
|
|
|
1129
1115
|
if job_info.get("status") == "failed":
|
|
1130
1116
|
job_snapshot["error"] = job_info.get("error")
|
|
1131
1117
|
|
|
1132
|
-
# 添加上传错误信息
|
|
1133
1118
|
if job_info.get("upload_error"):
|
|
1134
1119
|
job_snapshot["upload_error"] = job_info.get("upload_error")
|
|
1135
1120
|
|
|
@@ -1147,15 +1132,11 @@ async def get_progress(
|
|
|
1147
1132
|
@mcp.tool()
|
|
1148
1133
|
async def upload_project_to_mcp_server(
|
|
1149
1134
|
folder_path: str,
|
|
1150
|
-
upload_url: Optional[str] = None,
|
|
1151
1135
|
) -> Dict[str, Any]:
|
|
1152
1136
|
"""将项目文件夹打包成ZIP并上传到MCP服务器。
|
|
1153
1137
|
|
|
1154
1138
|
参数说明:
|
|
1155
1139
|
- folder_path: 项目文件夹的绝对路径
|
|
1156
|
-
- upload_url: 上传API地址(可选)
|
|
1157
|
-
默认为 "https://www.mcpcn.cc/api/fileUploadAndDownload/uploadMcpFile"
|
|
1158
|
-
一般不需要修改
|
|
1159
1140
|
|
|
1160
1141
|
返回值:
|
|
1161
1142
|
- status: 上传状态 ("success" 或 "error")
|
|
@@ -1164,9 +1145,6 @@ async def upload_project_to_mcp_server(
|
|
|
1164
1145
|
- message: 状态信息
|
|
1165
1146
|
"""
|
|
1166
1147
|
try:
|
|
1167
|
-
# 使用默认URL如果没有提供
|
|
1168
|
-
effective_upload_url = upload_url or DEFAULT_UPLOAD_URL
|
|
1169
|
-
|
|
1170
1148
|
# 验证文件夹路径
|
|
1171
1149
|
if not os.path.exists(folder_path):
|
|
1172
1150
|
return {"status": "error", "message": f"项目文件夹不存在: {folder_path}"}
|
|
@@ -1206,7 +1184,7 @@ async def upload_project_to_mcp_server(
|
|
|
1206
1184
|
"file", f, filename=zip_filename, content_type="application/zip"
|
|
1207
1185
|
)
|
|
1208
1186
|
|
|
1209
|
-
async with session.post(
|
|
1187
|
+
async with session.post(DEFAULT_UPLOAD_URL, data=data) as response:
|
|
1210
1188
|
response_text = await response.text()
|
|
1211
1189
|
|
|
1212
1190
|
if response.status != 200:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/html_templates_improved.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{htmlgen_mcp-0.3.7 → htmlgen_mcp-0.3.9}/src/htmlgen_mcp/agents/web_tools/simple_templates.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|