# 说在签名

NextChat2.16.0 之后的 Release 中不再提供桌面端构建,原因是添加了 MCP 服务器支持,此支持使用了 Next.js 的 ServerAction 功能,而此功能无法通过 yarn export 静态导出到网页,故在构建时发生了异常

# 太长不看

NextChat_2.16.1_x64-setup.exe

# 解决方案

禁用 MCP 服务器支持

# 步骤

  1. 安装 Rust 工具链
  2. 安装 Tauri 命令行工具
  3. Clone 仓库,安装 npm 依赖
  4. 创建 Tauri 秘钥
  5. 架空 MCP 函数
  6. 构建

# 安装 Tauri 命令行工具

1
cargo install create-tauri-app

# Clone 仓库,安装 npm 依赖

1
2
git clone https://github.com/ChatGPTNextWeb/NextChat.git
npm i

# 创建 Tauri 秘钥

1
npx tauri signer generate

之后会要求输入密码,并输出公钥与私钥

# 配置公钥

将输出的公钥填入 src-tauri\tauri.conf.jsontauri-pubkey

# 配置私钥

将私钥以及输入的密码记录到一个文件中,并添加一个环境变量 TAURI_PRIVATE_KEY 值为刚才输出的私钥。或者在终端使用指令

1
$env:TAURI_PRIVATE_KEY = "私钥内容"

# 架空 MCP 函数

修改 app\mcp\actions.ts 文件内容为以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"use client";
import {
createClient,
executeRequest,
listTools,
removeClient,
} from "./client";
import { MCPClientLogger } from "./logger";
import {
DEFAULT_MCP_CONFIG,
McpClientData,
McpConfigData,
McpRequestMessage,
ServerConfig,
ServerStatusResponse,
} from "./types";
import fs from "fs/promises";
import path from "path";
import { getServerSideConfig } from "../config/server";

const logger = new MCPClientLogger("MCP Actions");
const CONFIG_PATH = path.join(process.cwd(), "app/mcp/mcp_config.json");

const clientsMap = new Map<string, McpClientData>();

// 获取客户端状态
export async function getClientsStatus(): Promise<
Record<string, ServerStatusResponse>
> {
return {};
}

// 获取客户端工具
export async function getClientTools(clientId: string) {
return null;
}

// 获取可用客户端数量
export async function getAvailableClientsCount() {
let count = 0;
return count;
}

// 获取所有客户端工具
export async function getAllTools() {
const result = [];
for (const i in []) {
result.push({
clientId: '',
tools: { tools:[] },
});
}
return result;
}

// 初始化单个客户端
async function initializeSingleClient(
clientId: string,
serverConfig: ServerConfig,
) {
}

// 初始化系统
export async function initializeMcpSystem() {

}

// 添加服务器
export async function addMcpServer(clientId: string, config: ServerConfig) {
return {
mcpServers: {
},
}
}

// 暂停服务器
export async function pauseMcpServer(clientId: string) {
return {
mcpServers: {
},
}
}

// 恢复服务器
export async function resumeMcpServer(clientId: string): Promise<void> {

}

// 移除服务器
export async function removeMcpServer(clientId: string) {

}

// 重启所有客户端
export async function restartAllClients() {
return {
mcpServers: {
},
}
}

// 执行 MCP 请求
export async function executeMcpAction(
clientId: string,
request: McpRequestMessage,
) {

}

// 获取 MCP 配置文件
export async function getMcpConfigFromFile(): Promise<McpConfigData> {
return {mcpServers: {}};
}

// 更新 MCP 配置文件
async function updateMcpConfig(config: McpConfigData): Promise<void> {

}

// 检查 MCP 是否启用
export async function isMcpEnabled() {
return false;
}

# 构建

1
npx tauri build

期间要求输入私钥密码