chore(mcp): prepare npm publish

This commit is contained in:
digua authored and digua committed 2026-05-22 10:20:39 +08:00
1 parent d1737c7e8d
commit 6fa92bc2e4
16 files changed
+116 -13

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@
"publishConfig": {
"access": "public"
},
"license": "MIT",
"license": "AGPL-3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/ChatLab/ChatLab.git",
+1 -1
View File
@@ -267,7 +267,7 @@ program
program
.command('mcp')
.description('Start MCP Server (stdio transport, for Claude Desktop / Cursor / AI agents)')
.description('Start MCP Server (stdio transport, for ClaudeCode / Cursor / AI agents)')
.action(async () => {
const { startCliMcpServer } = await import('./mcp')
await startCliMcpServer()
+1 -1
View File
@@ -422,7 +422,7 @@ curl "http://127.0.0.1:5200/api/v1/sessions/abc123/messages?page=1&limit=50&keyw
### 1. MCP 集成
将 ChatLab API 接入 Claude Desktop 等 AI 工具,实现 AI 对聊天记录的直接查询和分析。
将 ChatLab API 接入 ClaudeCode 等 AI 工具,实现 AI 对聊天记录的直接查询和分析。
### 2. 自动化导入
+1 -1
View File
@@ -472,7 +472,7 @@ Content-Type and request body format are the same as `POST /api/v1/import`.
### 1. MCP Integration
Connect the ChatLab API to AI tools like Claude Desktop, enabling AI to directly query and analyze chat records.
Connect the ChatLab API to AI tools like ClaudeCode, enabling AI to directly query and analyze chat records.
### 2. Automation Scripts
+1 -1
View File
@@ -472,7 +472,7 @@ Content-Type 和请求体格式与 `POST /api/v1/import` 相同。
### 1. MCP 集成
将 ChatLab API 接入 Claude Desktop 等 AI 工具,实现 AI 对聊天记录的直接查询和分析。
将 ChatLab API 接入 ClaudeCode 等 AI 工具,实现 AI 对聊天记录的直接查询和分析。
### 2. 自动化脚本
+91
View File
@@ -0,0 +1,91 @@
# chatlab-mcp
ChatLab MCP Server exposes local ChatLab conversation data to MCP clients such as ClaudeCode, Cursor, Codex, and OpenClaw.
It runs over stdio and provides read-only access to imported ChatLab sessions, including session discovery, keyword search, member statistics, time analysis, SQL queries, and conversation context tools.
## Quick Start
Use it directly with `npx`:
```bash
npx -y chatlab-mcp
```
The command starts an MCP stdio server and waits for an MCP client. It does not print a help screen because stdout is reserved for MCP protocol messages.
## MCP Client Configuration
Add this server to your MCP client configuration:
```json
{
"mcpServers": {
"chatlab": {
"command": "npx",
"args": ["-y", "chatlab-mcp"]
}
}
}
```
If you install the package globally, you can also use:
```json
{
"mcpServers": {
"chatlab": {
"command": "chatlab-mcp"
}
}
}
```
## Data Directory
`chatlab-mcp` reads the same local data directory as ChatLab:
```text
~/.chatlab/
```
If you configured a custom ChatLab data directory in `~/.chatlab/config.toml`, the MCP server will use that configuration automatically.
The server is read-only. It opens existing ChatLab session databases and does not modify chat data.
## Available Capabilities
The server registers ChatLab tools for:
- Listing imported chat sessions
- Reading session metadata and database schema
- Searching messages and keywords
- Loading recent messages and message context
- Listing members and member activity
- Analyzing active hours, response time, interaction pairs, and daily active users
- Running read-only SQL queries
- Producing text or JSON output for tool results
## Requirements
- Node.js 20 or later
- Existing ChatLab data under `~/.chatlab/`
`better-sqlite3` is installed as a runtime dependency. On platforms without a matching prebuilt binary, npm may need local build tools for native modules.
`@node-rs/jieba` is optional and improves Chinese word segmentation for keyword-frequency tools. If it is unavailable, core MCP functionality still works.
## Package API
Advanced callers can import the shared server core:
```js
import { startMcpServer } from 'chatlab-mcp'
```
Most users should prefer the `npx -y chatlab-mcp` command.
## Links
- ChatLab: https://github.com/ChatLab/ChatLab
- Model Context Protocol: https://modelcontextprotocol.io/
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env node
import('../dist/bin.mjs')
+6 -2
View File
@@ -4,9 +4,10 @@
"description": "ChatLab MCP Server — shared core for CLI and Desktop, also usable standalone via npx",
"main": "./dist/index.mjs",
"bin": {
"chatlab-mcp": "./dist/bin.mjs"
"chatlab-mcp": "bin/chatlab-mcp.js"
},
"files": [
"bin/",
"dist/"
],
"engines": {
@@ -15,7 +16,7 @@
"publishConfig": {
"access": "public"
},
"license": "MIT",
"license": "AGPL-3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/ChatLab/ChatLab.git",
@@ -39,6 +40,9 @@
"smol-toml": "^1.3.1",
"zod": "^3.24.4"
},
"optionalDependencies": {
"@node-rs/jieba": "^2.0.1"
},
"devDependencies": {
"@openchatlab/config": "workspace:*",
"@openchatlab/core": "workspace:*",
+1 -1
View File
@@ -2,7 +2,7 @@
* ChatLab MCP Server core
*
* Registers @openchatlab/tools as MCP tools and exposes session data as MCP resources.
* Communicates with AI agents (Claude Desktop, Cursor, etc.) via stdio transport.
* Communicates with AI agents (ClaudeCode, Cursor, etc.) via stdio transport.
*/
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'
+4
View File
@@ -236,6 +236,10 @@ importers:
zod:
specifier: ^3.24.4
version: 3.25.76
optionalDependencies:
'@node-rs/jieba':
specifier: ^2.0.1
version: 2.0.1
devDependencies:
'@openchatlab/config':
specifier: workspace:*
@@ -11,7 +11,7 @@ type McpClient = 'claude' | 'codex' | 'openclaw' | 'other'
const selectedClient = ref<McpClient>('claude')
const clientOptions = computed(() => [
{ label: 'Claude', value: 'claude' },
{ label: 'ClaudeCode', value: 'claude' },
{ label: 'Codex', value: 'codex' },
{ label: 'OpenClaw', value: 'openclaw' },
{ label: t('settings.mcp.clients.other'), value: 'other' },
+1 -1
View File
@@ -568,7 +568,7 @@
"clientLabel": "MCP Client",
"copy": "Copy",
"copied": "Copied",
"claudeHint": "Add this to the claude_desktop_config.json file in Claude Desktop.",
"claudeHint": "Add this config to ClaudeCode's MCP configuration.",
"codexHint": "Add this TOML config to your ~/.codex/config.toml file.",
"openclawHint": "Add this config to your project's openclaw.json file.",
"otherHint": "Add this JSON config to your MCP client configuration file."
+1 -1
View File
@@ -568,7 +568,7 @@
"clientLabel": "MCP クライアント",
"copy": "コピー",
"copied": "コピー済み",
"claudeHint": "Claude Desktop の claude_desktop_config.json ファイルにこの設定を追加してください。",
"claudeHint": "この設定を ClaudeCode の MCP 設定に追加してください。",
"codexHint": "この TOML 設定を ~/.codex/config.toml ファイルに追加してください。",
"openclawHint": "この設定をプロジェクトの openclaw.json ファイルに追加してください。",
"otherHint": "この JSON 設定を MCP クライアントの設定ファイルに追加してください。"
+1 -1
View File
@@ -568,7 +568,7 @@
"clientLabel": "MCP 客户端",
"copy": "复制",
"copied": "已复制",
"claudeHint": "将此配置添加到 Claude Desktop 的 claude_desktop_config.json 文件中。",
"claudeHint": "将此配置添加到 ClaudeCode 的 MCP 配置中。",
"codexHint": "将此 TOML 配置添加到 ~/.codex/config.toml 文件中。",
"openclawHint": "将此配置添加到项目的 openclaw.json 文件中。",
"otherHint": "将此 JSON 配置添加到你的 MCP 客户端配置文件中。"
+1 -1
View File
@@ -568,7 +568,7 @@
"clientLabel": "MCP 用戶端",
"copy": "複製",
"copied": "已複製",
"claudeHint": "將此設定新增至 Claude Desktop 的 claude_desktop_config.json 檔案中。",
"claudeHint": "將此設定新增至 ClaudeCode 的 MCP 設定中。",
"codexHint": "將此 TOML 設定新增至 ~/.codex/config.toml 檔案中。",
"openclawHint": "將此設定新增至專案的 openclaw.json 檔案中。",
"otherHint": "將此 JSON 設定新增到你的 MCP 用戶端設定檔中。"
+1
View File
@@ -1,6 +1,7 @@
{
"extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
"include": ["src/env.d.ts", "src/**/*", "apps/desktop/preload/**/*.d.ts", "packages/**/*"],
"exclude": ["**/dist/**", "packages/*/bin/**"],
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",