koishi-plugin-chatluna-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/LICENSE +25 -0
- package/lib/config.d.ts +20 -0
- package/lib/index.cjs +859 -0
- package/lib/index.mjs +838 -0
- package/lib/plugins/config.d.ts +3 -0
- package/lib/plugins.d.ts +3 -0
- package/lib/service/mcp.d.ts +42 -0
- package/lib/utils.d.ts +4 -0
- package/package.json +111 -0
- package/readme.md +24 -0
package/lib/plugins.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Context, Logger } from 'koishi';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare class McpServerBridge {
|
|
4
|
+
private ctx;
|
|
5
|
+
private config;
|
|
6
|
+
private logger;
|
|
7
|
+
private endpointPath;
|
|
8
|
+
private tools;
|
|
9
|
+
private sessions;
|
|
10
|
+
private refreshing;
|
|
11
|
+
private refreshQueued;
|
|
12
|
+
private modelCache;
|
|
13
|
+
private embeddingsCache;
|
|
14
|
+
constructor(ctx: Context, config: Config, logger: Logger);
|
|
15
|
+
init(): Promise<void>;
|
|
16
|
+
dispose(): Promise<void>;
|
|
17
|
+
private bindEvents;
|
|
18
|
+
private registerRoutes;
|
|
19
|
+
private buildAccessUrl;
|
|
20
|
+
private refreshTools;
|
|
21
|
+
private collectTools;
|
|
22
|
+
private createSessionState;
|
|
23
|
+
private registerInitialTools;
|
|
24
|
+
private syncSessionTools;
|
|
25
|
+
private registerTool;
|
|
26
|
+
private handleToolCall;
|
|
27
|
+
private extractMeta;
|
|
28
|
+
private extractMetaFromRoot;
|
|
29
|
+
private normalizeMetaRoot;
|
|
30
|
+
private extractToolInputMeta;
|
|
31
|
+
private applyMetaDefaults;
|
|
32
|
+
private buildSession;
|
|
33
|
+
private buildDefaultSessionPayload;
|
|
34
|
+
private resolveBot;
|
|
35
|
+
private getBotList;
|
|
36
|
+
private parseBotTarget;
|
|
37
|
+
private resolveModelName;
|
|
38
|
+
private resolveEmbeddingsName;
|
|
39
|
+
private getModel;
|
|
40
|
+
private getEmbeddings;
|
|
41
|
+
private extendToolSchema;
|
|
42
|
+
}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function normalizeEndpointPath(path: string): string;
|
|
2
|
+
export declare function getHeaderValue(headers: Record<string, string | string[] | undefined>, name: string): string | undefined;
|
|
3
|
+
export declare function parseJsonPayload(value: unknown): Record<string, unknown> | null;
|
|
4
|
+
export declare function formatToolOutput(output: unknown): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-chatluna-mcp-server",
|
|
3
|
+
"description": "ChatLuna MCP Server, expose ChatLuna tools as MCP support",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.cjs",
|
|
7
|
+
"module": "lib/index.mjs",
|
|
8
|
+
"typings": "lib/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"import": "./lib/index.mjs",
|
|
13
|
+
"require": "./lib/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib",
|
|
19
|
+
"dist",
|
|
20
|
+
"resources",
|
|
21
|
+
"client"
|
|
22
|
+
],
|
|
23
|
+
"license": "AGPL-3.0",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"chatbot",
|
|
26
|
+
"koishi",
|
|
27
|
+
"plugin",
|
|
28
|
+
"service",
|
|
29
|
+
"chatgpt",
|
|
30
|
+
"chatluna",
|
|
31
|
+
"preset",
|
|
32
|
+
"mcp",
|
|
33
|
+
"server"
|
|
34
|
+
],
|
|
35
|
+
"author": "dingyi222666 <dingyi222666@foxmail.com>",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/ChatLunaLab/chatluna-mcp-server.git",
|
|
39
|
+
"directory": "."
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/ChatLunaLab/chatluna-mcp-server/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/ChatLunaLab/chatluna-mcp-server#readme",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@langchain/core": "0.3.62",
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
48
|
+
"zod": "3.25.76"
|
|
49
|
+
},
|
|
50
|
+
"resolutions": {
|
|
51
|
+
"@langchain/core": "0.3.62",
|
|
52
|
+
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
|
|
53
|
+
},
|
|
54
|
+
"overrides": {
|
|
55
|
+
"@langchain/core": "0.3.62",
|
|
56
|
+
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
|
|
57
|
+
},
|
|
58
|
+
"pnpm": {
|
|
59
|
+
"overrides": {
|
|
60
|
+
"@langchain/core": "0.3.62",
|
|
61
|
+
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@koishijs/client": "^5.30.9",
|
|
66
|
+
"zod-to-json-schema": "^3.24.6",
|
|
67
|
+
"@satorijs/protocol": "^1.6.1",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^7.18.1-alpha.3",
|
|
69
|
+
"@typescript-eslint/parser": "^8.45.1-alpha.0",
|
|
70
|
+
"atsc": "^1.2.2",
|
|
71
|
+
"esbuild": "^0.25.10",
|
|
72
|
+
"esbuild-register": "^3.6.0",
|
|
73
|
+
"eslint": "^8.57.1",
|
|
74
|
+
"eslint-config-prettier": "^9.1.2",
|
|
75
|
+
"eslint-config-standard": "^17.1.0",
|
|
76
|
+
"eslint-plugin-import": "^2.32.0",
|
|
77
|
+
"eslint-plugin-n": "^16.6.2",
|
|
78
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
79
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
80
|
+
"koishi": "^4.18.9",
|
|
81
|
+
"yakumo": "^1.0.0",
|
|
82
|
+
"yakumo-esbuild": "^1.0.0",
|
|
83
|
+
"yakumo-mocha": "^1.0.0",
|
|
84
|
+
"yakumo-tsc": "^1.0.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"koishi": "^4.18.9",
|
|
88
|
+
"koishi-plugin-chatluna": "^1.3.6"
|
|
89
|
+
},
|
|
90
|
+
"engines": {
|
|
91
|
+
"node": ">=18.0.0"
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "yarn yakumo build",
|
|
95
|
+
"bump": "yarn yakumo version",
|
|
96
|
+
"dep": "yarn yakumo upgrade",
|
|
97
|
+
"pub": "yarn yakumo publish",
|
|
98
|
+
"lint": "yarn eslint src --ext=ts",
|
|
99
|
+
"lint-fix": "yarn eslint src --ext=ts --fix"
|
|
100
|
+
},
|
|
101
|
+
"koishi": {
|
|
102
|
+
"description": {
|
|
103
|
+
"zh": "ChatLuna MCP 服务端,将 ChatLuna 注册的工具公开为 MCP 支持。"
|
|
104
|
+
},
|
|
105
|
+
"service": {
|
|
106
|
+
"required": [
|
|
107
|
+
"chatluna"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# koishi-plugin-chatluna-mcp-server
|
|
4
|
+
|
|
5
|
+
_ChatLuna MCP Server_
|
|
6
|
+
|
|
7
|
+
## [](https://www.npmjs.com/package/koishi-plugin-chatluna-mcp-server) [](https://www.npmjs.com/package/koishi-plugin-chatluna-mcp-server)  
|
|
8
|
+
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
## 特性
|
|
12
|
+
|
|
13
|
+
1. 将 ChatLuna 的工具通过 MCP 协议公开
|
|
14
|
+
2. 支持自定义命令与拦截器
|
|
15
|
+
|
|
16
|
+
## 部署
|
|
17
|
+
|
|
18
|
+
在 Koishi 插件市场搜索 `chatluna-mcp-server`,安装后启用即可。
|
|
19
|
+
|
|
20
|
+
**插件依赖 ChatLuna,请确保在 ChatLuna 启动后再启用本插件。**
|
|
21
|
+
|
|
22
|
+
## 使用
|
|
23
|
+
|
|
24
|
+
待续
|