@veloxts/mcp 0.6.23
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 +21 -0
- package/dist/bin.d.ts +17 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +25 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/index.d.ts +8 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +7 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/templates.d.ts +75 -0
- package/dist/prompts/templates.d.ts.map +1 -0
- package/dist/prompts/templates.js +442 -0
- package/dist/prompts/templates.js.map +1 -0
- package/dist/resources/errors.d.ts +45 -0
- package/dist/resources/errors.d.ts.map +1 -0
- package/dist/resources/errors.js +117 -0
- package/dist/resources/errors.js.map +1 -0
- package/dist/resources/index.d.ts +14 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +10 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/procedures.d.ts +61 -0
- package/dist/resources/procedures.d.ts.map +1 -0
- package/dist/resources/procedures.js +147 -0
- package/dist/resources/procedures.js.map +1 -0
- package/dist/resources/routes.d.ts +44 -0
- package/dist/resources/routes.d.ts.map +1 -0
- package/dist/resources/routes.js +115 -0
- package/dist/resources/routes.js.map +1 -0
- package/dist/resources/schemas.d.ts +41 -0
- package/dist/resources/schemas.d.ts.map +1 -0
- package/dist/resources/schemas.js +143 -0
- package/dist/resources/schemas.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +371 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/generate.d.ts +64 -0
- package/dist/tools/generate.d.ts.map +1 -0
- package/dist/tools/generate.js +155 -0
- package/dist/tools/generate.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/migrate.d.ts +72 -0
- package/dist/tools/migrate.d.ts.map +1 -0
- package/dist/tools/migrate.js +163 -0
- package/dist/tools/migrate.js.map +1 -0
- package/dist/utils/project.d.ts +49 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +133 -0
- package/dist/utils/project.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedures Resource
|
|
3
|
+
*
|
|
4
|
+
* Exposes VeloxTS procedure information to AI tools.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Information about a single procedure
|
|
8
|
+
*/
|
|
9
|
+
export interface ProcedureInfo {
|
|
10
|
+
/** Procedure name (e.g., 'getUser') */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Namespace (e.g., 'users') */
|
|
13
|
+
namespace: string;
|
|
14
|
+
/** Procedure type: 'query' or 'mutation' */
|
|
15
|
+
type: 'query' | 'mutation';
|
|
16
|
+
/** Whether input schema is defined */
|
|
17
|
+
hasInputSchema: boolean;
|
|
18
|
+
/** Whether output schema is defined */
|
|
19
|
+
hasOutputSchema: boolean;
|
|
20
|
+
/** Number of guards applied */
|
|
21
|
+
guardCount: number;
|
|
22
|
+
/** Number of middlewares applied */
|
|
23
|
+
middlewareCount: number;
|
|
24
|
+
/** REST route info if applicable */
|
|
25
|
+
route?: {
|
|
26
|
+
method: string;
|
|
27
|
+
path: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Procedures resource response
|
|
32
|
+
*/
|
|
33
|
+
export interface ProceduresResourceResponse {
|
|
34
|
+
procedures: ProcedureInfo[];
|
|
35
|
+
namespaces: string[];
|
|
36
|
+
totalCount: number;
|
|
37
|
+
queries: number;
|
|
38
|
+
mutations: number;
|
|
39
|
+
discoveryInfo?: {
|
|
40
|
+
scannedFiles: number;
|
|
41
|
+
loadedFiles: number;
|
|
42
|
+
warnings: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Discover and return procedure information for a project
|
|
47
|
+
*/
|
|
48
|
+
export declare function getProcedures(projectRoot: string): Promise<ProceduresResourceResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Get procedures filtered by namespace
|
|
51
|
+
*/
|
|
52
|
+
export declare function getProceduresByNamespace(projectRoot: string, namespace: string): Promise<ProcedureInfo[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Get procedures filtered by type
|
|
55
|
+
*/
|
|
56
|
+
export declare function getProceduresByType(projectRoot: string, type: 'query' | 'mutation'): Promise<ProcedureInfo[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Format procedures response as text
|
|
59
|
+
*/
|
|
60
|
+
export declare function formatProceduresAsText(response: ProceduresResourceResponse): string;
|
|
61
|
+
//# sourceMappingURL=procedures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../src/resources/procedures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,sCAAsC;IACtC,cAAc,EAAE,OAAO,CAAC;IACxB,uCAAuC;IACvC,eAAe,EAAE,OAAO,CAAC;IACzB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,KAAK,CAAC,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAuDD;;GAEG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA8C5F;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,EAAE,CAAC,CAG1B;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,OAAO,GAAG,UAAU,GACzB,OAAO,CAAC,aAAa,EAAE,CAAC,CAG1B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,0BAA0B,GAAG,MAAM,CAuCnF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedures Resource
|
|
3
|
+
*
|
|
4
|
+
* Exposes VeloxTS procedure information to AI tools.
|
|
5
|
+
*/
|
|
6
|
+
import { discoverProceduresVerbose, getRouteSummary } from '@veloxts/router';
|
|
7
|
+
import { getProceduresPath } from '../utils/project.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Resource Handler
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Extract procedure information from collections
|
|
13
|
+
*/
|
|
14
|
+
function extractProcedureInfo(collections) {
|
|
15
|
+
const procedures = [];
|
|
16
|
+
const namespaces = [];
|
|
17
|
+
// Get route mappings using getRouteSummary
|
|
18
|
+
const routeSummary = getRouteSummary(collections, '/api');
|
|
19
|
+
const routeMap = new Map();
|
|
20
|
+
for (const route of routeSummary) {
|
|
21
|
+
routeMap.set(`${route.namespace}.${route.procedure}`, {
|
|
22
|
+
method: route.method,
|
|
23
|
+
path: route.path,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
for (const collection of collections) {
|
|
27
|
+
namespaces.push(collection.namespace);
|
|
28
|
+
for (const [name, procedure] of Object.entries(collection.procedures)) {
|
|
29
|
+
const info = {
|
|
30
|
+
name,
|
|
31
|
+
namespace: collection.namespace,
|
|
32
|
+
type: procedure.type,
|
|
33
|
+
hasInputSchema: !!procedure.inputSchema,
|
|
34
|
+
hasOutputSchema: !!procedure.outputSchema,
|
|
35
|
+
guardCount: procedure.guards?.length ?? 0,
|
|
36
|
+
middlewareCount: procedure.middlewares?.length ?? 0,
|
|
37
|
+
};
|
|
38
|
+
// Add route info if available
|
|
39
|
+
const routeKey = `${collection.namespace}.${name}`;
|
|
40
|
+
const route = routeMap.get(routeKey);
|
|
41
|
+
if (route) {
|
|
42
|
+
info.route = route;
|
|
43
|
+
}
|
|
44
|
+
procedures.push(info);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { procedures, namespaces };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Discover and return procedure information for a project
|
|
51
|
+
*/
|
|
52
|
+
export async function getProcedures(projectRoot) {
|
|
53
|
+
const proceduresPath = getProceduresPath(projectRoot);
|
|
54
|
+
if (!proceduresPath) {
|
|
55
|
+
return {
|
|
56
|
+
procedures: [],
|
|
57
|
+
namespaces: [],
|
|
58
|
+
totalCount: 0,
|
|
59
|
+
queries: 0,
|
|
60
|
+
mutations: 0,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let result;
|
|
64
|
+
try {
|
|
65
|
+
result = await discoverProceduresVerbose(proceduresPath, {
|
|
66
|
+
recursive: true,
|
|
67
|
+
onInvalidExport: 'warn',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return {
|
|
72
|
+
procedures: [],
|
|
73
|
+
namespaces: [],
|
|
74
|
+
totalCount: 0,
|
|
75
|
+
queries: 0,
|
|
76
|
+
mutations: 0,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const { procedures, namespaces } = extractProcedureInfo(result.collections);
|
|
80
|
+
const queries = procedures.filter((p) => p.type === 'query').length;
|
|
81
|
+
const mutations = procedures.filter((p) => p.type === 'mutation').length;
|
|
82
|
+
return {
|
|
83
|
+
procedures,
|
|
84
|
+
namespaces,
|
|
85
|
+
totalCount: procedures.length,
|
|
86
|
+
queries,
|
|
87
|
+
mutations,
|
|
88
|
+
discoveryInfo: {
|
|
89
|
+
scannedFiles: result.scannedFiles.length,
|
|
90
|
+
loadedFiles: result.loadedFiles.length,
|
|
91
|
+
warnings: result.warnings.length,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get procedures filtered by namespace
|
|
97
|
+
*/
|
|
98
|
+
export async function getProceduresByNamespace(projectRoot, namespace) {
|
|
99
|
+
const response = await getProcedures(projectRoot);
|
|
100
|
+
return response.procedures.filter((p) => p.namespace === namespace);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get procedures filtered by type
|
|
104
|
+
*/
|
|
105
|
+
export async function getProceduresByType(projectRoot, type) {
|
|
106
|
+
const response = await getProcedures(projectRoot);
|
|
107
|
+
return response.procedures.filter((p) => p.type === type);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Format procedures response as text
|
|
111
|
+
*/
|
|
112
|
+
export function formatProceduresAsText(response) {
|
|
113
|
+
const lines = [
|
|
114
|
+
'# VeloxTS Procedures',
|
|
115
|
+
'',
|
|
116
|
+
`Total: ${response.totalCount} (${response.queries} queries, ${response.mutations} mutations)`,
|
|
117
|
+
`Namespaces: ${response.namespaces.join(', ')}`,
|
|
118
|
+
'',
|
|
119
|
+
];
|
|
120
|
+
if (response.discoveryInfo) {
|
|
121
|
+
lines.push('## Discovery Info');
|
|
122
|
+
lines.push(`- Scanned files: ${response.discoveryInfo.scannedFiles}`);
|
|
123
|
+
lines.push(`- Loaded files: ${response.discoveryInfo.loadedFiles}`);
|
|
124
|
+
lines.push(`- Warnings: ${response.discoveryInfo.warnings}`);
|
|
125
|
+
lines.push('');
|
|
126
|
+
}
|
|
127
|
+
// Group by namespace
|
|
128
|
+
const byNamespace = new Map();
|
|
129
|
+
for (const proc of response.procedures) {
|
|
130
|
+
const list = byNamespace.get(proc.namespace) ?? [];
|
|
131
|
+
list.push(proc);
|
|
132
|
+
byNamespace.set(proc.namespace, list);
|
|
133
|
+
}
|
|
134
|
+
for (const [namespace, procs] of byNamespace) {
|
|
135
|
+
lines.push(`## ${namespace}`);
|
|
136
|
+
lines.push('');
|
|
137
|
+
for (const proc of procs) {
|
|
138
|
+
const type = proc.type === 'query' ? 'Q' : 'M';
|
|
139
|
+
const route = proc.route ? ` -> ${proc.route.method} ${proc.route.path}` : '';
|
|
140
|
+
const guards = proc.guardCount > 0 ? ` [${proc.guardCount} guards]` : '';
|
|
141
|
+
lines.push(`- [${type}] ${proc.name}${route}${guards}`);
|
|
142
|
+
}
|
|
143
|
+
lines.push('');
|
|
144
|
+
}
|
|
145
|
+
return lines.join('\n');
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=procedures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures.js","sourceRoot":"","sources":["../../src/resources/procedures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,yBAAyB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA+CxD,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,oBAAoB,CAAC,WAAkC;IAI9D,MAAM,UAAU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,KAAK,IAAI,CAAC,IAAI,GAAG,KAAK,GAAG,MAAM,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routes Resource
|
|
3
|
+
*
|
|
4
|
+
* Exposes REST route mappings to AI tools.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Route information for MCP response
|
|
8
|
+
*/
|
|
9
|
+
export interface RouteInfo {
|
|
10
|
+
/** HTTP method (GET, POST, PUT, PATCH, DELETE) */
|
|
11
|
+
method: string;
|
|
12
|
+
/** Route path (e.g., '/api/users/:id') */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Procedure namespace */
|
|
15
|
+
namespace: string;
|
|
16
|
+
/** Procedure name */
|
|
17
|
+
procedure: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Routes resource response
|
|
21
|
+
*/
|
|
22
|
+
export interface RoutesResourceResponse {
|
|
23
|
+
routes: RouteInfo[];
|
|
24
|
+
totalCount: number;
|
|
25
|
+
byMethod: Record<string, number>;
|
|
26
|
+
byNamespace: Record<string, number>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Discover and return route information for a project
|
|
30
|
+
*/
|
|
31
|
+
export declare function getRoutes(projectRoot: string): Promise<RoutesResourceResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Get routes filtered by HTTP method
|
|
34
|
+
*/
|
|
35
|
+
export declare function getRoutesByMethod(projectRoot: string, method: string): Promise<RouteInfo[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Get routes filtered by namespace
|
|
38
|
+
*/
|
|
39
|
+
export declare function getRoutesByNamespace(projectRoot: string, namespace: string): Promise<RouteInfo[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Format routes response as text
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatRoutesAsText(response: RoutesResourceResponse): string;
|
|
44
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/resources/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAMD;;GAEG;AACH,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAwDpF;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAGjG;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,SAAS,EAAE,CAAC,CAGtB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,CAuC3E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routes Resource
|
|
3
|
+
*
|
|
4
|
+
* Exposes REST route mappings to AI tools.
|
|
5
|
+
*/
|
|
6
|
+
import { discoverProceduresVerbose, getRouteSummary } from '@veloxts/router';
|
|
7
|
+
import { getProceduresPath } from '../utils/project.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Resource Handler
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Discover and return route information for a project
|
|
13
|
+
*/
|
|
14
|
+
export async function getRoutes(projectRoot) {
|
|
15
|
+
const proceduresPath = getProceduresPath(projectRoot);
|
|
16
|
+
if (!proceduresPath) {
|
|
17
|
+
return {
|
|
18
|
+
routes: [],
|
|
19
|
+
totalCount: 0,
|
|
20
|
+
byMethod: {},
|
|
21
|
+
byNamespace: {},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
let collections;
|
|
25
|
+
try {
|
|
26
|
+
const result = await discoverProceduresVerbose(proceduresPath, {
|
|
27
|
+
recursive: true,
|
|
28
|
+
onInvalidExport: 'warn',
|
|
29
|
+
});
|
|
30
|
+
collections = result.collections;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return {
|
|
34
|
+
routes: [],
|
|
35
|
+
totalCount: 0,
|
|
36
|
+
byMethod: {},
|
|
37
|
+
byNamespace: {},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Get route summary which provides what we need
|
|
41
|
+
const routeSummary = getRouteSummary(collections, '/api');
|
|
42
|
+
const routes = routeSummary.map((r) => ({
|
|
43
|
+
method: r.method,
|
|
44
|
+
path: r.path,
|
|
45
|
+
namespace: r.namespace,
|
|
46
|
+
procedure: r.procedure,
|
|
47
|
+
}));
|
|
48
|
+
// Count by method
|
|
49
|
+
const byMethod = {};
|
|
50
|
+
for (const route of routes) {
|
|
51
|
+
byMethod[route.method] = (byMethod[route.method] ?? 0) + 1;
|
|
52
|
+
}
|
|
53
|
+
// Count by namespace
|
|
54
|
+
const byNamespace = {};
|
|
55
|
+
for (const route of routes) {
|
|
56
|
+
byNamespace[route.namespace] = (byNamespace[route.namespace] ?? 0) + 1;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
routes,
|
|
60
|
+
totalCount: routes.length,
|
|
61
|
+
byMethod,
|
|
62
|
+
byNamespace,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get routes filtered by HTTP method
|
|
67
|
+
*/
|
|
68
|
+
export async function getRoutesByMethod(projectRoot, method) {
|
|
69
|
+
const response = await getRoutes(projectRoot);
|
|
70
|
+
return response.routes.filter((r) => r.method === method.toUpperCase());
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get routes filtered by namespace
|
|
74
|
+
*/
|
|
75
|
+
export async function getRoutesByNamespace(projectRoot, namespace) {
|
|
76
|
+
const response = await getRoutes(projectRoot);
|
|
77
|
+
return response.routes.filter((r) => r.namespace === namespace);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Format routes response as text
|
|
81
|
+
*/
|
|
82
|
+
export function formatRoutesAsText(response) {
|
|
83
|
+
const lines = [
|
|
84
|
+
'# VeloxTS REST Routes',
|
|
85
|
+
'',
|
|
86
|
+
`Total routes: ${response.totalCount}`,
|
|
87
|
+
'',
|
|
88
|
+
'## By HTTP Method',
|
|
89
|
+
'',
|
|
90
|
+
];
|
|
91
|
+
for (const [method, count] of Object.entries(response.byMethod)) {
|
|
92
|
+
lines.push(`- ${method}: ${count}`);
|
|
93
|
+
}
|
|
94
|
+
lines.push('', '## By Namespace', '');
|
|
95
|
+
for (const [namespace, count] of Object.entries(response.byNamespace)) {
|
|
96
|
+
lines.push(`- ${namespace}: ${count}`);
|
|
97
|
+
}
|
|
98
|
+
lines.push('', '## All Routes', '');
|
|
99
|
+
// Group by method for better readability
|
|
100
|
+
const byMethod = new Map();
|
|
101
|
+
for (const route of response.routes) {
|
|
102
|
+
const list = byMethod.get(route.method) ?? [];
|
|
103
|
+
list.push(route);
|
|
104
|
+
byMethod.set(route.method, list);
|
|
105
|
+
}
|
|
106
|
+
for (const [method, routes] of byMethod) {
|
|
107
|
+
lines.push(`### ${method}`);
|
|
108
|
+
for (const route of routes) {
|
|
109
|
+
lines.push(`- ${route.path} -> ${route.namespace}.${route.procedure}`);
|
|
110
|
+
}
|
|
111
|
+
lines.push('');
|
|
112
|
+
}
|
|
113
|
+
return lines.join('\n');
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/resources/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA8BxD,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,WAAmB;IACjD,MAAM,cAAc,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAEtD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO;YACL,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,EAAE;SAChB,CAAC;IACJ,CAAC;IAED,IAAI,WAAkC,CAAC;IACvC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,cAAc,EAAE;YAC7D,SAAS,EAAE,IAAI;YACf,eAAe,EAAE,MAAM;SACxB,CAAC,CAAC;QACH,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,EAAE;SAChB,CAAC;IACJ,CAAC;IAED,gDAAgD;IAChD,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,EAAE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AK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,EAAE,CAAC,CAAC;QAC5B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schemas Resource
|
|
3
|
+
*
|
|
4
|
+
* Exposes Zod schema information to AI tools.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Information about a schema
|
|
8
|
+
*/
|
|
9
|
+
export interface SchemaInfo {
|
|
10
|
+
/** Schema name (e.g., 'UserSchema') */
|
|
11
|
+
name: string;
|
|
12
|
+
/** File where the schema is defined */
|
|
13
|
+
file: string;
|
|
14
|
+
/** Inferred type name if available */
|
|
15
|
+
typeName?: string;
|
|
16
|
+
/** Brief description of the schema */
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Schemas resource response
|
|
21
|
+
*/
|
|
22
|
+
export interface SchemasResourceResponse {
|
|
23
|
+
schemas: SchemaInfo[];
|
|
24
|
+
totalCount: number;
|
|
25
|
+
files: string[];
|
|
26
|
+
/** Warnings encountered during schema scanning */
|
|
27
|
+
warnings?: string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Discover and return schema information for a project
|
|
31
|
+
*/
|
|
32
|
+
export declare function getSchemas(projectRoot: string): Promise<SchemasResourceResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Search schemas by name
|
|
35
|
+
*/
|
|
36
|
+
export declare function searchSchemas(projectRoot: string, query: string): Promise<SchemaInfo[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Format schemas response as text
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatSchemasAsText(response: SchemasResourceResponse): string;
|
|
41
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/resources/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAyED;;GAEG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA6BtF;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAU7F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,MAAM,CAmC7E"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schemas Resource
|
|
3
|
+
*
|
|
4
|
+
* Exposes Zod schema information to AI tools.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { extractSchemaNames as extractNames, extractSchemaTypes } from '@veloxts/cli';
|
|
10
|
+
import { getSchemasPath } from '../utils/project.js';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Schema Detection
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Extract schema information from file content
|
|
16
|
+
* Uses shared utilities from @veloxts/cli
|
|
17
|
+
*/
|
|
18
|
+
function extractSchemaInfo(content, filePath) {
|
|
19
|
+
const schemaNames = extractNames(content);
|
|
20
|
+
const typeMap = extractSchemaTypes(content);
|
|
21
|
+
const schemas = [];
|
|
22
|
+
for (const schemaName of schemaNames) {
|
|
23
|
+
schemas.push({
|
|
24
|
+
name: schemaName,
|
|
25
|
+
file: filePath,
|
|
26
|
+
typeName: typeMap.get(schemaName),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return schemas;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Scan a directory for schema files
|
|
33
|
+
*/
|
|
34
|
+
async function scanSchemaFiles(schemasPath) {
|
|
35
|
+
const files = [];
|
|
36
|
+
const warnings = [];
|
|
37
|
+
try {
|
|
38
|
+
const entries = await readdir(schemasPath, { withFileTypes: true });
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
if (!entry.isFile())
|
|
41
|
+
continue;
|
|
42
|
+
if (!entry.name.endsWith('.ts'))
|
|
43
|
+
continue;
|
|
44
|
+
if (entry.name.endsWith('.test.ts') || entry.name.endsWith('.spec.ts'))
|
|
45
|
+
continue;
|
|
46
|
+
if (entry.name.endsWith('.d.ts'))
|
|
47
|
+
continue;
|
|
48
|
+
const filePath = join(schemasPath, entry.name);
|
|
49
|
+
try {
|
|
50
|
+
const content = await readFile(filePath, 'utf-8');
|
|
51
|
+
files.push({ file: entry.name, content });
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
// Track file read errors as warnings
|
|
55
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
56
|
+
warnings.push(`Failed to read ${entry.name}: ${message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// Track directory read errors as warnings
|
|
62
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
63
|
+
warnings.push(`Failed to scan schemas directory: ${message}`);
|
|
64
|
+
}
|
|
65
|
+
return { files, warnings };
|
|
66
|
+
}
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Resource Handler
|
|
69
|
+
// ============================================================================
|
|
70
|
+
/**
|
|
71
|
+
* Discover and return schema information for a project
|
|
72
|
+
*/
|
|
73
|
+
export async function getSchemas(projectRoot) {
|
|
74
|
+
const schemasPath = getSchemasPath(projectRoot);
|
|
75
|
+
if (!schemasPath || !existsSync(schemasPath)) {
|
|
76
|
+
return {
|
|
77
|
+
schemas: [],
|
|
78
|
+
totalCount: 0,
|
|
79
|
+
files: [],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const { files: schemaFiles, warnings } = await scanSchemaFiles(schemasPath);
|
|
83
|
+
const allSchemas = [];
|
|
84
|
+
const files = [];
|
|
85
|
+
for (const { file, content } of schemaFiles) {
|
|
86
|
+
const schemas = extractSchemaInfo(content, file);
|
|
87
|
+
if (schemas.length > 0) {
|
|
88
|
+
files.push(file);
|
|
89
|
+
allSchemas.push(...schemas);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
schemas: allSchemas,
|
|
94
|
+
totalCount: allSchemas.length,
|
|
95
|
+
files,
|
|
96
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Search schemas by name
|
|
101
|
+
*/
|
|
102
|
+
export async function searchSchemas(projectRoot, query) {
|
|
103
|
+
const response = await getSchemas(projectRoot);
|
|
104
|
+
const lowerQuery = query.toLowerCase();
|
|
105
|
+
return response.schemas.filter((s) => s.name.toLowerCase().includes(lowerQuery) ||
|
|
106
|
+
s.typeName?.toLowerCase().includes(lowerQuery) ||
|
|
107
|
+
s.file.toLowerCase().includes(lowerQuery));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Format schemas response as text
|
|
111
|
+
*/
|
|
112
|
+
export function formatSchemasAsText(response) {
|
|
113
|
+
const lines = [
|
|
114
|
+
'# VeloxTS Schemas',
|
|
115
|
+
'',
|
|
116
|
+
`Total schemas: ${response.totalCount}`,
|
|
117
|
+
`Schema files: ${response.files.length}`,
|
|
118
|
+
'',
|
|
119
|
+
'## Files',
|
|
120
|
+
'',
|
|
121
|
+
];
|
|
122
|
+
for (const file of response.files) {
|
|
123
|
+
lines.push(`- ${file}`);
|
|
124
|
+
}
|
|
125
|
+
lines.push('', '## Schemas', '');
|
|
126
|
+
// Group by file
|
|
127
|
+
const byFile = new Map();
|
|
128
|
+
for (const schema of response.schemas) {
|
|
129
|
+
const list = byFile.get(schema.file) ?? [];
|
|
130
|
+
list.push(schema);
|
|
131
|
+
byFile.set(schema.file, list);
|
|
132
|
+
}
|
|
133
|
+
for (const [file, schemas] of byFile) {
|
|
134
|
+
lines.push(`### ${file}`);
|
|
135
|
+
for (const schema of schemas) {
|
|
136
|
+
const typeName = schema.typeName ? ` (type: ${schema.typeName})` : '';
|
|
137
|
+
lines.push(`- ${schema.name}${typeName}`);
|
|
138
|
+
}
|
|
139
|
+
lines.push('');
|
|
140
|
+
}
|
|
141
|
+
return lines.join('\n');
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/resources/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,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AAC,KAAK,MAAM,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeloxTS MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Model Context Protocol server that exposes VeloxTS project context to AI tools.
|
|
5
|
+
*/
|
|
6
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Server configuration options
|
|
9
|
+
*/
|
|
10
|
+
export interface VeloxMCPServerOptions {
|
|
11
|
+
/** Project root directory (auto-detected if not specified) */
|
|
12
|
+
projectRoot?: string;
|
|
13
|
+
/** Enable debug logging */
|
|
14
|
+
debug?: boolean;
|
|
15
|
+
/** Server name */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** Server version */
|
|
18
|
+
version?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a VeloxTS MCP server
|
|
22
|
+
*/
|
|
23
|
+
export declare function createVeloxMCPServer(options?: VeloxMCPServerOptions): Server;
|
|
24
|
+
/**
|
|
25
|
+
* Run the MCP server with stdio transport
|
|
26
|
+
*/
|
|
27
|
+
export declare function runMCPServer(options?: VeloxMCPServerOptions): Promise<void>;
|
|
28
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AA0DnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAkWhF;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrF"}
|