@nexdoc/mcp-server 0.1.1 → 0.2.1
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/README.md +3 -1
- package/dist/client.d.ts +4 -0
- package/dist/client.js +5 -0
- package/dist/tools.js +29 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,7 +28,9 @@ Model Context Protocol server for [NexDoc Design](https://www.nexdoc.design).
|
|
|
28
28
|
|
|
29
29
|
## Tools
|
|
30
30
|
|
|
31
|
-
`create_design`, `update_design`, `check_run`, `refresh_preview`, `wait_for_run`, `list_runs`, `export_design`, `publish_design`, `unpublish_design`, `list_formats`, `get_balance`
|
|
31
|
+
`create_design`, `update_design`, `check_run`, `refresh_preview`, `wait_for_run`, `notify_run_email`, `list_runs`, `export_design`, `publish_design`, `unpublish_design`, `list_formats`, `get_balance`
|
|
32
|
+
|
|
33
|
+
`create_design` / `update_design` accept `notify_email: true` to email the account owner when the run finishes. `notify_run_email` does the same for a run that already started; if that run is already done, the tool returns a `warning` and no email is sent.
|
|
32
34
|
|
|
33
35
|
## Develop
|
|
34
36
|
|
package/dist/client.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type RunCreated = {
|
|
|
12
12
|
run_id: string;
|
|
13
13
|
status: string;
|
|
14
14
|
created_at: string;
|
|
15
|
+
notify_email?: boolean;
|
|
15
16
|
};
|
|
16
17
|
export type RunStatus = {
|
|
17
18
|
run_id: string;
|
|
@@ -37,6 +38,7 @@ export declare function createRunJson(jobId: string, body: {
|
|
|
37
38
|
file_id: string;
|
|
38
39
|
}>;
|
|
39
40
|
webhook_url?: string;
|
|
41
|
+
notify_email?: boolean;
|
|
40
42
|
}): Promise<RunCreated>;
|
|
41
43
|
export declare function createRunMultipart(jobId: string, opts: {
|
|
42
44
|
format?: string;
|
|
@@ -44,6 +46,7 @@ export declare function createRunMultipart(jobId: string, opts: {
|
|
|
44
46
|
content?: string;
|
|
45
47
|
contentPath?: string;
|
|
46
48
|
assetPaths?: string[];
|
|
49
|
+
notify_email?: boolean;
|
|
47
50
|
}): Promise<RunCreated>;
|
|
48
51
|
export declare function getRun(jobId: string, runId: string): Promise<RunStatus>;
|
|
49
52
|
export declare function listRuns(jobId: string): Promise<{
|
|
@@ -54,6 +57,7 @@ export declare function exportDesign(jobId: string, format: "pdf" | "html", runI
|
|
|
54
57
|
export declare function publishDesign(jobId: string, runId?: string): Promise<Record<string, unknown>>;
|
|
55
58
|
export declare function unpublishDesign(jobId: string): Promise<Record<string, unknown>>;
|
|
56
59
|
export declare function getPreviewLink(jobId: string): Promise<Record<string, unknown>>;
|
|
60
|
+
export declare function requestRunEmail(jobId: string, runId: string): Promise<Record<string, unknown>>;
|
|
57
61
|
export declare function getBalance(): Promise<Record<string, unknown>>;
|
|
58
62
|
export declare function waitForRun(jobId: string, runId: string, opts?: {
|
|
59
63
|
timeoutSec?: number;
|
package/dist/client.js
CHANGED
|
@@ -79,6 +79,8 @@ export async function createRunMultipart(jobId, opts) {
|
|
|
79
79
|
: "application/octet-stream";
|
|
80
80
|
form.append("files", new Blob([buf], { type }), name);
|
|
81
81
|
}
|
|
82
|
+
if (opts.notify_email)
|
|
83
|
+
form.set("notify_email", "true");
|
|
82
84
|
return request("POST", `/v1/jobs/${jobId}/runs`, { form });
|
|
83
85
|
}
|
|
84
86
|
export async function getRun(jobId, runId) {
|
|
@@ -103,6 +105,9 @@ export async function unpublishDesign(jobId) {
|
|
|
103
105
|
export async function getPreviewLink(jobId) {
|
|
104
106
|
return request("GET", `/v1/jobs/${jobId}/viewer/session`);
|
|
105
107
|
}
|
|
108
|
+
export async function requestRunEmail(jobId, runId) {
|
|
109
|
+
return request("POST", `/v1/jobs/${jobId}/runs/${runId}/notify-email`, { json: {} });
|
|
110
|
+
}
|
|
106
111
|
export async function getBalance() {
|
|
107
112
|
return request("GET", "/v1/credits");
|
|
108
113
|
}
|
package/dist/tools.js
CHANGED
|
@@ -43,6 +43,10 @@ export function registerTools(server) {
|
|
|
43
43
|
.optional()
|
|
44
44
|
.describe("If true, poll until terminal status before returning"),
|
|
45
45
|
timeout_sec: z.number().optional().describe("Wait timeout seconds (default 900)"),
|
|
46
|
+
notify_email: z
|
|
47
|
+
.boolean()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("If true, email the account owner when the run finishes (completed, failed, or cancelled). Use when you cannot poll for the full duration."),
|
|
46
50
|
}, async (args) => {
|
|
47
51
|
try {
|
|
48
52
|
let jobId = args.job_id;
|
|
@@ -58,11 +62,13 @@ export function registerTools(server) {
|
|
|
58
62
|
content: args.content,
|
|
59
63
|
contentPath: args.content_path,
|
|
60
64
|
assetPaths: args.asset_paths,
|
|
65
|
+
notify_email: args.notify_email,
|
|
61
66
|
})
|
|
62
67
|
: await api.createRunJson(jobId, {
|
|
63
68
|
format: args.format,
|
|
64
69
|
instructions: args.instructions,
|
|
65
70
|
content: args.content ?? "",
|
|
71
|
+
notify_email: args.notify_email,
|
|
66
72
|
});
|
|
67
73
|
if (args.wait) {
|
|
68
74
|
const final = await api.waitForRun(jobId, created.run_id, {
|
|
@@ -70,7 +76,13 @@ export function registerTools(server) {
|
|
|
70
76
|
});
|
|
71
77
|
return ok({ job_id: jobId, run: final });
|
|
72
78
|
}
|
|
73
|
-
return ok({
|
|
79
|
+
return ok({
|
|
80
|
+
job_id: jobId,
|
|
81
|
+
run_id: created.run_id,
|
|
82
|
+
status: created.status,
|
|
83
|
+
created_at: created.created_at,
|
|
84
|
+
notify_email: created.notify_email ?? false,
|
|
85
|
+
});
|
|
74
86
|
}
|
|
75
87
|
catch (err) {
|
|
76
88
|
return fail(err);
|
|
@@ -83,12 +95,17 @@ export function registerTools(server) {
|
|
|
83
95
|
content: z.string().optional(),
|
|
84
96
|
wait: z.boolean().optional(),
|
|
85
97
|
timeout_sec: z.number().optional(),
|
|
98
|
+
notify_email: z
|
|
99
|
+
.boolean()
|
|
100
|
+
.optional()
|
|
101
|
+
.describe("If true, email the account owner when the run finishes. Use when you cannot poll for the full duration."),
|
|
86
102
|
}, async (args) => {
|
|
87
103
|
try {
|
|
88
104
|
const created = await api.createRunJson(args.job_id, {
|
|
89
105
|
format: args.format,
|
|
90
106
|
instructions: args.instructions,
|
|
91
107
|
content: args.content ?? "",
|
|
108
|
+
notify_email: args.notify_email,
|
|
92
109
|
});
|
|
93
110
|
if (args.wait) {
|
|
94
111
|
const final = await api.waitForRun(args.job_id, created.run_id, {
|
|
@@ -121,6 +138,17 @@ export function registerTools(server) {
|
|
|
121
138
|
return fail(err);
|
|
122
139
|
}
|
|
123
140
|
});
|
|
141
|
+
server.tool("notify_run_email", "Request an email when an in-progress run finishes (completed, failed, or cancelled). Emails the authenticated account. If the run is already terminal, returns a warning and does not send.", {
|
|
142
|
+
job_id: z.string(),
|
|
143
|
+
run_id: z.string(),
|
|
144
|
+
}, async (args) => {
|
|
145
|
+
try {
|
|
146
|
+
return ok(await api.requestRunEmail(args.job_id, args.run_id));
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
return fail(err);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
124
152
|
server.tool("wait_for_run", "Poll a run until completed, failed, or cancelled (or timeout).", {
|
|
125
153
|
job_id: z.string(),
|
|
126
154
|
run_id: z.string(),
|