mdgen-mcp 0.1.1 → 0.1.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/client.js +0 -6
- package/dist/index.js +1 -6
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// mdgen backend(documents API)を PAT(Bearer)で叩く薄いクライアント。
|
|
2
|
-
// 認証・データ分離は API 側(#151 Phase 1)が担う。ここは HTTP 呼び出しとエラー整形のみ。
|
|
3
|
-
/** API エラー。status と人間可読メッセージを持つ。 */
|
|
4
1
|
export class MdgenApiError extends Error {
|
|
5
2
|
status;
|
|
6
3
|
constructor(status, message) {
|
|
@@ -41,7 +38,6 @@ export function createMdgenClient(baseUrl, token, fetchImpl = fetch) {
|
|
|
41
38
|
detail = body.error ?? body.code ?? "";
|
|
42
39
|
}
|
|
43
40
|
catch {
|
|
44
|
-
// non-JSON error body
|
|
45
41
|
}
|
|
46
42
|
const retryAfter = res.status === 429 ? res.headers.get("retry-after") : null;
|
|
47
43
|
throw new MdgenApiError(res.status, humanMessage(res.status, detail, retryAfter));
|
|
@@ -72,8 +68,6 @@ export function createMdgenClient(baseUrl, token, fetchImpl = fetch) {
|
|
|
72
68
|
});
|
|
73
69
|
return res.json();
|
|
74
70
|
},
|
|
75
|
-
// 指定フィールドのみ変更する。API の PUT は全項目を上書きするため、
|
|
76
|
-
// 既存を読んで未指定フィールドを保持してから送る(title/mode の消失を防ぐ)。
|
|
77
71
|
async updateDocument(id, patch) {
|
|
78
72
|
const current = (await (await request(`/api/documents/${encodeURIComponent(id)}`)).json());
|
|
79
73
|
await request(`/api/documents/${encodeURIComponent(id)}`, {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// mdgen MCP サーバ(#151)。
|
|
3
|
-
// ユーザー自身の MCP クライアント(Claude Desktop / Claude Code / Codex 等)から、
|
|
4
|
-
// ユーザーの PAT(MDGEN_TOKEN)で mdgen のドキュメントを読み書きする stdio サーバ。
|
|
5
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
4
|
import { z } from "zod";
|
|
@@ -14,7 +11,6 @@ if (!token) {
|
|
|
14
11
|
process.exit(1);
|
|
15
12
|
}
|
|
16
13
|
const client = createMdgenClient(apiUrl, token);
|
|
17
|
-
/** ツールハンドラ共通: 例外を人間可読なエラー結果に変換する。 */
|
|
18
14
|
async function run(fn) {
|
|
19
15
|
try {
|
|
20
16
|
return { content: [{ type: "text", text: await fn() }] };
|
|
@@ -28,7 +24,7 @@ async function run(fn) {
|
|
|
28
24
|
return { content: [{ type: "text", text: message }], isError: true };
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
const server = new McpServer({ name: "mdgen-mcp", version: "0.1.
|
|
27
|
+
const server = new McpServer({ name: "mdgen-mcp", version: "0.1.2" });
|
|
32
28
|
server.registerTool("list_documents", {
|
|
33
29
|
title: "List documents",
|
|
34
30
|
description: "List the current user's saved mdgen documents (id, title, mode, updatedAt).",
|
|
@@ -90,4 +86,3 @@ server.registerTool("delete_document", {
|
|
|
90
86
|
}));
|
|
91
87
|
const transport = new StdioServerTransport();
|
|
92
88
|
await server.connect(transport);
|
|
93
|
-
// stdio サーバはここで待機する(プロセスは MCP クライアントが管理)。
|