glongus-mcp 0.3.0 → 0.3.1
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/package.json +1 -1
- package/src/index.js +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glongus-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "MCP server for the Glongus agent marketplace — search listings, check agent reputation, and make offers and haggle over physical goods",
|
|
5
5
|
"mcpName": "io.github.glongusmain/glongus-mcp",
|
|
6
6
|
"type": "module",
|
package/src/index.js
CHANGED
|
@@ -36,10 +36,21 @@ async function api(path, { method = 'GET', body, token } = {}) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// Agent tokens last 24h; cache one per process and re-auth when it's close
|
|
39
|
-
// to expiry or the API rejects it.
|
|
39
|
+
// to expiry or the API rejects it. Concurrent callers (e.g. a tool call and
|
|
40
|
+
// its piggybacked heartbeat) share one in-flight POST /auth rather than each
|
|
41
|
+
// minting a token.
|
|
40
42
|
let session = null;
|
|
43
|
+
let pendingAuth = null;
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
function getToken({ fresh = false } = {}) {
|
|
46
|
+
if (!fresh && session && Date.parse(session.expires_at) - Date.now() > 60_000) return Promise.resolve(session);
|
|
47
|
+
pendingAuth ??= authenticate().finally(() => {
|
|
48
|
+
pendingAuth = null;
|
|
49
|
+
});
|
|
50
|
+
return pendingAuth;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function authenticate() {
|
|
43
54
|
if (!API_KEY) {
|
|
44
55
|
throw new Error(
|
|
45
56
|
'No GLONGUS_API_KEY set. Authenticated actions (offers, photo uploads) need an owner API key (own_live_…). ' +
|
|
@@ -47,7 +58,6 @@ async function getToken({ fresh = false } = {}) {
|
|
|
47
58
|
'then set GLONGUS_API_KEY in this MCP server\'s env config. Read-only tools work without it.'
|
|
48
59
|
);
|
|
49
60
|
}
|
|
50
|
-
if (!fresh && session && Date.parse(session.expires_at) - Date.now() > 60_000) return session;
|
|
51
61
|
const res = await fetch(`${API_URL}/auth`, {
|
|
52
62
|
method: 'POST',
|
|
53
63
|
headers: { 'content-type': 'application/json', 'x-api-key': API_KEY },
|
|
@@ -138,7 +148,7 @@ const tool = (handler) => async (args) => {
|
|
|
138
148
|
return result;
|
|
139
149
|
};
|
|
140
150
|
|
|
141
|
-
const server = new McpServer({ name: 'glongus', version: '0.3.
|
|
151
|
+
const server = new McpServer({ name: 'glongus', version: '0.3.1' });
|
|
142
152
|
|
|
143
153
|
server.registerTool(
|
|
144
154
|
'search_listings',
|