bitcompass 0.2.1 → 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/commands/mcp.js +2 -4
- package/dist/mcp/server.js +19 -0
- package/package.json +1 -1
package/dist/commands/mcp.js
CHANGED
|
@@ -2,10 +2,8 @@ import chalk from 'chalk';
|
|
|
2
2
|
import { isLoggedIn } from '../auth/config.js';
|
|
3
3
|
import { startMcpServer } from '../mcp/server.js';
|
|
4
4
|
export const runMcpStart = async () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
process.exit(1);
|
|
8
|
-
}
|
|
5
|
+
// Do not exit when not logged in: Cursor needs the process to stay alive to complete
|
|
6
|
+
// the MCP handshake. Tools return an auth message (run bitcompass login, then restart MCP) when needed.
|
|
9
7
|
await startMcpServer();
|
|
10
8
|
};
|
|
11
9
|
export const runMcpStatus = () => {
|
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,
|