@line-harness/mcp-server 0.2.1 → 0.2.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 +37 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -891,14 +891,43 @@ import { z as z13 } from "zod";
|
|
|
891
891
|
function registerAccountSummary(server2) {
|
|
892
892
|
server2.tool(
|
|
893
893
|
"account_summary",
|
|
894
|
-
"Get a high-level summary of the LINE account: friend count, active scenarios, recent broadcasts, tags, and forms. Use this to understand the current state before making changes.",
|
|
894
|
+
"Get a high-level summary of the LINE account: friend count per account (DB + LINE API stats), active scenarios, recent broadcasts, tags, and forms. Use this to understand the current state before making changes.",
|
|
895
895
|
{
|
|
896
896
|
accountId: z13.string().optional().describe("LINE account ID (uses default if omitted)")
|
|
897
897
|
},
|
|
898
898
|
async ({ accountId }) => {
|
|
899
899
|
try {
|
|
900
900
|
const client = getClient();
|
|
901
|
-
const
|
|
901
|
+
const apiUrl = process.env.LINE_HARNESS_API_URL;
|
|
902
|
+
const apiKey = process.env.LINE_HARNESS_API_KEY;
|
|
903
|
+
const accountsRes = await fetch(`${apiUrl}/api/line-accounts`, {
|
|
904
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
905
|
+
});
|
|
906
|
+
const accountsData = await accountsRes.json();
|
|
907
|
+
const accounts = accountsData.success ? accountsData.data : [];
|
|
908
|
+
const accountStats = [];
|
|
909
|
+
for (const acc of accounts) {
|
|
910
|
+
const count = await client.friends.count({ accountId: acc.id });
|
|
911
|
+
accountStats.push({
|
|
912
|
+
id: acc.id,
|
|
913
|
+
name: acc.name,
|
|
914
|
+
channelId: acc.channelId,
|
|
915
|
+
friendsInDb: count
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
for (const acc of accountStats) {
|
|
919
|
+
try {
|
|
920
|
+
const healthRes = await fetch(`${apiUrl}/api/accounts/${acc.id}/health`, {
|
|
921
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
922
|
+
});
|
|
923
|
+
const healthData = await healthRes.json();
|
|
924
|
+
if (healthData.success) {
|
|
925
|
+
acc.riskLevel = healthData.data.riskLevel;
|
|
926
|
+
}
|
|
927
|
+
} catch {
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
const [totalFriends, scenarios, broadcasts, tags, forms] = await Promise.all([
|
|
902
931
|
client.friends.count({ accountId }),
|
|
903
932
|
client.scenarios.list({ accountId }),
|
|
904
933
|
client.broadcasts.list({ accountId }),
|
|
@@ -908,7 +937,11 @@ function registerAccountSummary(server2) {
|
|
|
908
937
|
const activeScenarios = scenarios.filter((s) => s.isActive);
|
|
909
938
|
const recentBroadcasts = broadcasts.slice(0, 5);
|
|
910
939
|
const summary = {
|
|
911
|
-
friends: {
|
|
940
|
+
friends: {
|
|
941
|
+
totalDbRecords: totalFriends,
|
|
942
|
+
note: "totalDbRecords includes both Account \u2460 and \u2461 records. Same user on different accounts = separate records. Use per-account counts below for accurate numbers.",
|
|
943
|
+
perAccount: accountStats
|
|
944
|
+
},
|
|
912
945
|
scenarios: {
|
|
913
946
|
total: scenarios.length,
|
|
914
947
|
active: activeScenarios.length,
|
|
@@ -924,7 +957,7 @@ function registerAccountSummary(server2) {
|
|
|
924
957
|
},
|
|
925
958
|
forms: {
|
|
926
959
|
total: forms.length,
|
|
927
|
-
list: forms.map((f) => ({ id: f.id, name: f.name }))
|
|
960
|
+
list: forms.map((f) => ({ id: f.id, name: f.name, submitCount: f.submitCount }))
|
|
928
961
|
}
|
|
929
962
|
};
|
|
930
963
|
return {
|