@wener/mcps 1.0.1 → 1.0.4
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.
Potentially problematic release.
This version of @wener/mcps might be problematic. Click here for more details.
- package/README.md +144 -0
- package/dist/index.mjs +213076 -1
- package/dist/mcps-cli.mjs +102547 -59344
- package/lib/chat/handler.js +2 -2
- package/lib/chat/handler.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/dev.server.js +7 -1
- package/lib/dev.server.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/audit-db.js +64 -0
- package/lib/server/audit-db.js.map +1 -0
- package/lib/server/{audit.js → audit-plugin.js} +72 -126
- package/lib/server/audit-plugin.js.map +1 -0
- 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 +35 -5
- package/src/chat/handler.ts +2 -2
- package/src/cli-start.ts +43 -0
- package/src/cli.ts +45 -0
- package/src/dev.server.ts +8 -1
- 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/audit-db.ts +65 -0
- package/src/server/{audit.ts → audit-plugin.ts} +69 -142
- 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/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/server/db.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { MikroORM } from "@mikro-orm/core";
|
|
2
|
-
import { SqliteDriver } from "@mikro-orm/sqlite";
|
|
3
|
-
import { ChatRequestEntity } from "../entities/ChatRequestEntity.js";
|
|
4
|
-
import { McpRequestEntity } from "../entities/McpRequestEntity.js";
|
|
5
|
-
import { RequestLogEntity } from "../entities/RequestLogEntity.js";
|
|
6
|
-
import { ResponseEntity } from "../entities/ResponseEntity.js";
|
|
7
|
-
let orm = null;
|
|
8
|
-
let initPromise = null;
|
|
9
|
-
let storedDbConfig;
|
|
10
|
-
/**
|
|
11
|
-
* Get MikroORM configuration
|
|
12
|
-
*/ export function getOrmConfig(dbConfig) {
|
|
13
|
-
const dbPath = dbConfig?.path || ".mcps.db";
|
|
14
|
-
return {
|
|
15
|
-
driver: SqliteDriver,
|
|
16
|
-
dbName: dbPath,
|
|
17
|
-
entities: [
|
|
18
|
-
ChatRequestEntity,
|
|
19
|
-
McpRequestEntity,
|
|
20
|
-
RequestLogEntity,
|
|
21
|
-
ResponseEntity
|
|
22
|
-
],
|
|
23
|
-
// Enable debug in development
|
|
24
|
-
debug: process.env.NODE_ENV === "development",
|
|
25
|
-
// Allow global context for simpler usage
|
|
26
|
-
allowGlobalContext: true
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Initialize MikroORM and sync schema
|
|
31
|
-
*/ export async function initializeDb(dbConfig) {
|
|
32
|
-
if (orm) {
|
|
33
|
-
return orm;
|
|
34
|
-
}
|
|
35
|
-
// If already initializing, wait for the existing promise
|
|
36
|
-
if (initPromise) {
|
|
37
|
-
return initPromise;
|
|
38
|
-
}
|
|
39
|
-
storedDbConfig = dbConfig;
|
|
40
|
-
initPromise = (async () => {
|
|
41
|
-
const config = getOrmConfig(dbConfig);
|
|
42
|
-
orm = await MikroORM.init(config);
|
|
43
|
-
// Sync schema (create tables if not exist)
|
|
44
|
-
await orm.schema.update();
|
|
45
|
-
return orm;
|
|
46
|
-
})();
|
|
47
|
-
try {
|
|
48
|
-
return await initPromise;
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
// Reset on failure so retry is possible
|
|
52
|
-
initPromise = null;
|
|
53
|
-
throw e;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Configure DB for lazy initialization (stores config without initializing)
|
|
58
|
-
*/ export function configureDb(dbConfig) {
|
|
59
|
-
storedDbConfig = dbConfig;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Ensure DB is initialized (lazy init on first call)
|
|
63
|
-
* Returns the ORM instance, initializing if needed
|
|
64
|
-
*/ export async function ensureDbInitialized() {
|
|
65
|
-
if (orm) {
|
|
66
|
-
return orm;
|
|
67
|
-
}
|
|
68
|
-
return initializeDb(storedDbConfig);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get MikroORM instance (must be initialized first)
|
|
72
|
-
*/ export function getOrm() {
|
|
73
|
-
if (!orm) {
|
|
74
|
-
throw new Error("Database not initialized. Call initializeDb() first.");
|
|
75
|
-
}
|
|
76
|
-
return orm;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Get EntityManager
|
|
80
|
-
*/ export function getEntityManager() {
|
|
81
|
-
return getOrm().em;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Close database connection
|
|
85
|
-
*/ export async function closeDb() {
|
|
86
|
-
if (orm) {
|
|
87
|
-
await orm.close();
|
|
88
|
-
orm = null;
|
|
89
|
-
initPromise = null;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Check if database is initialized
|
|
94
|
-
*/ export function isDbInitialized() {
|
|
95
|
-
return orm !== null;
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=db.js.map
|
package/lib/server/db.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/db.ts"],"sourcesContent":["import { MikroORM, type Options } from '@mikro-orm/core';\nimport { SqliteDriver } from '@mikro-orm/sqlite';\nimport { ChatRequestEntity } from '../entities/ChatRequestEntity';\nimport { McpRequestEntity } from '../entities/McpRequestEntity';\nimport { RequestLogEntity } from '../entities/RequestLogEntity';\nimport { ResponseEntity } from '../entities/ResponseEntity';\nimport type { DbConfig } from './schema';\n\nlet orm: MikroORM<SqliteDriver> | null = null;\nlet initPromise: Promise<MikroORM<SqliteDriver>> | null = null;\nlet storedDbConfig: DbConfig | undefined;\n\n/**\n * Get MikroORM configuration\n */\nexport function getOrmConfig(dbConfig?: DbConfig): Options<SqliteDriver> {\n\tconst dbPath = dbConfig?.path || '.mcps.db';\n\n\treturn {\n\t\tdriver: SqliteDriver,\n\t\tdbName: dbPath,\n\t\tentities: [ChatRequestEntity, McpRequestEntity, RequestLogEntity, ResponseEntity],\n\t\t// Enable debug in development\n\t\tdebug: process.env.NODE_ENV === 'development',\n\t\t// Allow global context for simpler usage\n\t\tallowGlobalContext: true,\n\t};\n}\n\n/**\n * Initialize MikroORM and sync schema\n */\nexport async function initializeDb(dbConfig?: DbConfig): Promise<MikroORM<SqliteDriver>> {\n\tif (orm) {\n\t\treturn orm;\n\t}\n\n\t// If already initializing, wait for the existing promise\n\tif (initPromise) {\n\t\treturn initPromise;\n\t}\n\n\tstoredDbConfig = dbConfig;\n\n\tinitPromise = (async () => {\n\t\tconst config = getOrmConfig(dbConfig);\n\t\torm = await MikroORM.init(config);\n\n\t\t// Sync schema (create tables if not exist)\n\t\tawait orm.schema.update();\n\n\t\treturn orm;\n\t})();\n\n\ttry {\n\t\treturn await initPromise;\n\t} catch (e) {\n\t\t// Reset on failure so retry is possible\n\t\tinitPromise = null;\n\t\tthrow e;\n\t}\n}\n\n/**\n * Configure DB for lazy initialization (stores config without initializing)\n */\nexport function configureDb(dbConfig?: DbConfig): void {\n\tstoredDbConfig = dbConfig;\n}\n\n/**\n * Ensure DB is initialized (lazy init on first call)\n * Returns the ORM instance, initializing if needed\n */\nexport async function ensureDbInitialized(): Promise<MikroORM<SqliteDriver>> {\n\tif (orm) {\n\t\treturn orm;\n\t}\n\treturn initializeDb(storedDbConfig);\n}\n\n/**\n * Get MikroORM instance (must be initialized first)\n */\nexport function getOrm(): MikroORM<SqliteDriver> {\n\tif (!orm) {\n\t\tthrow new Error('Database not initialized. Call initializeDb() first.');\n\t}\n\treturn orm;\n}\n\n/**\n * Get EntityManager\n */\nexport function getEntityManager() {\n\treturn getOrm().em;\n}\n\n/**\n * Close database connection\n */\nexport async function closeDb(): Promise<void> {\n\tif (orm) {\n\t\tawait orm.close();\n\t\torm = null;\n\t\tinitPromise = null;\n\t}\n}\n\n/**\n * Check if database is initialized\n */\nexport function isDbInitialized(): boolean {\n\treturn orm !== null;\n}\n"],"names":["MikroORM","SqliteDriver","ChatRequestEntity","McpRequestEntity","RequestLogEntity","ResponseEntity","orm","initPromise","storedDbConfig","getOrmConfig","dbConfig","dbPath","path","driver","dbName","entities","debug","process","env","NODE_ENV","allowGlobalContext","initializeDb","config","init","schema","update","e","configureDb","ensureDbInitialized","getOrm","Error","getEntityManager","em","closeDb","close","isDbInitialized"],"mappings":"AAAA,SAASA,QAAQ,QAAsB,kBAAkB;AACzD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,S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AK;QACf5B,MAAM;QACNC,cAAc;IACf;AACD;AAEA;;CAEC,GACD,OAAO,SAAS4B;IACf,OAAO7B,QAAQ;AAChB"}
|
package/src/server/db.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { MikroORM, type Options } from '@mikro-orm/core';
|
|
2
|
-
import { SqliteDriver } from '@mikro-orm/sqlite';
|
|
3
|
-
import { ChatRequestEntity } from '../entities/ChatRequestEntity';
|
|
4
|
-
import { McpRequestEntity } from '../entities/McpRequestEntity';
|
|
5
|
-
import { RequestLogEntity } from '../entities/RequestLogEntity';
|
|
6
|
-
import { ResponseEntity } from '../entities/ResponseEntity';
|
|
7
|
-
import type { DbConfig } from './schema';
|
|
8
|
-
|
|
9
|
-
let orm: MikroORM<SqliteDriver> | null = null;
|
|
10
|
-
let initPromise: Promise<MikroORM<SqliteDriver>> | null = null;
|
|
11
|
-
let storedDbConfig: DbConfig | undefined;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Get MikroORM configuration
|
|
15
|
-
*/
|
|
16
|
-
export function getOrmConfig(dbConfig?: DbConfig): Options<SqliteDriver> {
|
|
17
|
-
const dbPath = dbConfig?.path || '.mcps.db';
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
driver: SqliteDriver,
|
|
21
|
-
dbName: dbPath,
|
|
22
|
-
entities: [ChatRequestEntity, McpRequestEntity, RequestLogEntity, ResponseEntity],
|
|
23
|
-
// Enable debug in development
|
|
24
|
-
debug: process.env.NODE_ENV === 'development',
|
|
25
|
-
// Allow global context for simpler usage
|
|
26
|
-
allowGlobalContext: true,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Initialize MikroORM and sync schema
|
|
32
|
-
*/
|
|
33
|
-
export async function initializeDb(dbConfig?: DbConfig): Promise<MikroORM<SqliteDriver>> {
|
|
34
|
-
if (orm) {
|
|
35
|
-
return orm;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// If already initializing, wait for the existing promise
|
|
39
|
-
if (initPromise) {
|
|
40
|
-
return initPromise;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
storedDbConfig = dbConfig;
|
|
44
|
-
|
|
45
|
-
initPromise = (async () => {
|
|
46
|
-
const config = getOrmConfig(dbConfig);
|
|
47
|
-
orm = await MikroORM.init(config);
|
|
48
|
-
|
|
49
|
-
// Sync schema (create tables if not exist)
|
|
50
|
-
await orm.schema.update();
|
|
51
|
-
|
|
52
|
-
return orm;
|
|
53
|
-
})();
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
return await initPromise;
|
|
57
|
-
} catch (e) {
|
|
58
|
-
// Reset on failure so retry is possible
|
|
59
|
-
initPromise = null;
|
|
60
|
-
throw e;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Configure DB for lazy initialization (stores config without initializing)
|
|
66
|
-
*/
|
|
67
|
-
export function configureDb(dbConfig?: DbConfig): void {
|
|
68
|
-
storedDbConfig = dbConfig;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Ensure DB is initialized (lazy init on first call)
|
|
73
|
-
* Returns the ORM instance, initializing if needed
|
|
74
|
-
*/
|
|
75
|
-
export async function ensureDbInitialized(): Promise<MikroORM<SqliteDriver>> {
|
|
76
|
-
if (orm) {
|
|
77
|
-
return orm;
|
|
78
|
-
}
|
|
79
|
-
return initializeDb(storedDbConfig);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get MikroORM instance (must be initialized first)
|
|
84
|
-
*/
|
|
85
|
-
export function getOrm(): MikroORM<SqliteDriver> {
|
|
86
|
-
if (!orm) {
|
|
87
|
-
throw new Error('Database not initialized. Call initializeDb() first.');
|
|
88
|
-
}
|
|
89
|
-
return orm;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Get EntityManager
|
|
94
|
-
*/
|
|
95
|
-
export function getEntityManager() {
|
|
96
|
-
return getOrm().em;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Close database connection
|
|
101
|
-
*/
|
|
102
|
-
export async function closeDb(): Promise<void> {
|
|
103
|
-
if (orm) {
|
|
104
|
-
await orm.close();
|
|
105
|
-
orm = null;
|
|
106
|
-
initPromise = null;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Check if database is initialized
|
|
112
|
-
*/
|
|
113
|
-
export function isDbInitialized(): boolean {
|
|
114
|
-
return orm !== null;
|
|
115
|
-
}
|