@zyzy-org/blog-mcp-server 1.0.0 → 1.0.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/DEPLOYMENT.md +99 -0
- package/README.md +202 -97
- package/README_CN.md +252 -0
- package/package.json +1 -1
- package/PROJECT_STRUCTURE.md +0 -67
- package/PUBLISH_GUIDE.md +0 -70
- package/SETUP.md +0 -96
- package/USAGE.md +0 -89
- package/example-config.md +0 -34
package/DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# 部署说明 / Deployment Guide
|
|
2
|
+
|
|
3
|
+
## 中文版 / Chinese Version
|
|
4
|
+
|
|
5
|
+
### 发布到 npm
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 构建项目
|
|
9
|
+
npm run build
|
|
10
|
+
|
|
11
|
+
# 发布包
|
|
12
|
+
npm run publish-package
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 发布到 GitHub
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 初始化 Git 仓库(如果还没有)
|
|
19
|
+
git init
|
|
20
|
+
|
|
21
|
+
# 添加文件
|
|
22
|
+
git add .
|
|
23
|
+
|
|
24
|
+
# 提交更改
|
|
25
|
+
git commit -m "Initial commit: Blog MCP Server"
|
|
26
|
+
|
|
27
|
+
# 添加远程仓库
|
|
28
|
+
git remote add origin https://github.com/zyzy-org/blog-mcp-server.git
|
|
29
|
+
|
|
30
|
+
# 推送到 GitHub
|
|
31
|
+
git push -u origin main
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 注意事项
|
|
35
|
+
|
|
36
|
+
1. **敏感信息保护** - 确保 `.env` 文件已添加到 `.gitignore`
|
|
37
|
+
2. **环境变量** - 所有敏感配置都通过环境变量管理
|
|
38
|
+
3. **私人服务** - 这是私人 MCP 服务,不对外公开
|
|
39
|
+
4. **测试** - 发布前请确保所有功能正常工作
|
|
40
|
+
|
|
41
|
+
### 版本更新
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# 更新版本号
|
|
45
|
+
npm version patch # 或 minor, major
|
|
46
|
+
|
|
47
|
+
# 重新发布
|
|
48
|
+
npm run publish-package
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## English Version
|
|
54
|
+
|
|
55
|
+
### Publishing to npm
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Build the project
|
|
59
|
+
npm run build
|
|
60
|
+
|
|
61
|
+
# Publish the package
|
|
62
|
+
npm run publish-package
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Publishing to GitHub
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Initialize Git repository (if not already done)
|
|
69
|
+
git init
|
|
70
|
+
|
|
71
|
+
# Add files
|
|
72
|
+
git add .
|
|
73
|
+
|
|
74
|
+
# Commit changes
|
|
75
|
+
git commit -m "Initial commit: Blog MCP Server"
|
|
76
|
+
|
|
77
|
+
# Add remote repository
|
|
78
|
+
git remote add origin https://github.com/zyzy-org/blog-mcp-server.git
|
|
79
|
+
|
|
80
|
+
# Push to GitHub
|
|
81
|
+
git push -u origin main
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Important Notes
|
|
85
|
+
|
|
86
|
+
1. **Sensitive Information Protection** - Ensure `.env` file is added to `.gitignore`
|
|
87
|
+
2. **Environment Variables** - All sensitive configurations are managed through environment variables
|
|
88
|
+
3. **Private Service** - This is a private MCP service, not publicly available
|
|
89
|
+
4. **Testing** - Please ensure all functionality works properly before publishing
|
|
90
|
+
|
|
91
|
+
### Version Updates
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Update version number
|
|
95
|
+
npm version patch # or minor, major
|
|
96
|
+
|
|
97
|
+
# Republish
|
|
98
|
+
npm run publish-package
|
|
99
|
+
```
|
package/README.md
CHANGED
|
@@ -1,147 +1,252 @@
|
|
|
1
1
|
# Blog MCP Server
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[README.md for Chinese version](./README.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
</div>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
> Private MCP Server - Let AI assistants create articles directly in your tech blog
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
This is a private MCP (Model Context Protocol) server customized for your blog, allowing AI assistants (such as Cursor, Claude, etc.) to create articles directly in your tech blog without manual editing.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- 📝 **Markdown 支持**: 支持完整的 Markdown 格式
|
|
15
|
-
- 🏷️ **标签管理**: 自动创建和管理文章标签
|
|
16
|
-
- 🔒 **安全认证**: 支持签名验证和客户端白名单
|
|
17
|
-
- 📦 **批量操作**: 支持批量创建多篇文章
|
|
18
|
-
- ⚡ **实时发布**: 文章创建后立即可见
|
|
19
|
-
- 🔧 **TypeScript**: 完整的类型安全支持
|
|
20
|
-
- 📦 **npm 包**: 可直接通过 npx 安装使用
|
|
13
|
+
## 🎯 Project Features
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
- 🔒 **Private Service** - Customized for your blog, not publicly available
|
|
16
|
+
- 🚀 **Automated Creation** - AI can create complete blog articles directly
|
|
17
|
+
- 📝 **Markdown Support** - Full Markdown format support
|
|
18
|
+
- 🏷️ **Tag Management** - Automatic creation and management of article tags
|
|
19
|
+
- 🔐 **Security Authentication** - Multi-layer security verification mechanism
|
|
20
|
+
- 📦 **npm Package** - Can be installed directly via npx
|
|
21
|
+
- ⚡ **Real-time Publishing** - Articles are immediately visible after creation
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
## 🚀 Quick Start
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
### 1. Configure in Cursor
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
Add the following configuration to your Cursor settings file `~/.cursor/mcp.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"Blog MCP Server": {
|
|
32
|
+
"type": "stdio",
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": [
|
|
35
|
+
"-y",
|
|
36
|
+
"@zyzy-org/blog-mcp-server@latest"
|
|
37
|
+
],
|
|
38
|
+
"env": {
|
|
39
|
+
"BLOG_URL": "https://your-blog.com",
|
|
40
|
+
"MCP_SECRET": "your_shared_secret_here",
|
|
41
|
+
"MCP_CLIENT_ID": "your_client_id",
|
|
42
|
+
"MCP_SIGNATURE_SECRET": "your_signature_secret"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
31
46
|
```
|
|
32
47
|
|
|
33
|
-
### 2.
|
|
48
|
+
### 2. Restart Cursor
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
After configuration, restart Cursor to activate the new MCP server.
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npx -y @zyzy-org/blog-mcp-server@latest
|
|
40
|
-
```
|
|
52
|
+
### 3. Start Using
|
|
41
53
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
Use directly in Cursor:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
Please create an article about React Hooks in my blog
|
|
45
58
|
```
|
|
46
59
|
|
|
47
|
-
##
|
|
60
|
+
## 🛠️ Available Tools
|
|
48
61
|
|
|
49
|
-
###
|
|
50
|
-
|
|
62
|
+
### create_blog_post
|
|
63
|
+
Create a single blog article
|
|
64
|
+
|
|
65
|
+
**Parameters:**
|
|
66
|
+
- `title` (string): Article title (required)
|
|
67
|
+
- `content` (string): Article content, supports Markdown (required)
|
|
68
|
+
- `tags` (array): Article tags (optional)
|
|
69
|
+
- `author` (string): Author name (optional)
|
|
70
|
+
- `readTime` (number): Estimated reading time in minutes (optional)
|
|
71
|
+
- `date` (string): Publication date (ISO 8601 format) (optional)
|
|
72
|
+
- `github_url` (string): Related GitHub link (optional)
|
|
73
|
+
- `slug` (string): Custom article slug (optional)
|
|
51
74
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- `
|
|
75
|
+
### create_multiple_blog_posts
|
|
76
|
+
Create multiple blog articles in batch
|
|
77
|
+
|
|
78
|
+
**Parameters:**
|
|
79
|
+
- `articles` (array): Array of articles to create
|
|
80
|
+
|
|
81
|
+
## 🔒 Security Features
|
|
82
|
+
|
|
83
|
+
- **Shared Secret Authentication** - Uses pre-configured keys for basic authentication
|
|
84
|
+
- **Timestamp Verification** - Prevents replay attacks
|
|
85
|
+
- **Signature Verification** - Optional additional security layer
|
|
86
|
+
- **Client Whitelist** - Restricts allowed client access
|
|
87
|
+
- **Environment Variable Management** - All sensitive information stored in environment variables
|
|
88
|
+
|
|
89
|
+
## 🏗️ Blog End Configuration
|
|
90
|
+
|
|
91
|
+
### 1. API Endpoint
|
|
92
|
+
|
|
93
|
+
Create `/app/api/mcp/posts/route.ts` in your Next.js blog project:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
97
|
+
import { createAdminClient } from '@/lib/supabase/admin';
|
|
98
|
+
|
|
99
|
+
export async function POST(req: NextRequest) {
|
|
100
|
+
const secret = process.env.MCP_SHARED_SECRET;
|
|
101
|
+
if (!secret) {
|
|
102
|
+
return NextResponse.json({ error: 'Server not configured' }, { status: 500 });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Basic secret verification
|
|
106
|
+
const provided = req.headers.get('x-mcp-secret');
|
|
107
|
+
if (!provided || provided !== secret) {
|
|
108
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let body;
|
|
112
|
+
try {
|
|
113
|
+
body = await req.json();
|
|
114
|
+
} catch {
|
|
115
|
+
return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Client whitelist verification
|
|
119
|
+
const allowedClients = process.env.MCP_ALLOWED_CLIENTS?.split(',') || [];
|
|
120
|
+
if (allowedClients.length > 0 && body.client_id && !allowedClients.includes(body.client_id)) {
|
|
121
|
+
return NextResponse.json({ error: 'Client not authorized' }, { status: 403 });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Article creation logic...
|
|
125
|
+
const admin = createAdminClient();
|
|
126
|
+
const finalSlug = body.slug ?? crypto.randomUUID();
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const { error: postError } = await admin
|
|
130
|
+
.from('Post')
|
|
131
|
+
.upsert({
|
|
132
|
+
slug: finalSlug,
|
|
133
|
+
title: body.title,
|
|
134
|
+
date: body.date ?? new Date().toISOString(),
|
|
135
|
+
author: body.author || '',
|
|
136
|
+
tags: body.tags || [],
|
|
137
|
+
content: body.content,
|
|
138
|
+
readTime: body.readTime === '' ? null : body.readTime,
|
|
139
|
+
lastModified: new Date().toISOString(),
|
|
140
|
+
github_url: body.github_url || '',
|
|
141
|
+
isShown: true,
|
|
142
|
+
}, { onConflict: 'slug' });
|
|
143
|
+
|
|
144
|
+
if (postError) {
|
|
145
|
+
return NextResponse.json({ error: 'Failed to create post', details: postError.message }, { status: 500 });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return NextResponse.json({ slug: finalSlug, message: 'ok' });
|
|
149
|
+
} catch (e) {
|
|
150
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
151
|
+
return NextResponse.json({ error: 'Unexpected error', details: errorMessage }, { status: 500 });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
57
155
|
|
|
58
|
-
###
|
|
59
|
-
- `--blog-url`: 覆盖环境变量中的博客地址
|
|
60
|
-
- `--secret`: 覆盖环境变量中的密钥
|
|
61
|
-
- `--client-id`: 覆盖环境变量中的客户端ID
|
|
62
|
-
- `--signature-secret`: 覆盖环境变量中的签名密钥
|
|
63
|
-
- `--local`: 使用本地开发环境
|
|
156
|
+
### 2. Environment Variable Configuration
|
|
64
157
|
|
|
65
|
-
|
|
158
|
+
Configure the following environment variables in Vercel:
|
|
66
159
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- `github_url` (string): 相关的 GitHub 链接
|
|
78
|
-
- `slug` (string): 自定义文章 slug
|
|
160
|
+
```bash
|
|
161
|
+
# MCP Authentication Configuration
|
|
162
|
+
MCP_SHARED_SECRET=your_shared_secret_here
|
|
163
|
+
MCP_CLIENT_ID=your_client_id
|
|
164
|
+
MCP_SIGNATURE_SECRET=your_signature_secret
|
|
165
|
+
MCP_ALLOWED_CLIENTS=client1,client2,client3
|
|
166
|
+
|
|
167
|
+
# Supabase Configuration
|
|
168
|
+
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
|
|
169
|
+
```
|
|
79
170
|
|
|
80
|
-
###
|
|
81
|
-
批量创建多篇博客文章
|
|
171
|
+
### 3. Middleware Configuration
|
|
82
172
|
|
|
83
|
-
|
|
84
|
-
- `articles` (array): 要创建的文章数组
|
|
173
|
+
Ensure `middleware.ts` excludes API routes:
|
|
85
174
|
|
|
86
|
-
|
|
175
|
+
```typescript
|
|
176
|
+
export const config = {
|
|
177
|
+
matcher: [
|
|
178
|
+
"/((?!_next/static|_next/image|favicon.ico|api|categories|post/|write|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
```
|
|
87
182
|
|
|
88
|
-
|
|
89
|
-
- 支持时间戳验证防止重放攻击
|
|
90
|
-
- 可选的签名验证提供额外安全层
|
|
91
|
-
- 支持客户端白名单限制访问
|
|
92
|
-
- 完整的错误处理和日志记录
|
|
183
|
+
## 🧪 Testing
|
|
93
184
|
|
|
94
|
-
|
|
185
|
+
### Local Testing
|
|
95
186
|
|
|
96
187
|
```bash
|
|
97
|
-
#
|
|
188
|
+
# Build project
|
|
98
189
|
npm run build
|
|
99
190
|
|
|
100
|
-
#
|
|
191
|
+
# Start MCP server
|
|
101
192
|
npm start
|
|
102
193
|
|
|
103
|
-
#
|
|
104
|
-
|
|
194
|
+
# Test configuration
|
|
195
|
+
npm test
|
|
105
196
|
```
|
|
106
197
|
|
|
107
|
-
|
|
198
|
+
### API Testing
|
|
108
199
|
|
|
109
200
|
```bash
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
# 本地测试
|
|
120
|
-
npm run test
|
|
201
|
+
curl -X POST https://your-blog.com/api/mcp/posts \
|
|
202
|
+
-H "Content-Type: application/json" \
|
|
203
|
+
-H "x-mcp-secret: your_shared_secret_here" \
|
|
204
|
+
-d '{
|
|
205
|
+
"title": "Test Article",
|
|
206
|
+
"content": "This is a test article",
|
|
207
|
+
"client_id": "your_client_id"
|
|
208
|
+
}'
|
|
121
209
|
```
|
|
122
210
|
|
|
123
|
-
## 📁
|
|
211
|
+
## 📁 Project Structure
|
|
124
212
|
|
|
125
213
|
```
|
|
126
214
|
src/
|
|
127
|
-
├── index.ts #
|
|
128
|
-
├── types.ts #
|
|
129
|
-
├── config.ts #
|
|
130
|
-
├── blog-client.ts #
|
|
131
|
-
|
|
132
|
-
└── tools.ts # MCP 工具定义
|
|
215
|
+
├── index.ts # Main entry file
|
|
216
|
+
├── types.ts # Type definitions
|
|
217
|
+
├── config.ts # Configuration parsing
|
|
218
|
+
├── blog-client.ts # Blog API client
|
|
219
|
+
└── mcp-server.ts # MCP server implementation
|
|
133
220
|
```
|
|
134
221
|
|
|
135
|
-
##
|
|
222
|
+
## 🚨 Important Notes
|
|
223
|
+
|
|
224
|
+
1. **Private Service** - This is a private service customized for your blog, not publicly available
|
|
225
|
+
2. **Key Security** - All sensitive information is stored in environment variables, do not commit to code repository
|
|
226
|
+
3. **Regular Updates** - It's recommended to regularly rotate signature keys
|
|
227
|
+
4. **Local Testing** - It's recommended to test functionality in local environment first
|
|
228
|
+
|
|
229
|
+
## 🎉 Usage Examples
|
|
136
230
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
231
|
+
After configuration, you can use it in Cursor like this:
|
|
232
|
+
|
|
233
|
+
### Create Single Article
|
|
234
|
+
```
|
|
235
|
+
Please create an article about TypeScript in my blog with the title "TypeScript Best Practices"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Create Multiple Articles
|
|
239
|
+
```
|
|
240
|
+
Please create three articles about React in my blog:
|
|
241
|
+
1. React Hooks Deep Dive
|
|
242
|
+
2. React Performance Optimization
|
|
243
|
+
3. React State Management
|
|
244
|
+
```
|
|
140
245
|
|
|
141
|
-
##
|
|
246
|
+
## 📄 License
|
|
142
247
|
|
|
143
|
-
|
|
248
|
+
MIT License - See [LICENSE](./LICENSE) file for details
|
|
144
249
|
|
|
145
|
-
|
|
250
|
+
---
|
|
146
251
|
|
|
147
|
-
|
|
252
|
+
**Note**: This is a private MCP service customized for your blog. All sensitive configuration information is stored in environment variables to ensure security.
|
package/README_CN.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Blog MCP Server
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[README_EN.md 查看英文版](./README_EN.md)
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
> 私人 MCP 服务器 - 让 AI 助手直接在你的技术博客中创建文章
|
|
10
|
+
|
|
11
|
+
这是一个专为你的博客定制的私人 MCP (Model Context Protocol) 服务器,允许 AI 助手(如 Cursor、Claude 等)直接在你的技术博客中创建文章,无需手动编辑。
|
|
12
|
+
|
|
13
|
+
## 🎯 项目特点
|
|
14
|
+
|
|
15
|
+
- 🔒 **私人服务** - 专为你的博客定制,不对外公开
|
|
16
|
+
- 🚀 **自动化创建** - AI 可以直接创建完整的博客文章
|
|
17
|
+
- 📝 **Markdown 支持** - 支持完整的 Markdown 格式
|
|
18
|
+
- 🏷️ **标签管理** - 自动创建和管理文章标签
|
|
19
|
+
- 🔐 **安全认证** - 多层安全验证机制
|
|
20
|
+
- 📦 **npm 包** - 可直接通过 npx 安装使用
|
|
21
|
+
- ⚡ **实时发布** - 文章创建后立即可见
|
|
22
|
+
|
|
23
|
+
## 🚀 快速开始
|
|
24
|
+
|
|
25
|
+
### 1. 在 Cursor 中配置
|
|
26
|
+
|
|
27
|
+
在你的 Cursor 设置文件 `~/.cursor/mcp.json` 中添加以下配置:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"Blog MCP Server": {
|
|
32
|
+
"type": "stdio",
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": [
|
|
35
|
+
"-y",
|
|
36
|
+
"@zyzy-org/blog-mcp-server@latest"
|
|
37
|
+
],
|
|
38
|
+
"env": {
|
|
39
|
+
"BLOG_URL": "https://your-blog.com",
|
|
40
|
+
"MCP_SECRET": "your_shared_secret_here",
|
|
41
|
+
"MCP_CLIENT_ID": "your_client_id",
|
|
42
|
+
"MCP_SIGNATURE_SECRET": "your_signature_secret"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 2. 重启 Cursor
|
|
49
|
+
|
|
50
|
+
配置完成后,重启 Cursor 以使新的 MCP 服务器生效。
|
|
51
|
+
|
|
52
|
+
### 3. 开始使用
|
|
53
|
+
|
|
54
|
+
在 Cursor 中直接使用:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
请在我的博客中创建一篇关于 React Hooks 的文章
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 🛠️ 可用工具
|
|
61
|
+
|
|
62
|
+
### create_blog_post
|
|
63
|
+
创建单篇博客文章
|
|
64
|
+
|
|
65
|
+
**参数:**
|
|
66
|
+
- `title` (string): 文章标题(必需)
|
|
67
|
+
- `content` (string): 文章内容,支持 Markdown(必需)
|
|
68
|
+
- `tags` (array): 文章标签(可选)
|
|
69
|
+
- `author` (string): 作者名称(可选)
|
|
70
|
+
- `readTime` (number): 预计阅读时间(分钟)(可选)
|
|
71
|
+
- `date` (string): 发布日期(ISO 8601 格式)(可选)
|
|
72
|
+
- `github_url` (string): 相关的 GitHub 链接(可选)
|
|
73
|
+
- `slug` (string): 自定义文章 slug(可选)
|
|
74
|
+
|
|
75
|
+
### create_multiple_blog_posts
|
|
76
|
+
批量创建多篇博客文章
|
|
77
|
+
|
|
78
|
+
**参数:**
|
|
79
|
+
- `articles` (array): 要创建的文章数组
|
|
80
|
+
|
|
81
|
+
## 🔒 安全特性
|
|
82
|
+
|
|
83
|
+
- **共享密钥认证** - 使用预配置的密钥进行基础认证
|
|
84
|
+
- **时间戳验证** - 防止重放攻击
|
|
85
|
+
- **签名验证** - 可选的额外安全层
|
|
86
|
+
- **客户端白名单** - 限制允许的客户端访问
|
|
87
|
+
- **环境变量管理** - 所有敏感信息存储在环境变量中
|
|
88
|
+
|
|
89
|
+
## 🏗️ 博客端配置
|
|
90
|
+
|
|
91
|
+
### 1. API 端点
|
|
92
|
+
|
|
93
|
+
在你的 Next.js 博客项目中创建 `/app/api/mcp/posts/route.ts`:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
97
|
+
import { createAdminClient } from '@/lib/supabase/admin';
|
|
98
|
+
|
|
99
|
+
export async function POST(req: NextRequest) {
|
|
100
|
+
const secret = process.env.MCP_SHARED_SECRET;
|
|
101
|
+
if (!secret) {
|
|
102
|
+
return NextResponse.json({ error: 'Server not configured' }, { status: 500 });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 基础密钥验证
|
|
106
|
+
const provided = req.headers.get('x-mcp-secret');
|
|
107
|
+
if (!provided || provided !== secret) {
|
|
108
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let body;
|
|
112
|
+
try {
|
|
113
|
+
body = await req.json();
|
|
114
|
+
} catch {
|
|
115
|
+
return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 客户端白名单验证
|
|
119
|
+
const allowedClients = process.env.MCP_ALLOWED_CLIENTS?.split(',') || [];
|
|
120
|
+
if (allowedClients.length > 0 && body.client_id && !allowedClients.includes(body.client_id)) {
|
|
121
|
+
return NextResponse.json({ error: 'Client not authorized' }, { status: 403 });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 创建文章逻辑...
|
|
125
|
+
const admin = createAdminClient();
|
|
126
|
+
const finalSlug = body.slug ?? crypto.randomUUID();
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const { error: postError } = await admin
|
|
130
|
+
.from('Post')
|
|
131
|
+
.upsert({
|
|
132
|
+
slug: finalSlug,
|
|
133
|
+
title: body.title,
|
|
134
|
+
date: body.date ?? new Date().toISOString(),
|
|
135
|
+
author: body.author || '',
|
|
136
|
+
tags: body.tags || [],
|
|
137
|
+
content: body.content,
|
|
138
|
+
readTime: body.readTime === '' ? null : body.readTime,
|
|
139
|
+
lastModified: new Date().toISOString(),
|
|
140
|
+
github_url: body.github_url || '',
|
|
141
|
+
isShown: true,
|
|
142
|
+
}, { onConflict: 'slug' });
|
|
143
|
+
|
|
144
|
+
if (postError) {
|
|
145
|
+
return NextResponse.json({ error: 'Failed to create post', details: postError.message }, { status: 500 });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return NextResponse.json({ slug: finalSlug, message: 'ok' });
|
|
149
|
+
} catch (e) {
|
|
150
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
151
|
+
return NextResponse.json({ error: 'Unexpected error', details: errorMessage }, { status: 500 });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 2. 环境变量配置
|
|
157
|
+
|
|
158
|
+
在 Vercel 中配置以下环境变量:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# MCP 认证配置
|
|
162
|
+
MCP_SHARED_SECRET=your_shared_secret_here
|
|
163
|
+
MCP_CLIENT_ID=your_client_id
|
|
164
|
+
MCP_SIGNATURE_SECRET=your_signature_secret
|
|
165
|
+
MCP_ALLOWED_CLIENTS=client1,client2,client3
|
|
166
|
+
|
|
167
|
+
# Supabase 配置
|
|
168
|
+
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 3. 中间件配置
|
|
172
|
+
|
|
173
|
+
确保 `middleware.ts` 排除 API 路由:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
export const config = {
|
|
177
|
+
matcher: [
|
|
178
|
+
"/((?!_next/static|_next/image|favicon.ico|api|categories|post/|write|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 🧪 测试
|
|
184
|
+
|
|
185
|
+
### 本地测试
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# 构建项目
|
|
189
|
+
npm run build
|
|
190
|
+
|
|
191
|
+
# 启动 MCP 服务器
|
|
192
|
+
npm start
|
|
193
|
+
|
|
194
|
+
# 测试配置
|
|
195
|
+
npm test
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### API 测试
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
curl -X POST https://your-blog.com/api/mcp/posts \
|
|
202
|
+
-H "Content-Type: application/json" \
|
|
203
|
+
-H "x-mcp-secret: your_shared_secret_here" \
|
|
204
|
+
-d '{
|
|
205
|
+
"title": "测试文章",
|
|
206
|
+
"content": "这是一篇测试文章",
|
|
207
|
+
"client_id": "your_client_id"
|
|
208
|
+
}'
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## 📁 项目结构
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
src/
|
|
215
|
+
├── index.ts # 主入口文件
|
|
216
|
+
├── types.ts # 类型定义
|
|
217
|
+
├── config.ts # 配置解析
|
|
218
|
+
├── blog-client.ts # 博客 API 客户端
|
|
219
|
+
└── mcp-server.ts # MCP 服务器实现
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 🚨 重要提醒
|
|
223
|
+
|
|
224
|
+
1. **私人服务** - 这是专为你的博客定制的私人服务,不对外公开
|
|
225
|
+
2. **密钥安全** - 所有敏感信息都存储在环境变量中,不要提交到代码仓库
|
|
226
|
+
3. **定期更新** - 建议定期更换签名密钥
|
|
227
|
+
4. **本地测试** - 建议先在本地环境测试功能
|
|
228
|
+
|
|
229
|
+
## 🎉 使用示例
|
|
230
|
+
|
|
231
|
+
配置完成后,你可以在 Cursor 中这样使用:
|
|
232
|
+
|
|
233
|
+
### 创建单篇文章
|
|
234
|
+
```
|
|
235
|
+
请在我的博客中创建一篇关于 TypeScript 的文章,标题为"TypeScript 最佳实践"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 批量创建文章
|
|
239
|
+
```
|
|
240
|
+
请在我的博客中创建三篇关于 React 的文章:
|
|
241
|
+
1. React Hooks 详解
|
|
242
|
+
2. React 性能优化
|
|
243
|
+
3. React 状态管理
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## 📄 许可证
|
|
247
|
+
|
|
248
|
+
MIT License - 详见 [LICENSE](./LICENSE) 文件
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
**注意**: 这是一个私人 MCP 服务,专为你的博客定制。所有敏感配置信息都存储在环境变量中,确保安全性。
|
package/package.json
CHANGED
package/PROJECT_STRUCTURE.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# 项目结构
|
|
2
|
-
|
|
3
|
-
```
|
|
4
|
-
yy-blog-generate-post-mcp-server/
|
|
5
|
-
├── src/ # TypeScript 源代码
|
|
6
|
-
│ ├── index.ts # 主入口文件
|
|
7
|
-
│ ├── types.ts # 类型定义
|
|
8
|
-
│ ├── config.ts # 配置解析
|
|
9
|
-
│ ├── blog-client.ts # 博客 API 客户端
|
|
10
|
-
│ ├── mcp-server.ts # MCP 服务器实现
|
|
11
|
-
│ └── tools.ts # MCP 工具定义
|
|
12
|
-
├── dist/ # 编译后的 JavaScript 文件
|
|
13
|
-
├── package.json # 项目配置和依赖
|
|
14
|
-
├── tsconfig.json # TypeScript 配置
|
|
15
|
-
├── README.md # 项目说明文档
|
|
16
|
-
├── LICENSE # MIT 许可证
|
|
17
|
-
├── PUBLISH.md # 发布指南
|
|
18
|
-
├── example-config.md # 配置示例
|
|
19
|
-
├── test-mcp.js # 测试脚本
|
|
20
|
-
└── .gitignore # Git 忽略文件
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## 核心文件说明
|
|
24
|
-
|
|
25
|
-
### src/index.ts
|
|
26
|
-
主入口文件,负责启动 MCP 服务器。
|
|
27
|
-
|
|
28
|
-
### src/config.ts
|
|
29
|
-
解析命令行参数,验证必需配置。
|
|
30
|
-
|
|
31
|
-
### src/blog-client.ts
|
|
32
|
-
博客 API 客户端,处理与你的博客后端的通信。
|
|
33
|
-
|
|
34
|
-
### src/mcp-server.ts
|
|
35
|
-
MCP 协议服务器实现,处理 AI 助手的请求。
|
|
36
|
-
|
|
37
|
-
### src/tools.ts
|
|
38
|
-
定义可用的 MCP 工具(create_blog_post, create_multiple_blog_posts)。
|
|
39
|
-
|
|
40
|
-
### src/types.ts
|
|
41
|
-
TypeScript 类型定义,确保类型安全。
|
|
42
|
-
|
|
43
|
-
## 构建和运行
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
# 安装依赖
|
|
47
|
-
npm install
|
|
48
|
-
|
|
49
|
-
# 构建项目
|
|
50
|
-
npm run build
|
|
51
|
-
|
|
52
|
-
# 测试配置
|
|
53
|
-
npm test
|
|
54
|
-
|
|
55
|
-
# 启动服务器
|
|
56
|
-
npm start
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## 发布和使用
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
# 发布到 npm
|
|
63
|
-
npm run publish-package
|
|
64
|
-
|
|
65
|
-
# 在 Cursor 中使用
|
|
66
|
-
npx -y @zyzy-org/blog-mcp-server@latest
|
|
67
|
-
```
|
package/PUBLISH_GUIDE.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# 发布指南
|
|
2
|
-
|
|
3
|
-
## 🚀 发布到 npm
|
|
4
|
-
|
|
5
|
-
### 1. 准备发布
|
|
6
|
-
|
|
7
|
-
确保你已经完成了以下步骤:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# 构建项目
|
|
11
|
-
npm run build
|
|
12
|
-
|
|
13
|
-
# 测试配置
|
|
14
|
-
npm test
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### 2. 登录 npm
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# 确保使用官方 npm 源
|
|
21
|
-
npm config set registry https://registry.npmjs.org/
|
|
22
|
-
|
|
23
|
-
# 登录到 npm
|
|
24
|
-
npm login
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### 3. 发布包
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# 发布包
|
|
31
|
-
npm run publish-package
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## 📦 包信息
|
|
35
|
-
|
|
36
|
-
- **包名**: `@zyzy-org/blog-mcp-server`
|
|
37
|
-
- **版本**: 1.0.0
|
|
38
|
-
- **访问权限**: public
|
|
39
|
-
- **描述**: 私人博客 MCP 服务器
|
|
40
|
-
|
|
41
|
-
## 🔒 安全注意事项
|
|
42
|
-
|
|
43
|
-
- ✅ `.env` 文件不会被发布(已在 `.gitignore` 中)
|
|
44
|
-
- ✅ 敏感信息只存储在本地环境变量中
|
|
45
|
-
- ✅ 包中只包含必要的源代码和文档
|
|
46
|
-
|
|
47
|
-
## 🎯 发布后使用
|
|
48
|
-
|
|
49
|
-
发布成功后,你可以在 Cursor 中使用:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npx -y @zyzy-org/blog-mcp-server@latest
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## 🚨 故障排除
|
|
56
|
-
|
|
57
|
-
### npm 认证问题
|
|
58
|
-
如果遇到认证问题,请检查:
|
|
59
|
-
1. 是否使用了正确的 npm 源
|
|
60
|
-
2. 是否已正确登录
|
|
61
|
-
3. 是否有发布权限
|
|
62
|
-
|
|
63
|
-
### 版本更新
|
|
64
|
-
更新版本时:
|
|
65
|
-
```bash
|
|
66
|
-
npm version patch # 小版本更新
|
|
67
|
-
npm version minor # 次版本更新
|
|
68
|
-
npm version major # 主版本更新
|
|
69
|
-
npm run publish-package
|
|
70
|
-
```
|
package/SETUP.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# 私人 MCP 服务器设置指南
|
|
2
|
-
|
|
3
|
-
## 🎯 项目说明
|
|
4
|
-
|
|
5
|
-
这是一个专为你的博客定制的私人 MCP 服务器,所有敏感信息都存储在 `.env` 文件中,确保安全性。
|
|
6
|
-
|
|
7
|
-
## 🚀 快速设置
|
|
8
|
-
|
|
9
|
-
### 1. 环境配置
|
|
10
|
-
|
|
11
|
-
项目已经为你配置好了 `.env` 文件,包含所有必要的密钥:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
# 博客配置
|
|
15
|
-
BLOG_URL=https://zyzy.info
|
|
16
|
-
BLOG_LOCAL_URL=http://localhost:3000
|
|
17
|
-
|
|
18
|
-
# MCP 认证配置
|
|
19
|
-
MCP_SECRET=660649959a92f12949618a919413e83c8aad09afbb39bcc172725583037e6beb
|
|
20
|
-
MCP_CLIENT_ID=my-mcp-client
|
|
21
|
-
MCP_SIGNATURE_SECRET=c20f0c7bd9128d05c53ffc7743f483c21169f1562542c30ea6e6bf127b488e5f
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### 2. 在 Cursor 中配置
|
|
25
|
-
|
|
26
|
-
在你的 Cursor 设置中添加以下 MCP 服务器:
|
|
27
|
-
|
|
28
|
-
#### 生产环境(推荐)
|
|
29
|
-
```bash
|
|
30
|
-
npx -y @zyzy-org/blog-mcp-server@latest
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
#### 本地开发
|
|
34
|
-
```bash
|
|
35
|
-
npx -y @zyzy-org/blog-mcp-server@latest --local
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## 🛠️ 使用方法
|
|
39
|
-
|
|
40
|
-
### 创建单篇文章
|
|
41
|
-
```
|
|
42
|
-
请在我的博客中创建一篇关于 React 的文章,标题为"React Hooks 详解"
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### 批量创建文章
|
|
46
|
-
```
|
|
47
|
-
请在我的博客中创建三篇关于 TypeScript 的文章:
|
|
48
|
-
1. TypeScript 基础语法
|
|
49
|
-
2. TypeScript 高级特性
|
|
50
|
-
3. TypeScript 最佳实践
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## 🔒 安全特性
|
|
54
|
-
|
|
55
|
-
- ✅ 所有敏感信息存储在 `.env` 文件中
|
|
56
|
-
- ✅ `.env` 文件已添加到 `.gitignore`
|
|
57
|
-
- ✅ 支持签名验证防止篡改
|
|
58
|
-
- ✅ 时间戳验证防止重放攻击
|
|
59
|
-
- ✅ 客户端白名单限制访问
|
|
60
|
-
|
|
61
|
-
## 🧪 测试
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
# 测试配置是否正确
|
|
65
|
-
npm test
|
|
66
|
-
|
|
67
|
-
# 构建项目
|
|
68
|
-
npm run build
|
|
69
|
-
|
|
70
|
-
# 启动服务器
|
|
71
|
-
npm start
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## 📁 项目结构
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
├── src/ # TypeScript 源代码
|
|
78
|
-
├── dist/ # 编译后的文件
|
|
79
|
-
├── .env # 环境变量配置(包含敏感信息)
|
|
80
|
-
├── .env.example # 环境变量模板
|
|
81
|
-
├── package.json # 项目配置
|
|
82
|
-
├── README.md # 项目说明
|
|
83
|
-
├── USAGE.md # 使用指南
|
|
84
|
-
└── test-config.js # 配置测试脚本
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## 🚨 重要提醒
|
|
88
|
-
|
|
89
|
-
1. **不要提交 `.env` 文件** - 它包含敏感信息
|
|
90
|
-
2. **这是私人服务** - 仅适用于你的博客
|
|
91
|
-
3. **定期更新密钥** - 建议定期更换签名密钥
|
|
92
|
-
4. **本地测试** - 建议先在本地环境测试
|
|
93
|
-
|
|
94
|
-
## 🎉 完成
|
|
95
|
-
|
|
96
|
-
配置完成后,你就可以在 Cursor 中直接使用 AI 助手创建博客文章了!
|
package/USAGE.md
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# 使用指南
|
|
2
|
-
|
|
3
|
-
## 快速开始
|
|
4
|
-
|
|
5
|
-
### 1. 配置环境变量
|
|
6
|
-
|
|
7
|
-
复制 `.env.example` 为 `.env` 并填入你的配置:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
cp .env.example .env
|
|
11
|
-
# 编辑 .env 文件,填入你的实际配置
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### 2. 在 Cursor 中配置
|
|
15
|
-
|
|
16
|
-
在你的 Cursor 设置中添加以下 MCP 服务器:
|
|
17
|
-
|
|
18
|
-
#### 生产环境配置
|
|
19
|
-
```bash
|
|
20
|
-
npx -y @zyzy-org/blog-mcp-server@latest
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
#### 本地开发配置
|
|
24
|
-
```bash
|
|
25
|
-
npx -y @zyzy-org/blog-mcp-server@latest --local
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## 可用工具
|
|
29
|
-
|
|
30
|
-
### create_blog_post
|
|
31
|
-
创建单篇博客文章
|
|
32
|
-
|
|
33
|
-
**示例用法:**
|
|
34
|
-
```
|
|
35
|
-
请在我的博客中创建一篇关于 TypeScript 的文章,标题为"TypeScript 最佳实践",包含以下内容:
|
|
36
|
-
- TypeScript 基础语法
|
|
37
|
-
- 类型系统详解
|
|
38
|
-
- 最佳实践建议
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### create_multiple_blog_posts
|
|
42
|
-
批量创建多篇博客文章
|
|
43
|
-
|
|
44
|
-
**示例用法:**
|
|
45
|
-
```
|
|
46
|
-
请在我的博客中创建三篇关于 React 的文章:
|
|
47
|
-
1. React Hooks 详解
|
|
48
|
-
2. React 性能优化
|
|
49
|
-
3. React 状态管理
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## 故障排除
|
|
53
|
-
|
|
54
|
-
### 1. API 连接问题
|
|
55
|
-
|
|
56
|
-
如果遇到 API 连接问题,请检查:
|
|
57
|
-
|
|
58
|
-
- 博客是否正在运行
|
|
59
|
-
- API 端点是否正确配置
|
|
60
|
-
- 认证密钥是否正确
|
|
61
|
-
- `.env` 文件配置是否正确
|
|
62
|
-
|
|
63
|
-
### 2. 生产环境问题
|
|
64
|
-
|
|
65
|
-
如果生产环境 API 返回登录页面,可能需要:
|
|
66
|
-
|
|
67
|
-
1. 检查中间件配置
|
|
68
|
-
2. 确保 API 路由正确部署
|
|
69
|
-
3. 验证认证逻辑
|
|
70
|
-
|
|
71
|
-
### 3. 本地测试
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# 构建项目
|
|
75
|
-
npm run build
|
|
76
|
-
|
|
77
|
-
# 启动 MCP 服务器
|
|
78
|
-
npm start
|
|
79
|
-
|
|
80
|
-
# 或者直接运行
|
|
81
|
-
node dist/index.js
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## 安全注意事项
|
|
85
|
-
|
|
86
|
-
- 不要在公开代码中暴露密钥
|
|
87
|
-
- 定期轮换签名密钥
|
|
88
|
-
- 使用客户端白名单限制访问
|
|
89
|
-
- 监控 API 使用情况
|
package/example-config.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# 配置示例
|
|
2
|
-
|
|
3
|
-
## Cursor 设置中的 MCP 配置
|
|
4
|
-
|
|
5
|
-
在你的 Cursor 设置中添加以下 MCP 服务器:
|
|
6
|
-
|
|
7
|
-
### 基本配置
|
|
8
|
-
```bash
|
|
9
|
-
npx -y @ziyouzhiyi/blog-mcp-server@latest --blog-url=https://zyzy.info --secret=660649959a92f12949618a919413e83c8aad09afbb39bcc172725583037e6beb
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
### 完整配置(推荐)
|
|
13
|
-
```bash
|
|
14
|
-
npx -y @ziyouzhiyi/blog-mcp-server@latest --blog-url=https://zyzy.info --secret=660649959a92f12949618a919413e83c8aad09afbb39bcc172725583037e6beb --client-id=my-mcp-client --signature-secret=c20f0c7bd9128d05c53ffc7743f483c21169f1562542c30ea6e6bf127b488e5f
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## 参数说明
|
|
18
|
-
|
|
19
|
-
- `--blog-url`: 你的博客域名(必需)
|
|
20
|
-
- `--secret`: MCP 共享密钥,对应你博客中的 `MCP_SHARED_SECRET`(必需)
|
|
21
|
-
- `--client-id`: 客户端标识,对应你博客中的 `MCP_CLIENT_ID`(可选)
|
|
22
|
-
- `--signature-secret`: 签名密钥,对应你博客中的 `MCP_SIGNATURE_SECRET`(可选,用于额外安全验证)
|
|
23
|
-
|
|
24
|
-
## 本地开发测试
|
|
25
|
-
|
|
26
|
-
如果你想在发布前测试,可以:
|
|
27
|
-
|
|
28
|
-
1. 克隆这个仓库
|
|
29
|
-
2. 运行 `npm install`
|
|
30
|
-
3. 运行 `npm run build`
|
|
31
|
-
4. 使用以下命令测试:
|
|
32
|
-
```bash
|
|
33
|
-
node dist/index.js --blog-url=http://localhost:3000 --secret=your-secret
|
|
34
|
-
```
|