sentinel-mcp 0.4.1 → 0.4.2
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 +24 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -114,6 +114,18 @@ async function refreshGithubToken() {
|
|
|
114
114
|
log(`Failed to refresh GitHub token: ${err.message}`);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
async function getTokenForRepo(repo) {
|
|
118
|
+
const httpUrl = RELAY_URL.replace("wss://", "https://").replace("ws://", "http://");
|
|
119
|
+
const tokenUrl = `${httpUrl}/api/token/by-repo/${repo}`;
|
|
120
|
+
const res = await fetch(tokenUrl, {
|
|
121
|
+
headers: { Authorization: `Bearer ${SENTINEL_TOKEN}` },
|
|
122
|
+
});
|
|
123
|
+
if (!res.ok) {
|
|
124
|
+
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
|
|
125
|
+
}
|
|
126
|
+
const data = (await res.json());
|
|
127
|
+
return data.token;
|
|
128
|
+
}
|
|
117
129
|
// ---------------------------------------------------------------------------
|
|
118
130
|
// API helper — proxy tool calls to remote MCP server via JSON-RPC
|
|
119
131
|
// ---------------------------------------------------------------------------
|
|
@@ -262,7 +274,18 @@ server.registerTool("fetch_image", {
|
|
|
262
274
|
issue_number: z.number().describe("Issue number where the image was posted"),
|
|
263
275
|
},
|
|
264
276
|
}, async ({ url, repo, issue_number }) => {
|
|
265
|
-
|
|
277
|
+
// Try with the default token first, then request a repo-specific token if it fails
|
|
278
|
+
let token = githubToken;
|
|
279
|
+
let result = await fetchImage(url, token, { repo, issueNumber: issue_number });
|
|
280
|
+
if (!result.ok) {
|
|
281
|
+
try {
|
|
282
|
+
token = await getTokenForRepo(repo);
|
|
283
|
+
result = await fetchImage(url, token, { repo, issueNumber: issue_number });
|
|
284
|
+
}
|
|
285
|
+
catch (err) {
|
|
286
|
+
log(`Failed to get repo-specific token for ${repo}: ${err.message}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
266
289
|
if (!result.ok) {
|
|
267
290
|
return {
|
|
268
291
|
content: [{ type: "text", text: `${result.error}. Ask the user to describe the image or paste it as text.` }],
|