bitcompass 0.2.2 → 0.2.3
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/mcp/server.js +19 -0
- package/package.json +1 -1
package/dist/mcp/server.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AUTH_REQUIRED_MSG, insertRule, searchRules } from '../api/client.js';
|
|
2
2
|
import { loadCredentials } from '../auth/config.js';
|
|
3
|
+
/** When token is missing, we fail initialize so Cursor shows "Needs authentication" (yellow) instead of success (green). */
|
|
4
|
+
const NEEDS_AUTH_ERROR_MESSAGE = 'Needs authentication';
|
|
5
|
+
const NEEDS_AUTH_ERROR_CODE = -32001; // Server error: auth required
|
|
3
6
|
function createStdioServer() {
|
|
4
7
|
const handlers = new Map();
|
|
5
8
|
let requestId = 0;
|
|
@@ -16,6 +19,22 @@ function createStdioServer() {
|
|
|
16
19
|
if (isNotification)
|
|
17
20
|
return;
|
|
18
21
|
if (msg.method === 'initialize') {
|
|
22
|
+
const hasToken = Boolean(loadCredentials()?.access_token);
|
|
23
|
+
if (!hasToken) {
|
|
24
|
+
send({
|
|
25
|
+
jsonrpc: '2.0',
|
|
26
|
+
id,
|
|
27
|
+
error: {
|
|
28
|
+
code: NEEDS_AUTH_ERROR_CODE,
|
|
29
|
+
message: NEEDS_AUTH_ERROR_MESSAGE,
|
|
30
|
+
data: {
|
|
31
|
+
action: 'Login',
|
|
32
|
+
instructions: "Run `bitcompass login` in a terminal, then restart the MCP server in Cursor.",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
19
38
|
send({
|
|
20
39
|
jsonrpc: '2.0',
|
|
21
40
|
id,
|