@wener/mcps 1.0.2 → 1.0.5
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/README.md +144 -0
- package/dist/index.mjs +213076 -1
- package/dist/mcps-cli.mjs +102632 -59429
- package/lib/audit/AuditContract.js.map +1 -0
- package/lib/{chat/audit.js → audit/chat.js} +1 -1
- package/lib/audit/chat.js.map +1 -0
- package/lib/audit/entities/ChatRequestEntity.js.map +1 -0
- package/lib/audit/entities/McpRequestEntity.js.map +1 -0
- package/lib/audit/entities/RequestLogEntity.js.map +1 -0
- package/lib/audit/entities/ResponseEntity.js.map +1 -0
- package/lib/audit/entities/index.js +6 -0
- package/lib/audit/entities/index.js.map +1 -0
- package/lib/audit/server/db.js +64 -0
- package/lib/audit/server/db.js.map +1 -0
- package/lib/audit/server/index.js +2 -0
- package/lib/audit/server/index.js.map +1 -0
- package/lib/{server/audit.js → audit/server/plugin.js} +73 -127
- package/lib/audit/server/plugin.js.map +1 -0
- package/lib/audit/types.js.map +1 -0
- package/lib/chat/handler.js +5 -5
- package/lib/chat/handler.js.map +1 -1
- package/lib/chat/index.js +1 -1
- package/lib/chat/index.js.map +1 -1
- package/lib/cli-start.js +36 -0
- package/lib/cli-start.js.map +1 -0
- package/lib/cli.js +19 -0
- package/lib/cli.js.map +1 -0
- package/lib/contracts/index.js +1 -1
- package/lib/contracts/index.js.map +1 -1
- package/lib/dev.server.js +7 -1
- package/lib/dev.server.js.map +1 -1
- package/lib/entities/index.js +2 -10
- package/lib/entities/index.js.map +1 -1
- package/lib/index.js +21 -3
- package/lib/index.js.map +1 -1
- package/lib/mcps-cli.js +6 -35
- package/lib/mcps-cli.js.map +1 -1
- package/lib/providers/feishu/def.js +35 -0
- package/lib/providers/feishu/def.js.map +1 -0
- package/lib/providers/findMcpServerDef.js +1 -0
- package/lib/providers/findMcpServerDef.js.map +1 -1
- package/lib/scripts/bundle.js +7 -1
- package/lib/scripts/bundle.js.map +1 -1
- package/lib/server/api-routes.js +7 -8
- package/lib/server/api-routes.js.map +1 -1
- package/lib/server/events.js +13 -0
- package/lib/server/events.js.map +1 -0
- package/lib/server/mcp-routes.js +31 -60
- package/lib/server/mcp-routes.js.map +1 -1
- package/lib/server/mcps-router.js +19 -24
- package/lib/server/mcps-router.js.map +1 -1
- package/lib/server/schema.js +22 -2
- package/lib/server/schema.js.map +1 -1
- package/lib/server/server.js +142 -87
- package/lib/server/server.js.map +1 -1
- package/package.json +145 -85
- package/src/{chat/audit.ts → audit/chat.ts} +3 -3
- package/src/audit/entities/index.ts +6 -0
- package/src/audit/server/db.ts +65 -0
- package/src/audit/server/index.ts +8 -0
- package/src/{server/audit.ts → audit/server/plugin.ts} +71 -144
- package/src/chat/handler.ts +5 -5
- package/src/chat/index.ts +1 -1
- package/src/cli-start.ts +43 -0
- package/src/cli.ts +45 -0
- package/src/contracts/index.ts +1 -1
- package/src/dev.server.ts +8 -1
- package/src/entities/index.ts +2 -12
- package/src/index.ts +47 -1
- package/src/mcps-cli.ts +6 -48
- package/src/providers/feishu/def.ts +37 -0
- package/src/providers/findMcpServerDef.ts +1 -0
- package/src/scripts/bundle.ts +12 -1
- package/src/server/api-routes.ts +11 -8
- package/src/server/events.ts +29 -0
- package/src/server/mcp-routes.ts +30 -58
- package/src/server/mcps-router.ts +21 -29
- package/src/server/schema.ts +23 -2
- package/src/server/server.ts +149 -81
- package/LICENSE +0 -21
- package/lib/chat/audit.js.map +0 -1
- package/lib/contracts/AuditContract.js.map +0 -1
- package/lib/entities/ChatRequestEntity.js.map +0 -1
- package/lib/entities/McpRequestEntity.js.map +0 -1
- package/lib/entities/RequestLogEntity.js.map +0 -1
- package/lib/entities/ResponseEntity.js.map +0 -1
- package/lib/entities/types.js.map +0 -1
- package/lib/server/audit.js.map +0 -1
- package/lib/server/db.js +0 -97
- package/lib/server/db.js.map +0 -1
- package/src/server/db.ts +0 -115
- /package/lib/{contracts → audit}/AuditContract.js +0 -0
- /package/lib/{entities → audit/entities}/ChatRequestEntity.js +0 -0
- /package/lib/{entities → audit/entities}/McpRequestEntity.js +0 -0
- /package/lib/{entities → audit/entities}/RequestLogEntity.js +0 -0
- /package/lib/{entities → audit/entities}/ResponseEntity.js +0 -0
- /package/lib/{entities → audit}/types.js +0 -0
- /package/src/{contracts → audit}/AuditContract.ts +0 -0
- /package/src/{entities → audit/entities}/ChatRequestEntity.ts +0 -0
- /package/src/{entities → audit/entities}/McpRequestEntity.ts +0 -0
- /package/src/{entities → audit/entities}/RequestLogEntity.ts +0 -0
- /package/src/{entities → audit/entities}/ResponseEntity.ts +0 -0
- /package/src/{entities → audit}/types.ts +0 -0
package/package.json
CHANGED
|
@@ -1,86 +1,146 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
2
|
+
"name": "@wener/mcps",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "",
|
|
6
|
+
"author": "",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcps": "./dist/mcps-cli.mjs"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.mjs",
|
|
11
|
+
"imports": {
|
|
12
|
+
"#/*": "./*"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./src/index.ts",
|
|
16
|
+
"./server": "./src/server/index.ts",
|
|
17
|
+
"./entities": "./src/audit/entities/index.ts",
|
|
18
|
+
"./contracts": "./src/contracts/index.ts",
|
|
19
|
+
"./chat": "./src/chat/index.ts",
|
|
20
|
+
"./providers": "./src/providers/McpServerHandlerDef.ts",
|
|
21
|
+
"./cli": "./src/cli.ts",
|
|
22
|
+
"./audit/server": "./src/audit/server/index.ts"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"lib",
|
|
27
|
+
"src",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"keywords": [],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "bun run ./src/scripts/bundle.ts",
|
|
33
|
+
"dev": "pnpm tsx --watch src/mcps-cli.ts",
|
|
34
|
+
"dev:web": "vite",
|
|
35
|
+
"prepublishOnly": "make build",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@mikro-orm/core": "*",
|
|
41
|
+
"@mikro-orm/decorators": "*",
|
|
42
|
+
"@mikro-orm/sql": "*",
|
|
43
|
+
"@wener/server": "*"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@mikro-orm/core": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"@mikro-orm/decorators": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"@mikro-orm/sql": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"@wener/server": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"emittery": "^1.2.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@ai-sdk/mcp": "^1.0.18",
|
|
64
|
+
"@ai-sdk/openai-compatible": "^2.0.26",
|
|
65
|
+
"@ai-sdk/react": "^3.0.71",
|
|
66
|
+
"@base-ui/react": "^1.1.0",
|
|
67
|
+
"@hono/mcp": "^0.2.3",
|
|
68
|
+
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
69
|
+
"@hono/node-server": "^1.19.9",
|
|
70
|
+
"@hono/vite-dev-server": "^0.24.1",
|
|
71
|
+
"@mikro-orm/core": "^7.0.0-rc.2",
|
|
72
|
+
"@mikro-orm/decorators": "^7.0.0-rc.2",
|
|
73
|
+
"@mikro-orm/sql": "^7.0.0-rc.2",
|
|
74
|
+
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
75
|
+
"@orpc/client": "^1.13.4",
|
|
76
|
+
"@orpc/contract": "^1.13.4",
|
|
77
|
+
"@orpc/json-schema": "^1.13.4",
|
|
78
|
+
"@orpc/openapi": "^1.13.4",
|
|
79
|
+
"@orpc/server": "^1.13.4",
|
|
80
|
+
"@orpc/zod": "^1.13.4",
|
|
81
|
+
"@streamdown/cjk": "^1.0.1",
|
|
82
|
+
"@streamdown/code": "^1.0.1",
|
|
83
|
+
"@streamdown/math": "^1.0.1",
|
|
84
|
+
"@streamdown/mermaid": "^1.0.1",
|
|
85
|
+
"@wener/ai": "workspace:*",
|
|
86
|
+
"@wener/client": "workspace:^1.0.26",
|
|
87
|
+
"@wener/common": "^2.0.3",
|
|
88
|
+
"@wener/server": "workspace:*",
|
|
89
|
+
"ai": "^6.0.69",
|
|
90
|
+
"commander": "^14.0.3",
|
|
91
|
+
"consola": "^3.4.2",
|
|
92
|
+
"hono": "^4.11.7",
|
|
93
|
+
"kysely": "^0.28.11",
|
|
94
|
+
"lru-cache": "^11.2.5",
|
|
95
|
+
"lucide-react": "^0.562.0",
|
|
96
|
+
"mysql2": "^3.16.3",
|
|
97
|
+
"openai": "^6.17.0",
|
|
98
|
+
"pg-query-stream": "^4.12.0",
|
|
99
|
+
"react": "^19.2.4",
|
|
100
|
+
"react-dom": "^19.2.4",
|
|
101
|
+
"react-markdown": "^10.1.0",
|
|
102
|
+
"react-router-dom": "^7.13.0",
|
|
103
|
+
"std-env": "^3.10.0",
|
|
104
|
+
"streamdown": "^2.1.0",
|
|
105
|
+
"tarn": "^3.0.2",
|
|
106
|
+
"tedious": "^19.2.0",
|
|
107
|
+
"yaml": "^2.8.2",
|
|
108
|
+
"zod": "^4.3.6"
|
|
109
|
+
},
|
|
110
|
+
"publishConfig": {
|
|
111
|
+
"exports": {
|
|
112
|
+
".": {
|
|
113
|
+
"types": "./src/index.ts",
|
|
114
|
+
"default": "./lib/index.js"
|
|
115
|
+
},
|
|
116
|
+
"./server": {
|
|
117
|
+
"types": "./src/server/index.ts",
|
|
118
|
+
"default": "./lib/server/index.js"
|
|
119
|
+
},
|
|
120
|
+
"./entities": {
|
|
121
|
+
"types": "./src/audit/entities/index.ts",
|
|
122
|
+
"default": "./lib/audit/entities/index.js"
|
|
123
|
+
},
|
|
124
|
+
"./contracts": {
|
|
125
|
+
"types": "./src/contracts/index.ts",
|
|
126
|
+
"default": "./lib/contracts/index.js"
|
|
127
|
+
},
|
|
128
|
+
"./chat": {
|
|
129
|
+
"types": "./src/chat/index.ts",
|
|
130
|
+
"default": "./lib/chat/index.js"
|
|
131
|
+
},
|
|
132
|
+
"./providers": {
|
|
133
|
+
"types": "./src/providers/McpServerHandlerDef.ts",
|
|
134
|
+
"default": "./lib/providers/McpServerHandlerDef.js"
|
|
135
|
+
},
|
|
136
|
+
"./cli": {
|
|
137
|
+
"types": "./src/cli.ts",
|
|
138
|
+
"default": "./lib/cli.js"
|
|
139
|
+
},
|
|
140
|
+
"./audit/server": {
|
|
141
|
+
"types": "./src/audit/server/index.ts",
|
|
142
|
+
"default": "./lib/audit/server/index.js"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Context } from 'hono';
|
|
6
6
|
import consola from 'consola';
|
|
7
|
-
import type { ChatProtocolType, RequestStatus as RequestStatusType, ChatAuditStats } from '
|
|
7
|
+
import type { ChatProtocolType, RequestStatus as RequestStatusType, ChatAuditStats } from './types';
|
|
8
8
|
|
|
9
9
|
const log = consola.withTag('chat-audit');
|
|
10
10
|
|
|
@@ -77,7 +77,7 @@ export interface ChatAuditStore {
|
|
|
77
77
|
/**
|
|
78
78
|
* Get aggregate statistics
|
|
79
79
|
*/
|
|
80
|
-
getStats(options: { from?: Date; to?: Date }): Promise<
|
|
80
|
+
getStats(options: { from?: Date; to?: Date }): Promise<ChatAuditStats>;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export interface ChatAuditQueryOptions {
|
|
@@ -93,7 +93,7 @@ export interface ChatAuditQueryOptions {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// Re-export ChatAuditStats from entities
|
|
96
|
-
export type { ChatAuditStats } from '
|
|
96
|
+
export type { ChatAuditStats } from './types';
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* In-memory audit store implementation
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from '../types';
|
|
2
|
+
|
|
3
|
+
export { ChatRequestEntity, ChatProtocolType, RequestStatus } from './ChatRequestEntity';
|
|
4
|
+
export { McpRequestEntity, McpServerType, McpRequestType } from './McpRequestEntity';
|
|
5
|
+
export { RequestLogEntity } from './RequestLogEntity';
|
|
6
|
+
export { ResponseEntity } from './ResponseEntity';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { MikroORM, type Options } from '@mikro-orm/core';
|
|
2
|
+
import { SqliteDriver } from '@mikro-orm/sql';
|
|
3
|
+
import { createSqliteDialect } from '@wener/server/mikro-orm';
|
|
4
|
+
import type { DbConfig } from '../../server/schema';
|
|
5
|
+
import { ChatRequestEntity } from '../entities/ChatRequestEntity';
|
|
6
|
+
import { McpRequestEntity } from '../entities/McpRequestEntity';
|
|
7
|
+
import { RequestLogEntity } from '../entities/RequestLogEntity';
|
|
8
|
+
import { ResponseEntity } from '../entities/ResponseEntity';
|
|
9
|
+
|
|
10
|
+
export { RequestLogEntity };
|
|
11
|
+
|
|
12
|
+
let orm: MikroORM<SqliteDriver> | null = null;
|
|
13
|
+
let initPromise: Promise<MikroORM<SqliteDriver>> | null = null;
|
|
14
|
+
|
|
15
|
+
async function getOrmConfig(dbConfig?: DbConfig): Promise<Options<SqliteDriver>> {
|
|
16
|
+
const dbPath = dbConfig?.path || '.mcps.db';
|
|
17
|
+
return {
|
|
18
|
+
driver: SqliteDriver,
|
|
19
|
+
dbName: dbPath,
|
|
20
|
+
entities: [ChatRequestEntity, McpRequestEntity, RequestLogEntity, ResponseEntity],
|
|
21
|
+
driverOptions: await createSqliteDialect(dbPath),
|
|
22
|
+
debug: process.env.NODE_ENV === 'development',
|
|
23
|
+
allowGlobalContext: true,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function ensureDbInitialized(dbConfig?: DbConfig): Promise<MikroORM<SqliteDriver>> {
|
|
28
|
+
if (orm) return orm;
|
|
29
|
+
if (initPromise) return initPromise;
|
|
30
|
+
|
|
31
|
+
initPromise = (async () => {
|
|
32
|
+
const config = await getOrmConfig(dbConfig);
|
|
33
|
+
orm = await MikroORM.init(config);
|
|
34
|
+
await orm.schema.update();
|
|
35
|
+
return orm;
|
|
36
|
+
})();
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
return await initPromise;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
initPromise = null;
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getOrm(): MikroORM<SqliteDriver> {
|
|
47
|
+
if (!orm) throw new Error('Database not initialized');
|
|
48
|
+
return orm;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getEntityManager() {
|
|
52
|
+
return getOrm().em;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function closeDb(): Promise<void> {
|
|
56
|
+
if (orm) {
|
|
57
|
+
await orm.close();
|
|
58
|
+
orm = null;
|
|
59
|
+
initPromise = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function isDbInitialized(): boolean {
|
|
64
|
+
return orm !== null;
|
|
65
|
+
}
|