@zyzy-org/blog-mcp-server 1.0.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.
- package/.env.example +14 -0
- package/LICENSE +21 -0
- package/PROJECT_STRUCTURE.md +67 -0
- package/PUBLISH_GUIDE.md +70 -0
- package/README.md +147 -0
- package/SETUP.md +96 -0
- package/USAGE.md +89 -0
- package/dist/blog-client.d.ts +9 -0
- package/dist/blog-client.d.ts.map +1 -0
- package/dist/blog-client.js +63 -0
- package/dist/blog-client.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +10 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +106 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +106 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/example-config.md +34 -0
- package/package.json +45 -0
- package/src/blog-client.ts +66 -0
- package/src/config.ts +56 -0
- package/src/index.ts +25 -0
- package/src/mcp-server.ts +113 -0
- package/src/tools.ts +104 -0
- package/src/types.ts +50 -0
- package/test-config.js +27 -0
- package/tsconfig.json +19 -0
package/src/tools.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { MCPTool } from './types';
|
|
2
|
+
|
|
3
|
+
export const tools: Record<string, MCPTool> = {
|
|
4
|
+
create_blog_post: {
|
|
5
|
+
name: "create_blog_post",
|
|
6
|
+
description: "在你的技术博客中创建新文章",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
title: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "文章标题"
|
|
13
|
+
},
|
|
14
|
+
content: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "文章内容,支持 Markdown 格式"
|
|
17
|
+
},
|
|
18
|
+
tags: {
|
|
19
|
+
type: "array",
|
|
20
|
+
items: {
|
|
21
|
+
type: "string"
|
|
22
|
+
},
|
|
23
|
+
description: "文章标签数组"
|
|
24
|
+
},
|
|
25
|
+
author: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "作者名称"
|
|
28
|
+
},
|
|
29
|
+
readTime: {
|
|
30
|
+
type: "number",
|
|
31
|
+
description: "预计阅读时间(分钟)"
|
|
32
|
+
},
|
|
33
|
+
date: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "发布日期(ISO 8601 格式)"
|
|
36
|
+
},
|
|
37
|
+
github_url: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "相关的 GitHub 链接"
|
|
40
|
+
},
|
|
41
|
+
slug: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "自定义文章 slug(可选)"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
required: ["title", "content"]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
create_multiple_blog_posts: {
|
|
50
|
+
name: "create_multiple_blog_posts",
|
|
51
|
+
description: "批量创建多篇博客文章",
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
articles: {
|
|
56
|
+
type: "array",
|
|
57
|
+
items: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: {
|
|
60
|
+
title: {
|
|
61
|
+
type: "string",
|
|
62
|
+
description: "文章标题"
|
|
63
|
+
},
|
|
64
|
+
content: {
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "文章内容(Markdown 格式)"
|
|
67
|
+
},
|
|
68
|
+
tags: {
|
|
69
|
+
type: "array",
|
|
70
|
+
items: {
|
|
71
|
+
type: "string"
|
|
72
|
+
},
|
|
73
|
+
description: "文章标签"
|
|
74
|
+
},
|
|
75
|
+
author: {
|
|
76
|
+
type: "string",
|
|
77
|
+
description: "作者名称"
|
|
78
|
+
},
|
|
79
|
+
readTime: {
|
|
80
|
+
type: "number",
|
|
81
|
+
description: "阅读时间(分钟)"
|
|
82
|
+
},
|
|
83
|
+
date: {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "发布日期"
|
|
86
|
+
},
|
|
87
|
+
github_url: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description: "GitHub 链接"
|
|
90
|
+
},
|
|
91
|
+
slug: {
|
|
92
|
+
type: "string",
|
|
93
|
+
description: "自定义 slug"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
required: ["title", "content"]
|
|
97
|
+
},
|
|
98
|
+
description: "要创建的文章数组"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
required: ["articles"]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface BlogPostData {
|
|
2
|
+
title: string;
|
|
3
|
+
content: string;
|
|
4
|
+
tags?: string[];
|
|
5
|
+
author?: string;
|
|
6
|
+
readTime?: number;
|
|
7
|
+
date?: string;
|
|
8
|
+
github_url?: string;
|
|
9
|
+
slug?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SecureBlogPostData extends BlogPostData {
|
|
13
|
+
client_id: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
signature?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface MCPConfig {
|
|
19
|
+
blogUrl: string;
|
|
20
|
+
secret: string;
|
|
21
|
+
clientId: string;
|
|
22
|
+
signatureSecret?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface MCPRequest {
|
|
26
|
+
jsonrpc: "2.0";
|
|
27
|
+
id: string | number;
|
|
28
|
+
method: string;
|
|
29
|
+
params?: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface MCPResponse {
|
|
33
|
+
jsonrpc: "2.0";
|
|
34
|
+
id: string | number;
|
|
35
|
+
result?: any;
|
|
36
|
+
error?: {
|
|
37
|
+
code: number;
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface MCPTool {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: string;
|
|
47
|
+
properties: Record<string, any>;
|
|
48
|
+
required?: string[];
|
|
49
|
+
};
|
|
50
|
+
}
|
package/test-config.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 测试配置是否正确加载
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { parseConfig } = require('./dist/config');
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
console.log('🔍 测试配置加载...');
|
|
11
|
+
|
|
12
|
+
const config = parseConfig();
|
|
13
|
+
|
|
14
|
+
console.log('✅ 配置加载成功!');
|
|
15
|
+
console.log('📋 配置详情:');
|
|
16
|
+
console.log(` 博客地址: ${config.blogUrl}`);
|
|
17
|
+
console.log(` 客户端ID: ${config.clientId}`);
|
|
18
|
+
console.log(` 密钥: ${config.secret ? '已配置' : '未配置'}`);
|
|
19
|
+
console.log(` 签名密钥: ${config.signatureSecret ? '已配置' : '未配置'}`);
|
|
20
|
+
|
|
21
|
+
console.log('\n🚀 配置验证通过,可以启动 MCP 服务器!');
|
|
22
|
+
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('❌ 配置加载失败:', error.message);
|
|
25
|
+
console.log('\n💡 请检查 .env 文件配置是否正确');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"resolveJsonModule": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|