@scorehub/mcp-server 0.2.3 → 0.2.4
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.
- package/dist/index.js +9 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -129,10 +129,16 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
129
129
|
return new Promise((resolve) => {
|
|
130
130
|
let timeoutId;
|
|
131
131
|
const callbackServer = (0, node_http_1.createServer)((req, res) => {
|
|
132
|
-
if (timeoutId)
|
|
133
|
-
clearTimeout(timeoutId);
|
|
134
132
|
const requestUrl = req.url ?? "/";
|
|
135
133
|
const url = new URL(requestUrl, `http://127.0.0.1:${actualPort}`);
|
|
134
|
+
// 只处理 /callback 路径的请求,忽略浏览器探测请求(favicon、安全检查等)
|
|
135
|
+
if (url.pathname !== "/callback") {
|
|
136
|
+
res.writeHead(204);
|
|
137
|
+
res.end();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (timeoutId)
|
|
141
|
+
clearTimeout(timeoutId);
|
|
136
142
|
const code = url.searchParams.get("code");
|
|
137
143
|
if (code) {
|
|
138
144
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -171,6 +177,7 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
171
177
|
}));
|
|
172
178
|
}
|
|
173
179
|
else {
|
|
180
|
+
// 到达 /callback 但没有 code —— 真正的错误
|
|
174
181
|
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
175
182
|
res.end("<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Authorization Failed</title></head>" +
|
|
176
183
|
"<body style=\"font-family:sans-serif;text-align:center;padding-top:80px;\">" +
|