@claudeink/mcp-server 0.5.0 → 0.6.0
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 +113 -162
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
6
6
|
|
|
7
7
|
// src/tools/source.ts
|
|
8
8
|
import { z } from "zod";
|
|
9
|
-
import { mkdir as mkdir3 } from "fs/promises";
|
|
9
|
+
import { mkdir as mkdir3, readFile as readFile4 } from "fs/promises";
|
|
10
10
|
import { join as join4 } from "path";
|
|
11
11
|
|
|
12
12
|
// src/lib/config.ts
|
|
@@ -23,7 +23,7 @@ var PATHS = {
|
|
|
23
23
|
logs: join(CLAUDEINK_DIR, "logs")
|
|
24
24
|
};
|
|
25
25
|
var DEFAULT_CONFIG = {
|
|
26
|
-
apiBaseUrl: "https://
|
|
26
|
+
apiBaseUrl: "https://app.claudeink.com",
|
|
27
27
|
syncIntervalMs: 3e5,
|
|
28
28
|
// 5 minutes
|
|
29
29
|
heartbeatIntervalMs: 3e5,
|
|
@@ -39,9 +39,6 @@ var DEFAULT_TAG_QUEUE = {
|
|
|
39
39
|
avgTagsPerItem: 0
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
var DEFAULT_CRAWL_SCHEDULES = {
|
|
43
|
-
schedules: []
|
|
44
|
-
};
|
|
45
42
|
async function ensureDir() {
|
|
46
43
|
await mkdir(CLAUDEINK_DIR, { recursive: true });
|
|
47
44
|
await mkdir(PATHS.logs, { recursive: true });
|
|
@@ -82,9 +79,6 @@ async function getTagQueue() {
|
|
|
82
79
|
async function saveTagQueue(queue) {
|
|
83
80
|
await writeJson(PATHS.tagQueue, queue);
|
|
84
81
|
}
|
|
85
|
-
async function getCrawlSchedules() {
|
|
86
|
-
return readJson(PATHS.crawlSchedules, DEFAULT_CRAWL_SCHEDULES);
|
|
87
|
-
}
|
|
88
82
|
|
|
89
83
|
// src/lib/sources.ts
|
|
90
84
|
import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
@@ -166,6 +160,7 @@ var DEFAULT_STATE = {
|
|
|
166
160
|
published: {},
|
|
167
161
|
configs: {},
|
|
168
162
|
crawlerSources: {},
|
|
163
|
+
writingMasters: {},
|
|
169
164
|
lastSyncAt: ""
|
|
170
165
|
};
|
|
171
166
|
async function getStatePath() {
|
|
@@ -211,11 +206,6 @@ async function moveDraftToPublished(id, data) {
|
|
|
211
206
|
state.published[id] = data;
|
|
212
207
|
await writeState(state);
|
|
213
208
|
}
|
|
214
|
-
async function updateConfig(key, data) {
|
|
215
|
-
const state = await readState();
|
|
216
|
-
state.configs[key] = data;
|
|
217
|
-
await writeState(state);
|
|
218
|
-
}
|
|
219
209
|
async function updateCrawlerSource(id, data) {
|
|
220
210
|
const state = await readState();
|
|
221
211
|
state.crawlerSources[id] = data;
|
|
@@ -254,7 +244,13 @@ async function sourceAdd(input) {
|
|
|
254
244
|
const filePath = join4(dir, filename);
|
|
255
245
|
const meta = {
|
|
256
246
|
title: input.title,
|
|
257
|
-
source: input.url ?
|
|
247
|
+
source: input.url ? (() => {
|
|
248
|
+
try {
|
|
249
|
+
return new URL(input.url).hostname;
|
|
250
|
+
} catch {
|
|
251
|
+
return input.url;
|
|
252
|
+
}
|
|
253
|
+
})() : "manual",
|
|
258
254
|
published: date,
|
|
259
255
|
url: input.url
|
|
260
256
|
};
|
|
@@ -303,14 +299,21 @@ var sourceCrawlSchema = z.object({
|
|
|
303
299
|
sourceId: z.string().optional().describe("\u6307\u5B9A\u722C\u866B\u6E90\u540D\u79F0\uFF0C\u4E0D\u4F20\u5219\u5168\u91CF")
|
|
304
300
|
});
|
|
305
301
|
async function sourceCrawl(input) {
|
|
306
|
-
const
|
|
307
|
-
|
|
302
|
+
const config = await getConfig();
|
|
303
|
+
const configPath = join4(config.workflowDir || process.cwd(), "tools", "crawler", "config.json");
|
|
304
|
+
let crawlerConfig;
|
|
305
|
+
try {
|
|
306
|
+
crawlerConfig = JSON.parse(await readFile4(configPath, "utf-8"));
|
|
307
|
+
} catch {
|
|
308
|
+
crawlerConfig = { sources: [] };
|
|
309
|
+
}
|
|
310
|
+
if (crawlerConfig.sources.length === 0) {
|
|
308
311
|
return {
|
|
309
312
|
success: false,
|
|
310
313
|
message: "\u6682\u65E0\u914D\u7F6E\u722C\u866B\u6E90\u3002\u8BF7\u5148\u7528 source.subscribe \u6DFB\u52A0\u3002"
|
|
311
314
|
};
|
|
312
315
|
}
|
|
313
|
-
const targets = input.sourceId ?
|
|
316
|
+
const targets = input.sourceId ? crawlerConfig.sources.filter((s) => s.name === input.sourceId) : crawlerConfig.sources.filter((s) => s.enabled !== false);
|
|
314
317
|
if (targets.length === 0) {
|
|
315
318
|
return {
|
|
316
319
|
success: false,
|
|
@@ -420,7 +423,7 @@ async function sourceTagApply(input) {
|
|
|
420
423
|
|
|
421
424
|
// src/tools/subscribe.ts
|
|
422
425
|
import { z as z2 } from "zod";
|
|
423
|
-
import { readFile as
|
|
426
|
+
import { readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
|
|
424
427
|
import { join as join5 } from "path";
|
|
425
428
|
var sourceSubscribeSchema = z2.object({
|
|
426
429
|
action: z2.enum(["add", "remove", "list"]).describe("\u64CD\u4F5C\u7C7B\u578B"),
|
|
@@ -435,7 +438,7 @@ async function sourceSubscribe(input) {
|
|
|
435
438
|
const configPath = join5(config.workflowDir || process.cwd(), "tools/crawler/config.json");
|
|
436
439
|
let crawlerConfig;
|
|
437
440
|
try {
|
|
438
|
-
crawlerConfig = JSON.parse(await
|
|
441
|
+
crawlerConfig = JSON.parse(await readFile5(configPath, "utf-8"));
|
|
439
442
|
} catch {
|
|
440
443
|
crawlerConfig = { sources: [] };
|
|
441
444
|
}
|
|
@@ -488,7 +491,7 @@ async function sourceSubscribe(input) {
|
|
|
488
491
|
import { z as z3 } from "zod";
|
|
489
492
|
|
|
490
493
|
// src/lib/drafts.ts
|
|
491
|
-
import { readFile as
|
|
494
|
+
import { readFile as readFile6, writeFile as writeFile5, mkdir as mkdir4, unlink } from "fs/promises";
|
|
492
495
|
import { join as join6, basename } from "path";
|
|
493
496
|
import matter2 from "gray-matter";
|
|
494
497
|
import { glob as glob2 } from "glob";
|
|
@@ -533,7 +536,7 @@ async function saveDraft(options) {
|
|
|
533
536
|
return { filePath, meta, content: options.content };
|
|
534
537
|
}
|
|
535
538
|
async function publishDraft(options) {
|
|
536
|
-
const raw = await
|
|
539
|
+
const raw = await readFile6(options.file, "utf-8");
|
|
537
540
|
const { data, content } = matter2(raw);
|
|
538
541
|
const meta = data;
|
|
539
542
|
meta.status = "published";
|
|
@@ -683,6 +686,8 @@ async function analyticsPush(input) {
|
|
|
683
686
|
sources: [],
|
|
684
687
|
drafts: [],
|
|
685
688
|
published: [],
|
|
689
|
+
configs: [],
|
|
690
|
+
crawlerSources: [],
|
|
686
691
|
analytics: [payload]
|
|
687
692
|
});
|
|
688
693
|
if (!res.ok) {
|
|
@@ -704,114 +709,21 @@ var analyticsReportSchema = z4.object({
|
|
|
704
709
|
async function analyticsReport(input) {
|
|
705
710
|
return {
|
|
706
711
|
success: true,
|
|
707
|
-
message: "\u6570\u636E\u62A5\u544A\u529F\u80FD\u9700\u8981\u4E91\u7AEF Dashboard \u652F\u6301\uFF0C\u8BF7\u8BBF\u95EE https://app.claudeink.
|
|
712
|
+
message: "\u6570\u636E\u62A5\u544A\u529F\u80FD\u9700\u8981\u4E91\u7AEF Dashboard \u652F\u6301\uFF0C\u8BF7\u8BBF\u95EE https://app.claudeink.com \u67E5\u770B\u8BE6\u7EC6\u6570\u636E\u5206\u6790\u3002",
|
|
708
713
|
data: {
|
|
709
|
-
dashboardUrl: "https://app.claudeink.
|
|
714
|
+
dashboardUrl: "https://app.claudeink.com/analytics",
|
|
710
715
|
account: input.account,
|
|
711
716
|
period: input.period || "30d"
|
|
712
717
|
}
|
|
713
718
|
};
|
|
714
719
|
}
|
|
715
720
|
|
|
716
|
-
// src/tools/
|
|
721
|
+
// src/tools/sync.ts
|
|
717
722
|
import { z as z5 } from "zod";
|
|
718
|
-
import {
|
|
723
|
+
import { writeFile as writeFile6, mkdir as mkdir5 } from "fs/promises";
|
|
719
724
|
import { join as join7 } from "path";
|
|
720
|
-
var
|
|
721
|
-
|
|
722
|
-
platform: z5.string().describe("\u5E73\u53F0\u540D\u79F0\uFF0C\u5982 wechat, xiaohongshu"),
|
|
723
|
-
displayName: z5.string().optional().describe("\u663E\u793A\u540D\u79F0"),
|
|
724
|
-
domains: z5.array(z5.string()).describe("\u5185\u5BB9\u9886\u57DF"),
|
|
725
|
-
description: z5.string().optional().describe("\u8D26\u53F7\u5B9A\u4F4D\u63CF\u8FF0"),
|
|
726
|
-
profileUrl: z5.string().optional().describe("\u8D26\u53F7\u5728\u5E73\u53F0\u4E0A\u7684\u4E3B\u9875 URL")
|
|
727
|
-
});
|
|
728
|
-
async function accountCreate(input) {
|
|
729
|
-
const config = await getConfig();
|
|
730
|
-
const yamlPath = join7(config.workflowDir, "accounts", `${input.name}.yaml`);
|
|
731
|
-
try {
|
|
732
|
-
await readFile6(yamlPath);
|
|
733
|
-
return { success: false, message: `\u8D26\u53F7 ${input.name} \u5DF2\u5B58\u5728` };
|
|
734
|
-
} catch {
|
|
735
|
-
}
|
|
736
|
-
let template = "";
|
|
737
|
-
try {
|
|
738
|
-
template = await readFile6(
|
|
739
|
-
join7(config.workflowDir, "accounts", "_template.yaml"),
|
|
740
|
-
"utf-8"
|
|
741
|
-
);
|
|
742
|
-
} catch {
|
|
743
|
-
template = defaultTemplate();
|
|
744
|
-
}
|
|
745
|
-
const yamlContent = template.replace(/name:\s*""/, `name: "${input.displayName || input.name}"`).replace(/id:\s*""/, `id: "${input.name}"`).replace(/platform:\s*""/, `platform: "${input.platform}"`).replace(/profile_url:\s*""/, `profile_url: "${input.profileUrl || ""}"`).replace(/description:\s*""/, `description: "${input.description || ""}"`).replace(
|
|
746
|
-
/domains:\s*\n\s*- ""/,
|
|
747
|
-
`domains:
|
|
748
|
-
${input.domains.map((d) => ` - "${d}"`).join("\n")}`
|
|
749
|
-
);
|
|
750
|
-
await writeFile6(yamlPath, yamlContent, "utf-8");
|
|
751
|
-
const accountDir = join7(config.workflowDir, "accounts", input.name);
|
|
752
|
-
await mkdir5(join7(accountDir, "drafts"), { recursive: true });
|
|
753
|
-
await mkdir5(join7(accountDir, "published"), { recursive: true });
|
|
754
|
-
await mkdir5(join7(accountDir, "assets"), { recursive: true });
|
|
755
|
-
await updateConfig(`account:${input.name}`, {
|
|
756
|
-
type: "account",
|
|
757
|
-
name: input.name,
|
|
758
|
-
displayName: input.displayName || input.name,
|
|
759
|
-
content: yamlContent,
|
|
760
|
-
metadata: { platform: input.platform, profileUrl: input.profileUrl || "" },
|
|
761
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
762
|
-
});
|
|
763
|
-
return {
|
|
764
|
-
success: true,
|
|
765
|
-
message: `\u8D26\u53F7 ${input.name} \u5DF2\u521B\u5EFA
|
|
766
|
-
\u914D\u7F6E: accounts/${input.name}.yaml
|
|
767
|
-
\u76EE\u5F55: accounts/${input.name}/drafts/, published/, assets/`,
|
|
768
|
-
data: {
|
|
769
|
-
config: yamlPath,
|
|
770
|
-
directories: [
|
|
771
|
-
`accounts/${input.name}/drafts/`,
|
|
772
|
-
`accounts/${input.name}/published/`,
|
|
773
|
-
`accounts/${input.name}/assets/`
|
|
774
|
-
]
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
function defaultTemplate() {
|
|
779
|
-
return `# ClaudeInk \u8D26\u53F7\u914D\u7F6E
|
|
780
|
-
name: ""
|
|
781
|
-
id: ""
|
|
782
|
-
platform: ""
|
|
783
|
-
profile_url: ""
|
|
784
|
-
description: ""
|
|
785
|
-
|
|
786
|
-
domains:
|
|
787
|
-
- ""
|
|
788
|
-
|
|
789
|
-
style:
|
|
790
|
-
tone: "\u5E73\u5B9E"
|
|
791
|
-
voice: "\u53E3\u8BED\u5316"
|
|
792
|
-
formality: "medium"
|
|
793
|
-
emotion: "\u9002\u5EA6"
|
|
794
|
-
humor: "\u5076\u5C14"
|
|
795
|
-
language: "zh-CN"
|
|
796
|
-
|
|
797
|
-
persona:
|
|
798
|
-
role: ""
|
|
799
|
-
background: ""
|
|
800
|
-
first_person: "\u6211"
|
|
801
|
-
|
|
802
|
-
paths:
|
|
803
|
-
drafts: "accounts/{id}/drafts/"
|
|
804
|
-
published: "accounts/{id}/published/"
|
|
805
|
-
assets: "accounts/{id}/assets/"
|
|
806
|
-
`;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
// src/tools/sync.ts
|
|
810
|
-
import { z as z6 } from "zod";
|
|
811
|
-
import { writeFile as writeFile7 } from "fs/promises";
|
|
812
|
-
import { join as join8 } from "path";
|
|
813
|
-
var syncPushSchema = z6.object({
|
|
814
|
-
workDir: z6.string().optional().describe("\u5DE5\u4F5C\u76EE\u5F55\uFF08\u9ED8\u8BA4\u4F7F\u7528\u914D\u7F6E\u4E2D\u7684 workflowDir\uFF09")
|
|
725
|
+
var syncPushSchema = z5.object({
|
|
726
|
+
workDir: z5.string().optional().describe("\u5DE5\u4F5C\u76EE\u5F55\uFF08\u9ED8\u8BA4\u4F7F\u7528\u914D\u7F6E\u4E2D\u7684 workflowDir\uFF09")
|
|
815
727
|
});
|
|
816
728
|
async function syncPush(input) {
|
|
817
729
|
const creds = await getCredentials();
|
|
@@ -899,8 +811,8 @@ async function syncPush(input) {
|
|
|
899
811
|
return { success: false, message: `\u540C\u6B65\u7F51\u7EDC\u9519\u8BEF: ${err instanceof Error ? err.message : err}` };
|
|
900
812
|
}
|
|
901
813
|
}
|
|
902
|
-
var syncPullSchema =
|
|
903
|
-
workDir:
|
|
814
|
+
var syncPullSchema = z5.object({
|
|
815
|
+
workDir: z5.string().optional().describe("\u5DE5\u4F5C\u76EE\u5F55")
|
|
904
816
|
});
|
|
905
817
|
async function syncPull(input) {
|
|
906
818
|
const creds = await getCredentials();
|
|
@@ -925,37 +837,77 @@ async function syncPull(input) {
|
|
|
925
837
|
}
|
|
926
838
|
let updated = 0;
|
|
927
839
|
const state = await readState();
|
|
928
|
-
for (const
|
|
929
|
-
const stateKey = `${
|
|
840
|
+
for (const cfgItem of cloudData.configs) {
|
|
841
|
+
const stateKey = `${cfgItem.type}:${cfgItem.name}`;
|
|
930
842
|
const localUpdatedAt = state.configs[stateKey]?.updatedAt || "";
|
|
931
|
-
if (!localUpdatedAt ||
|
|
843
|
+
if (!localUpdatedAt || cfgItem.updatedAt > localUpdatedAt) {
|
|
932
844
|
let filePath = "";
|
|
933
|
-
if (
|
|
934
|
-
filePath =
|
|
935
|
-
} else if (
|
|
936
|
-
filePath =
|
|
937
|
-
} else if (
|
|
938
|
-
filePath =
|
|
845
|
+
if (cfgItem.type === "base_rules") {
|
|
846
|
+
filePath = join7(workDir, "base-rules.md");
|
|
847
|
+
} else if (cfgItem.type === "platform") {
|
|
848
|
+
filePath = join7(workDir, "platforms", `${cfgItem.name}.md`);
|
|
849
|
+
} else if (cfgItem.type === "account") {
|
|
850
|
+
filePath = join7(workDir, "accounts", `${cfgItem.name}.yaml`);
|
|
939
851
|
}
|
|
940
|
-
if (filePath &&
|
|
941
|
-
await
|
|
852
|
+
if (filePath && cfgItem.content) {
|
|
853
|
+
await writeFile6(filePath, cfgItem.content, "utf-8");
|
|
942
854
|
state.configs[stateKey] = {
|
|
943
|
-
type:
|
|
944
|
-
name:
|
|
945
|
-
displayName:
|
|
946
|
-
content:
|
|
947
|
-
metadata:
|
|
948
|
-
updatedAt:
|
|
855
|
+
type: cfgItem.type,
|
|
856
|
+
name: cfgItem.name,
|
|
857
|
+
displayName: cfgItem.displayName,
|
|
858
|
+
content: cfgItem.content,
|
|
859
|
+
metadata: cfgItem.metadata || {},
|
|
860
|
+
updatedAt: cfgItem.updatedAt
|
|
949
861
|
};
|
|
950
862
|
updated++;
|
|
951
863
|
}
|
|
952
864
|
}
|
|
953
865
|
}
|
|
866
|
+
let crawlerCount = 0;
|
|
867
|
+
state.crawlerSources = {};
|
|
868
|
+
for (const cfg of cloudData.configs || []) {
|
|
869
|
+
if (cfg.type === "crawler" && cfg.content) {
|
|
870
|
+
try {
|
|
871
|
+
const sources = JSON.parse(cfg.content);
|
|
872
|
+
for (const s of sources) {
|
|
873
|
+
state.crawlerSources[s.id] = {
|
|
874
|
+
name: s.name,
|
|
875
|
+
url: s.url,
|
|
876
|
+
type: s.type || "rss",
|
|
877
|
+
icon: s.icon || "",
|
|
878
|
+
enabled: s.enabled !== false
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
const crawlerDir = join7(workDir, "tools", "crawler");
|
|
882
|
+
await mkdir5(crawlerDir, { recursive: true });
|
|
883
|
+
const crawlerConfigPath = join7(crawlerDir, "config.json");
|
|
884
|
+
await writeFile6(crawlerConfigPath, JSON.stringify({ sources }, null, 2), "utf-8");
|
|
885
|
+
crawlerCount = sources.length;
|
|
886
|
+
} catch (e) {
|
|
887
|
+
console.error("[sync.pull] Failed to parse crawler sources:", e);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
if (cloudData.writingMasters && Object.keys(cloudData.writingMasters).length > 0) {
|
|
892
|
+
state.writingMasters = state.writingMasters || {};
|
|
893
|
+
for (const [accountName, master] of Object.entries(cloudData.writingMasters)) {
|
|
894
|
+
state.writingMasters[accountName] = {
|
|
895
|
+
id: master.id,
|
|
896
|
+
name: master.name,
|
|
897
|
+
stylePrompt: master.stylePrompt
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
}
|
|
954
901
|
await replaceState(state);
|
|
902
|
+
const masterCount = cloudData.writingMasters ? Object.keys(cloudData.writingMasters).length : 0;
|
|
955
903
|
return {
|
|
956
904
|
success: true,
|
|
957
|
-
message: updated > 0
|
|
958
|
-
|
|
905
|
+
message: updated > 0 || masterCount > 0 || crawlerCount > 0 ? [
|
|
906
|
+
`\u2705 \u4ECE\u4E91\u7AEF\u540C\u6B65\u4E86 ${updated} \u4E2A\u914D\u7F6E\u6587\u4EF6`,
|
|
907
|
+
crawlerCount > 0 ? ` \u8BA2\u9605\u6E90: ${crawlerCount} \u4E2A` : "",
|
|
908
|
+
masterCount > 0 ? ` \u5199\u4F5C\u5927\u5E08: ${masterCount} \u4E2A` : ""
|
|
909
|
+
].filter(Boolean).join("\n") : "\u672C\u5730\u914D\u7F6E\u5DF2\u662F\u6700\u65B0\uFF0C\u65E0\u9700\u66F4\u65B0",
|
|
910
|
+
data: { updated, crawlerSources: crawlerCount, writingMasters: masterCount }
|
|
959
911
|
};
|
|
960
912
|
} catch (err) {
|
|
961
913
|
return { success: false, message: `\u62C9\u53D6\u9519\u8BEF: ${err instanceof Error ? err.message : err}` };
|
|
@@ -963,16 +915,17 @@ async function syncPull(input) {
|
|
|
963
915
|
}
|
|
964
916
|
|
|
965
917
|
// src/tools/workflow.ts
|
|
966
|
-
import { z as
|
|
967
|
-
import { cp, mkdir as mkdir6, access as access2, writeFile as
|
|
968
|
-
import { join as
|
|
918
|
+
import { z as z6 } from "zod";
|
|
919
|
+
import { cp, mkdir as mkdir6, access as access2, writeFile as writeFile7 } from "fs/promises";
|
|
920
|
+
import { join as join8, dirname } from "path";
|
|
969
921
|
import { fileURLToPath } from "url";
|
|
922
|
+
var DEFAULT_API_BASE_URL = "https://app.claudeink.com";
|
|
970
923
|
var __filename = fileURLToPath(import.meta.url);
|
|
971
924
|
var __dirname = dirname(__filename);
|
|
972
|
-
var WORKFLOW_SRC =
|
|
973
|
-
var workflowInitSchema =
|
|
974
|
-
workDir:
|
|
975
|
-
licenseKey:
|
|
925
|
+
var WORKFLOW_SRC = join8(__dirname, "..", "workflow");
|
|
926
|
+
var workflowInitSchema = z6.object({
|
|
927
|
+
workDir: z6.string().describe("\u5DE5\u4F5C\u6D41\u521D\u59CB\u5316\u76EE\u6807\u76EE\u5F55\uFF08\u7EDD\u5BF9\u8DEF\u5F84\uFF09"),
|
|
928
|
+
licenseKey: z6.string().optional().describe("License Key\uFF08\u53EF\u9009\uFF0C\u4F20\u5165\u5219\u81EA\u52A8\u6FC0\u6D3B\uFF09")
|
|
976
929
|
});
|
|
977
930
|
async function workflowInit(input) {
|
|
978
931
|
const cwd = input.workDir;
|
|
@@ -980,8 +933,8 @@ async function workflowInit(input) {
|
|
|
980
933
|
try {
|
|
981
934
|
const items = ["CLAUDE.md", "base-rules.md", "platforms", "accounts", "tools"];
|
|
982
935
|
for (const item of items) {
|
|
983
|
-
const src =
|
|
984
|
-
const dest =
|
|
936
|
+
const src = join8(WORKFLOW_SRC, item);
|
|
937
|
+
const dest = join8(cwd, item);
|
|
985
938
|
try {
|
|
986
939
|
await access2(dest);
|
|
987
940
|
results.push(`\u23ED\uFE0F ${item} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7`);
|
|
@@ -1000,7 +953,7 @@ async function workflowInit(input) {
|
|
|
1000
953
|
".claudeink"
|
|
1001
954
|
];
|
|
1002
955
|
for (const dir of dirs) {
|
|
1003
|
-
await mkdir6(
|
|
956
|
+
await mkdir6(join8(cwd, dir), { recursive: true });
|
|
1004
957
|
}
|
|
1005
958
|
results.push("\u2705 \u8FD0\u884C\u65F6\u76EE\u5F55\u5DF2\u521B\u5EFA");
|
|
1006
959
|
const emptyState = {
|
|
@@ -1009,6 +962,7 @@ async function workflowInit(input) {
|
|
|
1009
962
|
published: {},
|
|
1010
963
|
configs: {},
|
|
1011
964
|
crawlerSources: {},
|
|
965
|
+
writingMasters: {},
|
|
1012
966
|
lastSyncAt: ""
|
|
1013
967
|
};
|
|
1014
968
|
await replaceState(emptyState);
|
|
@@ -1016,15 +970,16 @@ async function workflowInit(input) {
|
|
|
1016
970
|
let activated = false;
|
|
1017
971
|
if (input.licenseKey) {
|
|
1018
972
|
try {
|
|
1019
|
-
const
|
|
973
|
+
const activateUrl = `${DEFAULT_API_BASE_URL}/api/auth/activate`;
|
|
974
|
+
const res = await fetch(activateUrl, {
|
|
1020
975
|
method: "POST",
|
|
1021
976
|
headers: { "Content-Type": "application/json" },
|
|
1022
977
|
body: JSON.stringify({ key: input.licenseKey })
|
|
1023
978
|
});
|
|
1024
979
|
const data = await res.json();
|
|
1025
980
|
if (data.userId) {
|
|
1026
|
-
await
|
|
1027
|
-
|
|
981
|
+
await writeFile7(
|
|
982
|
+
join8(cwd, ".claudeink", "credentials.json"),
|
|
1028
983
|
JSON.stringify(data, null, 2),
|
|
1029
984
|
{ mode: 384 }
|
|
1030
985
|
);
|
|
@@ -1050,10 +1005,10 @@ async function workflowInit(input) {
|
|
|
1050
1005
|
}
|
|
1051
1006
|
}
|
|
1052
1007
|
try {
|
|
1053
|
-
await access2(
|
|
1008
|
+
await access2(join8(cwd, "tools", "crawler", "package.json"));
|
|
1054
1009
|
const { execSync } = await import("child_process");
|
|
1055
1010
|
execSync("npm install --silent", {
|
|
1056
|
-
cwd:
|
|
1011
|
+
cwd: join8(cwd, "tools", "crawler"),
|
|
1057
1012
|
stdio: "pipe"
|
|
1058
1013
|
});
|
|
1059
1014
|
results.push("\u2705 \u722C\u866B\u4F9D\u8D56\u5DF2\u5B89\u88C5");
|
|
@@ -1083,7 +1038,7 @@ async function workflowInit(input) {
|
|
|
1083
1038
|
// src/index.ts
|
|
1084
1039
|
var server = new McpServer({
|
|
1085
1040
|
name: "ClaudeInk",
|
|
1086
|
-
version: "0.
|
|
1041
|
+
version: "0.6.0"
|
|
1087
1042
|
});
|
|
1088
1043
|
server.tool("workflow.init", "\u521D\u59CB\u5316\u5199\u4F5C\u5DE5\u4F5C\u6D41\uFF08\u91CA\u653E\u4E09\u5C42\u914D\u7F6E + \u6FC0\u6D3B License + \u81EA\u52A8\u540C\u6B65\u4E91\u7AEF\u914D\u7F6E\uFF09", workflowInitSchema.shape, async (input) => {
|
|
1089
1044
|
const result = await workflowInit(input);
|
|
@@ -1133,14 +1088,10 @@ server.tool("analytics.report", "\u83B7\u53D6\u6570\u636E\u5206\u6790\u62A5\u544
|
|
|
1133
1088
|
const result = await analyticsReport(input);
|
|
1134
1089
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1135
1090
|
});
|
|
1136
|
-
server.tool("account.create", "\u521B\u5EFA\u65B0\u81EA\u5A92\u4F53\u8D26\u53F7", accountCreateSchema.shape, async (input) => {
|
|
1137
|
-
const result = await accountCreate(input);
|
|
1138
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1139
|
-
});
|
|
1140
1091
|
async function main() {
|
|
1141
1092
|
const transport = new StdioServerTransport();
|
|
1142
1093
|
await server.connect(transport);
|
|
1143
|
-
console.error("[ClaudeInk MCP] Server started on stdio (
|
|
1094
|
+
console.error("[ClaudeInk MCP] Server started on stdio (12 tools)");
|
|
1144
1095
|
}
|
|
1145
1096
|
main().catch((err) => {
|
|
1146
1097
|
console.error("[ClaudeInk MCP] Fatal error:", err);
|