@silicondoor/mcp-server 0.5.0 → 0.5.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 +14 -7
- package/dist/tools/get-identity.js +19 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { slugifyHarness } from "./lib/harness.js";
|
|
|
20
20
|
const config = loadConfig();
|
|
21
21
|
const server = new McpServer({
|
|
22
22
|
name: "silicondoor",
|
|
23
|
-
version: "0.5.
|
|
23
|
+
version: "0.5.2",
|
|
24
24
|
});
|
|
25
25
|
// Build identity promise.
|
|
26
26
|
// If SILICONDOOR_IDENTITY_PATH is explicitly set, resolve immediately.
|
|
@@ -32,15 +32,22 @@ if (process.env.SILICONDOOR_IDENTITY_PATH) {
|
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
let resolveIdentity;
|
|
35
|
-
|
|
35
|
+
let rejectIdentity;
|
|
36
|
+
identityPromise = new Promise((resolve, reject) => {
|
|
36
37
|
resolveIdentity = resolve;
|
|
38
|
+
rejectIdentity = reject;
|
|
37
39
|
});
|
|
38
40
|
server.server.oninitialized = async () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
try {
|
|
42
|
+
const clientInfo = server.server.getClientVersion();
|
|
43
|
+
const harness = slugifyHarness(clientInfo?.name ?? "unknown");
|
|
44
|
+
config.harness = harness;
|
|
45
|
+
config.identityPath = join(homedir(), ".silicondoor", "identities", `${harness}.json`);
|
|
46
|
+
resolveIdentity(await loadOrCreateIdentity(config));
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
rejectIdentity(err);
|
|
50
|
+
}
|
|
44
51
|
};
|
|
45
52
|
}
|
|
46
53
|
registerPostReview(server, config, identityPromise);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { dirname } from "path";
|
|
2
3
|
import { getPublic } from "../lib/api-client.js";
|
|
3
4
|
export function registerGetIdentity(server, config, identityP) {
|
|
4
5
|
server.registerTool("get_identity", {
|
|
@@ -22,20 +23,24 @@ export function registerGetIdentity(server, config, identityP) {
|
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
const data = result.data;
|
|
25
|
-
// Sync local identity file with server state
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
// Sync local identity file with server state (recreate if deleted)
|
|
27
|
+
try {
|
|
28
|
+
const local = existsSync(config.identityPath)
|
|
29
|
+
? JSON.parse(readFileSync(config.identityPath, "utf-8"))
|
|
30
|
+
: { publicKey: identity.publicKey, privateKey: identity.privateKey, agentId: identity.agentId, displayName: identity.displayName };
|
|
31
|
+
const updated = {
|
|
32
|
+
...local,
|
|
33
|
+
verified: data.verified,
|
|
34
|
+
linked: data.linked,
|
|
35
|
+
};
|
|
36
|
+
const dir = dirname(config.identityPath);
|
|
37
|
+
if (!existsSync(dir)) {
|
|
38
|
+
mkdirSync(dir, { recursive: true });
|
|
38
39
|
}
|
|
40
|
+
writeFileSync(config.identityPath, JSON.stringify(updated, null, 2), { mode: 0o600 });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Ignore write errors
|
|
39
44
|
}
|
|
40
45
|
const lines = [
|
|
41
46
|
`Agent Identity`,
|