@claudeink/mcp-server 0.6.2 → 0.6.4
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 +44 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -82,21 +82,12 @@ async function getCredentials() {
|
|
|
82
82
|
if (!await fileExists(paths.credentials)) return null;
|
|
83
83
|
return readJson(paths.credentials, null);
|
|
84
84
|
}
|
|
85
|
-
async function saveCredentials(creds) {
|
|
86
|
-
const paths = getPaths();
|
|
87
|
-
await writeJson(paths.credentials, creds, true);
|
|
88
|
-
}
|
|
89
85
|
async function getConfig() {
|
|
90
86
|
const paths = getPaths();
|
|
91
87
|
const config = await readJson(paths.config, DEFAULT_CONFIG);
|
|
92
88
|
config.workflowDir = getWorkDir();
|
|
93
89
|
return config;
|
|
94
90
|
}
|
|
95
|
-
async function saveConfig(config) {
|
|
96
|
-
const paths = getPaths();
|
|
97
|
-
const current = await readJson(paths.config, DEFAULT_CONFIG);
|
|
98
|
-
await writeJson(paths.config, { ...current, ...config });
|
|
99
|
-
}
|
|
100
91
|
async function getTagQueue() {
|
|
101
92
|
const paths = getPaths();
|
|
102
93
|
return readJson(paths.tagQueue, DEFAULT_TAG_QUEUE);
|
|
@@ -751,6 +742,7 @@ var syncPushSchema = z5.object({
|
|
|
751
742
|
workDir: z5.string().optional().describe("\u5DE5\u4F5C\u76EE\u5F55\uFF08\u9ED8\u8BA4\u4F7F\u7528\u914D\u7F6E\u4E2D\u7684 workflowDir\uFF09")
|
|
752
743
|
});
|
|
753
744
|
async function syncPush(input) {
|
|
745
|
+
if (input.workDir) setWorkDir(input.workDir);
|
|
754
746
|
const creds = await getCredentials();
|
|
755
747
|
if (!creds?.token) {
|
|
756
748
|
return { success: false, message: "\u672A\u6FC0\u6D3B\uFF0C\u8BF7\u5148\u4F7F\u7528 workflow.init \u6FC0\u6D3B License" };
|
|
@@ -840,6 +832,7 @@ var syncPullSchema = z5.object({
|
|
|
840
832
|
workDir: z5.string().optional().describe("\u5DE5\u4F5C\u76EE\u5F55")
|
|
841
833
|
});
|
|
842
834
|
async function syncPull(input) {
|
|
835
|
+
if (input.workDir) setWorkDir(input.workDir);
|
|
843
836
|
const creds = await getCredentials();
|
|
844
837
|
if (!creds?.token) {
|
|
845
838
|
return { success: false, message: "\u672A\u6FC0\u6D3B\uFF0C\u8BF7\u5148\u4F7F\u7528 workflow.init \u6FC0\u6D3B License" };
|
|
@@ -941,7 +934,7 @@ async function syncPull(input) {
|
|
|
941
934
|
|
|
942
935
|
// src/tools/workflow.ts
|
|
943
936
|
import { z as z6 } from "zod";
|
|
944
|
-
import { cp, mkdir as mkdir6, access as access2 } from "fs/promises";
|
|
937
|
+
import { cp, mkdir as mkdir6, access as access2, writeFile as writeFile7 } from "fs/promises";
|
|
945
938
|
import { join as join8, dirname } from "path";
|
|
946
939
|
import { fileURLToPath } from "url";
|
|
947
940
|
var DEFAULT_API_BASE_URL = "https://app.claudeink.com";
|
|
@@ -956,6 +949,7 @@ async function workflowInit(input) {
|
|
|
956
949
|
const cwd = input.workDir;
|
|
957
950
|
const results = [];
|
|
958
951
|
try {
|
|
952
|
+
setWorkDir(cwd);
|
|
959
953
|
const items = ["CLAUDE.md", "base-rules.md", "platforms", "accounts", "tools"];
|
|
960
954
|
for (const item of items) {
|
|
961
955
|
const src = join8(WORKFLOW_SRC, item);
|
|
@@ -968,25 +962,33 @@ async function workflowInit(input) {
|
|
|
968
962
|
results.push(`\u2705 ${item}`);
|
|
969
963
|
}
|
|
970
964
|
}
|
|
965
|
+
const claudeinkDir = join8(cwd, ".claudeink");
|
|
971
966
|
const dirs = [
|
|
972
967
|
"sources/articles",
|
|
973
968
|
"sources/video-transcripts",
|
|
974
969
|
"sources/notes",
|
|
975
970
|
"sources/data",
|
|
976
971
|
"sources/daily",
|
|
977
|
-
"templates"
|
|
978
|
-
".claudeink"
|
|
972
|
+
"templates"
|
|
979
973
|
];
|
|
980
974
|
for (const dir of dirs) {
|
|
981
975
|
await mkdir6(join8(cwd, dir), { recursive: true });
|
|
982
976
|
}
|
|
977
|
+
await mkdir6(claudeinkDir, { recursive: true });
|
|
983
978
|
results.push("\u2705 \u8FD0\u884C\u65F6\u76EE\u5F55\u5DF2\u521B\u5EFA");
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
979
|
+
const configPath = join8(claudeinkDir, "config.json");
|
|
980
|
+
const statePath = join8(claudeinkDir, "state.json");
|
|
981
|
+
await writeFile7(configPath, JSON.stringify({
|
|
982
|
+
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
983
|
+
syncIntervalMs: 3e5,
|
|
984
|
+
heartbeatIntervalMs: 3e5,
|
|
985
|
+
maxTagQueueBatch: 20,
|
|
986
|
+
workflowDir: cwd
|
|
987
|
+
}, null, 2), "utf-8");
|
|
988
|
+
results.push("\u2705 config.json");
|
|
987
989
|
try {
|
|
988
990
|
await access2(statePath);
|
|
989
|
-
results.push("\u23ED\uFE0F \
|
|
991
|
+
results.push("\u23ED\uFE0F state.json \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");
|
|
990
992
|
} catch {
|
|
991
993
|
const emptyState = {
|
|
992
994
|
sources: {},
|
|
@@ -997,8 +999,8 @@ async function workflowInit(input) {
|
|
|
997
999
|
writingMasters: {},
|
|
998
1000
|
lastSyncAt: ""
|
|
999
1001
|
};
|
|
1000
|
-
await
|
|
1001
|
-
results.push("\u2705
|
|
1002
|
+
await writeFile7(statePath, JSON.stringify(emptyState, null, 2), "utf-8");
|
|
1003
|
+
results.push("\u2705 state.json");
|
|
1002
1004
|
}
|
|
1003
1005
|
let activated = false;
|
|
1004
1006
|
if (input.licenseKey) {
|
|
@@ -1011,13 +1013,17 @@ async function workflowInit(input) {
|
|
|
1011
1013
|
});
|
|
1012
1014
|
const data = await res.json();
|
|
1013
1015
|
if (data.userId) {
|
|
1014
|
-
await
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1016
|
+
await writeFile7(
|
|
1017
|
+
join8(claudeinkDir, "credentials.json"),
|
|
1018
|
+
JSON.stringify({
|
|
1019
|
+
licenseKey: input.licenseKey,
|
|
1020
|
+
token: data.token,
|
|
1021
|
+
userId: data.userId,
|
|
1022
|
+
plan: data.plan,
|
|
1023
|
+
expiresAt: data.expiresAt
|
|
1024
|
+
}, null, 2),
|
|
1025
|
+
{ mode: 384 }
|
|
1026
|
+
);
|
|
1021
1027
|
results.push(`\u2705 License \u6FC0\u6D3B\u6210\u529F\uFF08\u5957\u9910: ${data.plan}\uFF09`);
|
|
1022
1028
|
activated = true;
|
|
1023
1029
|
} else {
|
|
@@ -1058,8 +1064,7 @@ async function workflowInit(input) {
|
|
|
1058
1064
|
"",
|
|
1059
1065
|
"\u{1F3AF} \u4E0B\u4E00\u6B65\uFF1A",
|
|
1060
1066
|
"1. \u8BFB\u53D6 CLAUDE.md \u4E86\u89E3\u4E09\u5C42\u914D\u7F6E\u67B6\u6784",
|
|
1061
|
-
"2. \
|
|
1062
|
-
"3. \u4F7F\u7528 /\u7F16\u5199 \u5F00\u59CB\u5185\u5BB9\u521B\u4F5C"
|
|
1067
|
+
"2. \u5F00\u59CB\u5185\u5BB9\u521B\u4F5C"
|
|
1063
1068
|
].join("\n")
|
|
1064
1069
|
};
|
|
1065
1070
|
} catch (err) {
|
|
@@ -1071,9 +1076,11 @@ async function workflowInit(input) {
|
|
|
1071
1076
|
}
|
|
1072
1077
|
|
|
1073
1078
|
// src/index.ts
|
|
1079
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
1080
|
+
import { join as join9 } from "path";
|
|
1074
1081
|
var server = new McpServer({
|
|
1075
1082
|
name: "ClaudeInk",
|
|
1076
|
-
version: "0.6.
|
|
1083
|
+
version: "0.6.4"
|
|
1077
1084
|
});
|
|
1078
1085
|
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) => {
|
|
1079
1086
|
const result = await workflowInit(input);
|
|
@@ -1124,6 +1131,15 @@ server.tool("analytics.report", "\u83B7\u53D6\u6570\u636E\u5206\u6790\u62A5\u544
|
|
|
1124
1131
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1125
1132
|
});
|
|
1126
1133
|
async function main() {
|
|
1134
|
+
try {
|
|
1135
|
+
const configPath = join9(process.cwd(), ".claudeink", "config.json");
|
|
1136
|
+
const config = JSON.parse(await readFile7(configPath, "utf-8"));
|
|
1137
|
+
if (config.workflowDir) {
|
|
1138
|
+
setWorkDir(config.workflowDir);
|
|
1139
|
+
console.error(`[ClaudeInk MCP] workDir restored: ${config.workflowDir}`);
|
|
1140
|
+
}
|
|
1141
|
+
} catch {
|
|
1142
|
+
}
|
|
1127
1143
|
const transport = new StdioServerTransport();
|
|
1128
1144
|
await server.connect(transport);
|
|
1129
1145
|
console.error("[ClaudeInk MCP] Server started on stdio (12 tools)");
|