Skip to content

Commit 159edcf

Browse files
dongdada29claude
andcommitted
fix(windows): use CREATE_NO_WINDOW constant instead of raw integer
process-wrap 9.0/8.2 的 CreationFlags 需要 PROCESS_CREATION_FLAGS 类型而非裸整数,导致 Windows CI 编译失败。改用 windows crate 的 CREATE_NO_WINDOW 常量。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0a83231 commit 159edcf

File tree

8 files changed

+25
-12
lines changed

8 files changed

+25
-12
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mcp-proxy/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ moka = { workspace = true, features = ["future"] }
7272
# 添加 job-object 特性用于 Windows 平台的进程树管理
7373
process-wrap = { version = "9.0", features = ["tokio1", "process-group", "job-object"] }
7474

75+
[target.'cfg(windows)'.dependencies]
76+
windows = { version = "0.61", features = ["Win32_System_Threading"] }
77+
7578
[[bin]]
7679
name = "mcp-proxy"
7780
path = "src/main.rs"

mcp-proxy/src/client/core/command.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ pub async fn run_command_mode(
113113
// Windows: 使用 Job Object 管理进程树,并隐藏控制台窗口
114114
#[cfg(windows)]
115115
{
116-
use process_wrap::CreationFlags;
117-
// CREATE_NO_WINDOW = 0x08000000
118-
// 隐藏控制台窗口,避免在 GUI 应用(如 Tauri)中显示 CMD 窗口
119-
wrapped_cmd.wrap(CreationFlags(0x08000000));
116+
use process_wrap::tokio::CreationFlags;
117+
use windows::Win32::System::Threading::CREATE_NO_WINDOW;
118+
wrapped_cmd.wrap(CreationFlags(CREATE_NO_WINDOW));
120119
wrapped_cmd.wrap(JobObject);
121120
}
122121
// 所有平台: Drop 时自动清理进程

mcp-sse-proxy/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ futures = { workspace = true }
5555
# 版本需要与 rmcp 0.10 兼容
5656
# 添加 process-group 特性用于 Unix 平台的进程组管理,job-object 用于 Windows 平台
5757
process-wrap = { version = "8.2", features = ["tokio1", "process-group", "job-object"] }
58+
59+
[target.'cfg(windows)'.dependencies]
60+
windows = { version = "0.61", features = ["Win32_System_Threading"] }

mcp-sse-proxy/src/server.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ use process_wrap::tokio::ProcessGroup;
2626
#[cfg(windows)]
2727
use process_wrap::tokio::{CreationFlags, JobObject};
2828

29+
#[cfg(windows)]
30+
use windows::Win32::System::Threading::CREATE_NO_WINDOW;
31+
2932
use crate::SseHandler;
3033

3134
/// 从配置启动 SSE 服务器
@@ -108,11 +111,9 @@ pub async fn run_sse_server_from_config(
108111
// Unix: 创建进程组,支持 killpg 清理整个进程树
109112
#[cfg(unix)]
110113
wrapped_cmd.wrap(ProcessGroup::leader());
111-
// Windows: 使用 CREATE_NO_WINDOW + Job Object 管理进程树并隐藏控制台窗口
112114
#[cfg(windows)]
113115
{
114-
// CREATE_NO_WINDOW = 0x08000000
115-
wrapped_cmd.wrap(CreationFlags(0x08000000));
116+
wrapped_cmd.wrap(CreationFlags(CREATE_NO_WINDOW));
116117
wrapped_cmd.wrap(JobObject);
117118
}
118119
// 所有平台: Drop 时自动清理进程

mcp-sse-proxy/src/server_builder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,8 @@ impl SseServerBuilder {
352352
#[cfg(windows)]
353353
{
354354
use process_wrap::tokio::CreationFlags;
355-
// CREATE_NO_WINDOW = 0x08000000
356-
// 隐藏控制台窗口,避免在 GUI 应用(如 Tauri)中显示 CMD 窗口
357-
wrapped_cmd.wrap(CreationFlags(0x08000000));
355+
use windows::Win32::System::Threading::CREATE_NO_WINDOW;
356+
wrapped_cmd.wrap(CreationFlags(CREATE_NO_WINDOW));
358357
wrapped_cmd.wrap(JobObject);
359358
}
360359

mcp-streamable-proxy/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ futures = { workspace = true }
6060
# 添加 process-group 特性用于 Unix 平台的进程组管理
6161
# 添加 job-object 特性用于 Windows 平台的进程树管理
6262
process-wrap = { version = "9.0", features = ["tokio1", "process-group", "job-object"] }
63+
64+
[target.'cfg(windows)'.dependencies]
65+
windows = { version = "0.61", features = ["Win32_System_Threading"] }

mcp-streamable-proxy/src/server.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ use process_wrap::tokio::ProcessGroup;
2828
#[cfg(windows)]
2929
use process_wrap::tokio::{CreationFlags, JobObject};
3030

31+
#[cfg(windows)]
32+
use windows::Win32::System::Threading::CREATE_NO_WINDOW;
33+
3134
use crate::{ProxyAwareSessionManager, ProxyHandler};
3235

3336
/// 从配置启动 Streamable HTTP 服务器
@@ -113,8 +116,7 @@ pub async fn run_stream_server_from_config(
113116
// Windows: 使用 CREATE_NO_WINDOW + Job Object 管理进程树并隐藏控制台窗口
114117
#[cfg(windows)]
115118
{
116-
// CREATE_NO_WINDOW = 0x08000000
117-
wrapped_cmd.wrap(CreationFlags(0x08000000));
119+
wrapped_cmd.wrap(CreationFlags(CREATE_NO_WINDOW));
118120
wrapped_cmd.wrap(JobObject);
119121
}
120122
// 所有平台: Drop 时自动清理进程

0 commit comments

Comments
 (0)