@pandanpc/mcp-server 0.1.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.
Files changed (4) hide show
  1. package/README.md +59 -0
  2. package/index.js +35 -0
  3. package/install.js +133 -0
  4. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @pandanpc/mcp-server
2
+
3
+ PandaNpc MCP Server — 将 PandaNote、工作区、AI 模型和提供商管理能力暴露给 Claude Code、Cursor、Windsurf 等 MCP 客户端。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g @pandanpc/mcp-server
9
+ ```
10
+
11
+ 安装时自动从 `https://cos.pandanpc.com/mcp-server/` 下载对应平台的 Rust 二进制。
12
+
13
+ ### 支持平台
14
+
15
+ - Linux x64
16
+ - macOS x64 (Intel)
17
+ - macOS arm64 (Apple Silicon)
18
+ - Windows x64
19
+
20
+ ## Claude Code 配置
21
+
22
+ 编辑 `~/.config/claude-code/config.json`(或对应平台路径):
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "pandanpc": {
28
+ "command": "pandanpc-mcp"
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## 命令行使用
35
+
36
+ ```bash
37
+ # stdio 模式(MCP 客户端默认)
38
+ pandanpc-mcp
39
+
40
+ # HTTP/SSE 模式
41
+ pandanpc-mcp --http --port 3100
42
+ ```
43
+
44
+ ## 可用工具
45
+
46
+ - `note_login` — 登录 PandaNpc 账号
47
+ - `list_workspaces` / `create_workspace` / `update_workspace` / `delete_workspace`
48
+ - `list_notes` / `create_note` / `read_note` / `update_note` / `delete_note` / `move_note_to_workspace`
49
+ - `search_notes` — 标题 + 全文 + 语义搜索
50
+ - `generate_note_title` — AI 生成标题和图标
51
+ - `list_providers` / `create_provider` / `update_provider` / `delete_provider`
52
+ - `list_models` / `list_model_types` / `create_model` / `update_model` / `delete_model`
53
+ - `sync_rules` — 同步 `.claude/rules/` 和 `.claude/skills/` Markdown 到 PandaNote
54
+
55
+ 首次使用请先调用 `note_login` 登录。
56
+
57
+ ## 许可
58
+
59
+ MIT © PandaNpc
package/index.js ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * bin 入口:spawn 对应平台的 pandanpc-mcp 二进制,转发所有参数和 stdio
4
+ */
5
+
6
+ const path = require('path')
7
+ const { spawn } = require('child_process')
8
+ const fs = require('fs')
9
+
10
+ const binName = process.platform === 'win32' ? 'pandanpc-mcp.exe' : 'pandanpc-mcp'
11
+ const binPath = path.join(__dirname, 'bin', binName)
12
+
13
+ if (!fs.existsSync(binPath)) {
14
+ console.error(`[pandanpc-mcp] binary not found at ${binPath}`)
15
+ console.error(`[pandanpc-mcp] try reinstall: npm install -g @pandanpc/mcp-server`)
16
+ process.exit(1)
17
+ }
18
+
19
+ const child = spawn(binPath, process.argv.slice(2), {
20
+ stdio: 'inherit',
21
+ windowsHide: true,
22
+ })
23
+
24
+ child.on('exit', (code, signal) => {
25
+ if (signal) process.kill(process.pid, signal)
26
+ else process.exit(code ?? 0)
27
+ })
28
+
29
+ child.on('error', (err) => {
30
+ console.error(`[pandanpc-mcp] failed to spawn: ${err.message}`)
31
+ process.exit(1)
32
+ })
33
+
34
+ process.on('SIGINT', () => child.kill('SIGINT'))
35
+ process.on('SIGTERM', () => child.kill('SIGTERM'))
package/install.js ADDED
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall: 根据平台下载对应 pandanpc-mcp 二进制到 bin/
4
+ *
5
+ * 下载源:https://cos.pandanpc.com/mcp-server/v<version>/pandanpc-mcp-<platform>
6
+ * 校验:SHA256SUMS
7
+ */
8
+
9
+ const fs = require('fs')
10
+ const path = require('path')
11
+ const https = require('https')
12
+ const crypto = require('crypto')
13
+
14
+ const pkg = require('./package.json')
15
+ const VERSION = pkg.version
16
+ const BASE_URL = `https://cos.pandanpc.com/mcp-server/v${VERSION}`
17
+
18
+ const PLATFORM_MAP = {
19
+ 'linux-x64': 'pandanpc-mcp-linux-x64',
20
+ 'darwin-x64': 'pandanpc-mcp-darwin-x64',
21
+ 'darwin-arm64': 'pandanpc-mcp-darwin-arm64',
22
+ 'win32-x64': 'pandanpc-mcp-windows-x64.exe',
23
+ }
24
+
25
+ function detectPlatform() {
26
+ const key = `${process.platform}-${process.arch}`
27
+ const name = PLATFORM_MAP[key]
28
+ if (!name) {
29
+ throw new Error(`Unsupported platform: ${key}. Supported: ${Object.keys(PLATFORM_MAP).join(', ')}`)
30
+ }
31
+ return { key, name }
32
+ }
33
+
34
+ function download(url, dest) {
35
+ return new Promise((resolve, reject) => {
36
+ const file = fs.createWriteStream(dest)
37
+ const req = https.get(url, (res) => {
38
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
39
+ file.close()
40
+ fs.unlinkSync(dest)
41
+ return download(res.headers.location, dest).then(resolve, reject)
42
+ }
43
+ if (res.statusCode !== 200) {
44
+ file.close()
45
+ fs.unlinkSync(dest)
46
+ return reject(new Error(`HTTP ${res.statusCode} for ${url}`))
47
+ }
48
+ res.pipe(file)
49
+ file.on('finish', () => file.close(resolve))
50
+ })
51
+ req.on('error', (err) => {
52
+ file.close()
53
+ try { fs.unlinkSync(dest) } catch {}
54
+ reject(err)
55
+ })
56
+ })
57
+ }
58
+
59
+ function sha256(file) {
60
+ return new Promise((resolve, reject) => {
61
+ const hash = crypto.createHash('sha256')
62
+ const stream = fs.createReadStream(file)
63
+ stream.on('data', (d) => hash.update(d))
64
+ stream.on('end', () => resolve(hash.digest('hex')))
65
+ stream.on('error', reject)
66
+ })
67
+ }
68
+
69
+ async function fetchText(url) {
70
+ return new Promise((resolve, reject) => {
71
+ https.get(url, (res) => {
72
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
73
+ return fetchText(res.headers.location).then(resolve, reject)
74
+ }
75
+ if (res.statusCode !== 200) return reject(new Error(`HTTP ${res.statusCode}`))
76
+ let body = ''
77
+ res.on('data', (c) => (body += c))
78
+ res.on('end', () => resolve(body))
79
+ }).on('error', reject)
80
+ })
81
+ }
82
+
83
+ async function main() {
84
+ const { key, name } = detectPlatform()
85
+ const binDir = path.join(__dirname, 'bin')
86
+ if (!fs.existsSync(binDir)) fs.mkdirSync(binDir, { recursive: true })
87
+ const localBin = path.join(binDir, process.platform === 'win32' ? 'pandanpc-mcp.exe' : 'pandanpc-mcp')
88
+
89
+ // 如果二进制已存在且有效(开发环境手动拷贝),跳过下载
90
+ if (fs.existsSync(localBin) && fs.statSync(localBin).size > 0) {
91
+ console.log(`[pandanpc-mcp] binary already present at ${localBin}, skipping download`)
92
+ return
93
+ }
94
+
95
+ const url = `${BASE_URL}/${name}`
96
+ console.log(`[pandanpc-mcp] downloading ${url} → ${localBin}`)
97
+
98
+ try {
99
+ await download(url, localBin)
100
+ } catch (err) {
101
+ console.error(`[pandanpc-mcp] download failed: ${err.message}`)
102
+ console.error(`[pandanpc-mcp] If you are on an unsupported platform, build from source: https://github.com/pandanpc/mcp-server`)
103
+ process.exit(1)
104
+ }
105
+
106
+ // 校验 SHA256
107
+ try {
108
+ const sumsText = await fetchText(`${BASE_URL}/SHA256SUMS`)
109
+ const line = sumsText.split('\n').find((l) => l.includes(name))
110
+ if (line) {
111
+ const expected = line.trim().split(/\s+/)[0]
112
+ const actual = await sha256(localBin)
113
+ if (expected !== actual) {
114
+ fs.unlinkSync(localBin)
115
+ throw new Error(`SHA256 mismatch: expected ${expected}, got ${actual}`)
116
+ }
117
+ console.log(`[pandanpc-mcp] SHA256 verified`)
118
+ }
119
+ } catch (err) {
120
+ console.warn(`[pandanpc-mcp] SHA256 verification skipped: ${err.message}`)
121
+ }
122
+
123
+ if (process.platform !== 'win32') {
124
+ fs.chmodSync(localBin, 0o755)
125
+ }
126
+
127
+ console.log(`[pandanpc-mcp] installed for ${key}`)
128
+ }
129
+
130
+ main().catch((err) => {
131
+ console.error('[pandanpc-mcp] install failed:', err.message)
132
+ process.exit(1)
133
+ })
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@pandanpc/mcp-server",
3
+ "version": "0.1.0",
4
+ "description": "PandaNpc MCP Server — Claude Code and MCP clients integration for PandaNote",
5
+ "keywords": ["mcp", "pandanpc", "claude", "notes", "panda-note"],
6
+ "homepage": "https://pandanpc.com",
7
+ "license": "MIT",
8
+ "author": "PandaNpc <support@pandanpc.com>",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/pandanpc/mcp-server"
12
+ },
13
+ "bin": {
14
+ "pandanpc-mcp": "index.js"
15
+ },
16
+ "files": [
17
+ "index.js",
18
+ "install.js",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "postinstall": "node install.js"
23
+ },
24
+ "engines": {
25
+ "node": ">=16"
26
+ },
27
+ "os": [
28
+ "darwin",
29
+ "linux",
30
+ "win32"
31
+ ],
32
+ "cpu": [
33
+ "x64",
34
+ "arm64"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ }
39
+ }