@line-harness/mcp-server 0.2.2 → 0.4.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.
@@ -0,0 +1,90 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { getClient } from "../client.js";
4
+
5
+ export function registerManageTags(server: McpServer): void {
6
+ server.tool(
7
+ "manage_tags",
8
+ "Create tags, add tags to friends, or remove tags from friends. Supports batch operations on multiple friends.",
9
+ {
10
+ action: z.enum(["create", "add", "remove"]).describe("Action to perform"),
11
+ tagName: z
12
+ .string()
13
+ .optional()
14
+ .describe("Tag name (for 'create' action)"),
15
+ tagColor: z
16
+ .string()
17
+ .optional()
18
+ .describe("Tag color hex code (for 'create' action, e.g. '#FF0000')"),
19
+ tagId: z
20
+ .string()
21
+ .optional()
22
+ .describe("Tag ID (for 'add' or 'remove' actions)"),
23
+ friendIds: z
24
+ .array(z.string())
25
+ .optional()
26
+ .describe(
27
+ "Friend IDs to add/remove the tag from (for 'add' or 'remove' actions)",
28
+ ),
29
+ },
30
+ async ({ action, tagName, tagColor, tagId, friendIds }) => {
31
+ try {
32
+ const client = getClient();
33
+
34
+ if (action === "create") {
35
+ if (!tagName) throw new Error("tagName is required for create action");
36
+ const tag = await client.tags.create({
37
+ name: tagName,
38
+ color: tagColor,
39
+ });
40
+ return {
41
+ content: [
42
+ {
43
+ type: "text" as const,
44
+ text: JSON.stringify({ success: true, tag }, null, 2),
45
+ },
46
+ ],
47
+ };
48
+ }
49
+
50
+ if (!tagId)
51
+ throw new Error("tagId is required for add/remove actions");
52
+ if (!friendIds?.length)
53
+ throw new Error("friendIds is required for add/remove actions");
54
+
55
+ const results: Array<{ friendId: string; status: string }> = [];
56
+ for (const friendId of friendIds) {
57
+ if (action === "add") {
58
+ await client.friends.addTag(friendId, tagId);
59
+ } else {
60
+ await client.friends.removeTag(friendId, tagId);
61
+ }
62
+ results.push({ friendId, status: "ok" });
63
+ }
64
+
65
+ return {
66
+ content: [
67
+ {
68
+ type: "text" as const,
69
+ text: JSON.stringify({ success: true, results }, null, 2),
70
+ },
71
+ ],
72
+ };
73
+ } catch (error) {
74
+ return {
75
+ content: [
76
+ {
77
+ type: "text" as const,
78
+ text: JSON.stringify(
79
+ { success: false, error: String(error) },
80
+ null,
81
+ 2,
82
+ ),
83
+ },
84
+ ],
85
+ isError: true,
86
+ };
87
+ }
88
+ },
89
+ );
90
+ }
@@ -0,0 +1,60 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { getClient } from "../client.js";
4
+
5
+ export function registerSendMessage(server: McpServer): void {
6
+ server.tool(
7
+ "send_message",
8
+ "Send a text or flex message to a specific friend. Use messageType 'flex' for rich card layouts.",
9
+ {
10
+ friendId: z.string().describe("The friend's ID to send the message to"),
11
+ content: z
12
+ .string()
13
+ .describe(
14
+ "Message content. For text: plain string. For flex: JSON string of LINE Flex Message.",
15
+ ),
16
+ messageType: z
17
+ .enum(["text", "flex"])
18
+ .default("text")
19
+ .describe(
20
+ "Message type: 'text' for plain text, 'flex' for Flex Message JSON",
21
+ ),
22
+ },
23
+ async ({ friendId, content, messageType }) => {
24
+ try {
25
+ const client = getClient();
26
+ const result = await client.friends.sendMessage(
27
+ friendId,
28
+ content,
29
+ messageType,
30
+ );
31
+ return {
32
+ content: [
33
+ {
34
+ type: "text" as const,
35
+ text: JSON.stringify(
36
+ { success: true, messageId: result.messageId },
37
+ null,
38
+ 2,
39
+ ),
40
+ },
41
+ ],
42
+ };
43
+ } catch (error) {
44
+ return {
45
+ content: [
46
+ {
47
+ type: "text" as const,
48
+ text: JSON.stringify(
49
+ { success: false, error: String(error) },
50
+ null,
51
+ 2,
52
+ ),
53
+ },
54
+ ],
55
+ isError: true,
56
+ };
57
+ }
58
+ },
59
+ );
60
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022"],
7
+ "outDir": "dist",
8
+ "rootDir": "src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true
17
+ },
18
+ "include": ["src/**/*.ts"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm"],
6
+ target: "node20",
7
+ outDir: "dist",
8
+ clean: true,
9
+ banner: {
10
+ js: "#!/usr/bin/env node",
11
+ },
12
+ });
package/README.md DELETED
@@ -1,63 +0,0 @@
1
- # @line-harness/mcp-server
2
-
3
- MCP Server for LINE Harness — operate LINE official accounts from Claude Code, Cursor, or any MCP-compatible AI tool via natural language.
4
-
5
- ## Quick Setup
6
-
7
- Add to your MCP config (`claude_desktop_config.json` for Claude Code, `mcp.json` for Cursor):
8
-
9
- ```json
10
- {
11
- "mcpServers": {
12
- "line-harness": {
13
- "command": "npx",
14
- "args": ["-y", "@line-harness/mcp-server"],
15
- "env": {
16
- "LINE_HARNESS_API_URL": "https://your-worker.your-subdomain.workers.dev",
17
- "LINE_HARNESS_API_KEY": "your_api_key"
18
- }
19
- }
20
- }
21
- }
22
- ```
23
-
24
- Restart your AI tool. The 14 LINE Harness tools will appear automatically.
25
-
26
- ## Available Tools
27
-
28
- | Tool | Description |
29
- |---|---|
30
- | `account_summary` | High-level overview: friend count, active scenarios, recent broadcasts, tags |
31
- | `list_friends` | List friends with optional tag filtering and pagination |
32
- | `get_friend_detail` | Detailed profile, tags, and metadata for a specific friend |
33
- | `send_message` | Send text or flex message to a specific friend |
34
- | `broadcast` | Send broadcast to all friends, a tag group, or a filtered segment |
35
- | `manage_tags` | Create tags, add/remove tags on friends (supports batch) |
36
- | `create_scenario` | Create a step-delivery scenario with delays and triggers |
37
- | `enroll_in_scenario` | Enroll a friend into a scenario manually |
38
- | `create_form` | Create a response-collection form with auto-tag on submit |
39
- | `get_form_submissions` | Retrieve all submissions for a form |
40
- | `create_tracked_link` | Create a click-tracking link with auto-tag on click |
41
- | `get_link_clicks` | Click analytics for a tracked link |
42
- | `create_rich_menu` | Create a LINE rich menu (persistent bottom menu) |
43
- | `list_crm_objects` | List scenarios, forms, tags, rich menus, tracked links, or broadcasts |
44
-
45
- ## Environment Variables
46
-
47
- | Variable | Description |
48
- |---|---|
49
- | `LINE_HARNESS_API_URL` | URL of your deployed Cloudflare Worker (e.g. `https://my-worker.workers.dev`) |
50
- | `LINE_HARNESS_API_KEY` | API key set as `API_KEY` secret on your Worker |
51
-
52
- ## Requirements
53
-
54
- - Node.js 20+
55
- - A running LINE Harness Worker ([deploy guide](https://github.com/Shudesu/line-harness-oss#quick-start))
56
-
57
- ## Main Repository
58
-
59
- [github.com/Shudesu/line-harness-oss](https://github.com/Shudesu/line-harness-oss)
60
-
61
- ## License
62
-
63
- MIT