@troxy/cli 0.1.6 → 0.1.8
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/api.js +3 -0
- package/src/mcp-server.js +9 -1
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -47,6 +47,9 @@ export const api = {
|
|
|
47
47
|
|
|
48
48
|
// Evaluate (agent API key)
|
|
49
49
|
evaluate: (body, apiKey) => request('POST', '/evaluate', { apiKey, body }),
|
|
50
|
+
|
|
51
|
+
// MCP heartbeat (agent API key)
|
|
52
|
+
mcpHeartbeat: (apiKey) => request('POST', '/mcp/heartbeat', { apiKey }),
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
// Named export for backwards compat with init.js + mcp-server.js
|
package/src/mcp-server.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ListToolsRequestSchema,
|
|
6
6
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
7
7
|
import { loadConfig } from './config.js';
|
|
8
|
-
import { evaluatePayment } from './api.js';
|
|
8
|
+
import { evaluatePayment, api } from './api.js';
|
|
9
9
|
|
|
10
10
|
export async function runMcp() {
|
|
11
11
|
const config = loadConfig();
|
|
@@ -105,6 +105,14 @@ export async function runMcp() {
|
|
|
105
105
|
};
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
+
// Heartbeat: tell the dashboard this MCP server is active.
|
|
109
|
+
// Must be set up before server.connect() since stdio transport keeps the
|
|
110
|
+
// event loop running but connect() may not return in all environments.
|
|
111
|
+
const sendHeartbeat = () =>
|
|
112
|
+
api.mcpHeartbeat(apiKey).catch(() => {}); // silent — don't crash MCP on network error
|
|
113
|
+
sendHeartbeat();
|
|
114
|
+
setInterval(sendHeartbeat, 60_000);
|
|
115
|
+
|
|
108
116
|
const transport = new StdioServerTransport();
|
|
109
117
|
await server.connect(transport);
|
|
110
118
|
}
|