d365fo-mcp 1.26.1 → 1.26.2
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/dist/bridge/bridgeClient.d.ts +50 -0
- package/dist/bridge/bridgeClient.js +131 -0
- package/dist/bridge/udeLaunchPaths.d.ts +20 -0
- package/dist/bridge/udeLaunchPaths.js +34 -0
- package/dist/config/settings.js +22 -0
- package/dist/index.js +19 -0
- package/dist/metadata/symbolIndex.d.ts +7 -0
- package/dist/metadata/symbolIndex.js +36 -1
- package/dist/scripts/build-database.js +52 -3
- package/dist/scripts/build-fts.js +52 -3
- package/dist/scripts/extract-binary-models.js +20 -0
- package/dist/scripts/extract-metadata.js +20 -0
- package/dist/scripts/startupIndexWorker.js +52 -3
- package/dist/server/transport.js +5 -0
- package/dist/tools/readers/classInfo.js +29 -5
- package/dist/tools/readers/diskFallback.d.ts +30 -0
- package/dist/tools/readers/diskFallback.js +61 -0
- package/dist/tools/readers/edtInfo.js +7 -0
- package/dist/tools/readers/formInfo.js +14 -0
- package/dist/tools/sdlc/modelReindex.d.ts +30 -1
- package/dist/tools/sdlc/modelReindex.js +98 -6
- package/dist/tools/sdlc/updateSymbolIndex.d.ts +17 -0
- package/dist/tools/sdlc/updateSymbolIndex.js +21 -0
- package/dist/tools/toolHandler.js +6 -2
- package/dist/utils/modelClassifier.d.ts +2 -0
- package/dist/utils/modelClassifier.js +4 -0
- package/dist/utils/nameArguments.d.ts +22 -0
- package/dist/utils/nameArguments.js +59 -0
- package/dist/utils/objectFileLookup.js +5 -2
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ import { extensionInfoTool } from './readers/extensionInfo.js';
|
|
|
21
21
|
import { getKnowledgeTool } from './knowledge/getKnowledge.js';
|
|
22
22
|
import { validateObjectNamingTool } from './analysis/validateObjectNaming.js';
|
|
23
23
|
import { verifyD365ProjectTool } from './sdlc/verifyD365Project.js';
|
|
24
|
-
import {
|
|
24
|
+
import { updateSymbolIndexRequest } from './sdlc/updateSymbolIndex.js';
|
|
25
25
|
import { buildProjectTool } from './sdlc/buildProject.js';
|
|
26
26
|
import { dbSyncTool } from './sdlc/dbSync.js';
|
|
27
27
|
import { runBpCheckTool } from './sdlc/runBpCheck.js';
|
|
@@ -37,6 +37,7 @@ import { getWorkspaceInfoTool } from './readers/getWorkspaceInfo.js';
|
|
|
37
37
|
import { recordToolStart, startMetricsLogging, recordCallSequence, occurrencesInEpoch, reportSlowCall } from '../utils/toolMetrics.js';
|
|
38
38
|
import { DEDUP_EXCLUDED_TOOLS, DEDUP_TTL_MS, dedupKey, getDedupedResult, storeDedupResult, appendNote, getInFlight, registerInFlight, clearInFlight, MUTATING_TOOLS, currentWriteEpoch, bumpWriteEpoch, } from '../utils/callDedup.js';
|
|
39
39
|
import { capToolResponse } from './responseCaps.js';
|
|
40
|
+
import { refusePathAsName } from '../utils/nameArguments.js';
|
|
40
41
|
/**
|
|
41
42
|
* Tools whose call can WRITE to the model. Used only to pick the right wording
|
|
42
43
|
* when the bridge failed but the tool still returned OK — see the note in the
|
|
@@ -217,6 +218,9 @@ export function registerToolHandler(server, context) {
|
|
|
217
218
|
isError: true,
|
|
218
219
|
};
|
|
219
220
|
}
|
|
221
|
+
const pathAsName = refusePathAsName(toolName, request.params.arguments); // every tool, one place
|
|
222
|
+
if (pathAsName)
|
|
223
|
+
return pathAsName;
|
|
220
224
|
// Loop detection + duplicate-call dedup
|
|
221
225
|
const callKey = dedupKey(toolName, request.params.arguments);
|
|
222
226
|
// Captured HERE, not after the tool runs: it tags this occurrence in the
|
|
@@ -319,7 +323,7 @@ export function registerToolHandler(server, context) {
|
|
|
319
323
|
case 'verify_d365fo_project':
|
|
320
324
|
return verifyD365ProjectTool(request, context);
|
|
321
325
|
case 'update_symbol_index':
|
|
322
|
-
return await
|
|
326
|
+
return await updateSymbolIndexRequest(request.params.arguments, context);
|
|
323
327
|
case 'build_d365fo_project':
|
|
324
328
|
// Streams progress while xppc runs, so a build longer than any timeout
|
|
325
329
|
// still completes inside this one call instead of handing back a stub.
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* This allows dynamically detected models to be treated as custom
|
|
16
16
|
*/
|
|
17
17
|
export declare function registerCustomModel(modelName: string): void;
|
|
18
|
+
/** The models registered as custom at run time (workspace and custom packages root). */
|
|
19
|
+
export declare function getAutoDetectedCustomModels(): string[];
|
|
18
20
|
/**
|
|
19
21
|
* Clear all auto-detected custom models (for test isolation)
|
|
20
22
|
*/
|
|
@@ -24,6 +24,10 @@ export function registerCustomModel(modelName) {
|
|
|
24
24
|
autoDetectedCustomModels.add(modelName);
|
|
25
25
|
console.error(`[ModelClassifier] Registered "${modelName}" as custom model (auto-detected)`);
|
|
26
26
|
}
|
|
27
|
+
/** The models registered as custom at run time (workspace and custom packages root). */
|
|
28
|
+
export function getAutoDetectedCustomModels() {
|
|
29
|
+
return [...autoDetectedCustomModels];
|
|
30
|
+
}
|
|
27
31
|
/**
|
|
28
32
|
* Clear all auto-detected custom models (for test isolation)
|
|
29
33
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool arguments that name a thing: a model, a package, an object, a label file, a
|
|
3
|
+
* language. The server builds file paths from them, so each must be one path segment.
|
|
4
|
+
* Arguments that take a path (`filePath`, `projectPath`, `packagePath`, …) are checked
|
|
5
|
+
* where they are used and are not listed here.
|
|
6
|
+
*/
|
|
7
|
+
/** True when `value` cannot be one segment of a file path. */
|
|
8
|
+
export declare function isPathLikeName(value: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Where the first name argument holding a path is (`labels[0].translations[1].language`),
|
|
11
|
+
* or null when every name is a name.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findPathLikeName(toolName: string, args: unknown): string | null;
|
|
14
|
+
/** The error result for a call with a path where a name goes, or null when there is none. */
|
|
15
|
+
export declare function refusePathAsName(toolName: string, args: unknown): {
|
|
16
|
+
content: {
|
|
17
|
+
type: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
}[];
|
|
20
|
+
isError: boolean;
|
|
21
|
+
} | null;
|
|
22
|
+
//# sourceMappingURL=nameArguments.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool arguments that name a thing: a model, a package, an object, a label file, a
|
|
3
|
+
* language. The server builds file paths from them, so each must be one path segment.
|
|
4
|
+
* Arguments that take a path (`filePath`, `projectPath`, `packagePath`, …) are checked
|
|
5
|
+
* where they are used and are not listed here.
|
|
6
|
+
*/
|
|
7
|
+
const NAME_KEYS = new Set([
|
|
8
|
+
'baseFormName', 'baseName', 'baseObjectName', 'className', 'dutyName', 'edtName',
|
|
9
|
+
'entityName', 'enumName', 'formName', 'labelFileId', 'language', 'languages', 'macroName',
|
|
10
|
+
'mapName', 'model', 'modelName', 'objectName', 'packageName', 'policyName', 'privilegeName',
|
|
11
|
+
'projectName', 'queryName', 'reportName', 'serviceName', 'tableName', 'viewName',
|
|
12
|
+
]);
|
|
13
|
+
/** `name` is the name of an object only as a top-level argument of these tools. */
|
|
14
|
+
const TOOLS_NAMING_AN_OBJECT_AS_NAME = new Set(['get_object_info', 'generate_object']);
|
|
15
|
+
/** True when `value` cannot be one segment of a file path. */
|
|
16
|
+
export function isPathLikeName(value) {
|
|
17
|
+
const trimmed = value.trim();
|
|
18
|
+
return /[\\/\0]/.test(trimmed) || trimmed === '.' || trimmed === '..';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Where the first name argument holding a path is (`labels[0].translations[1].language`),
|
|
22
|
+
* or null when every name is a name.
|
|
23
|
+
*/
|
|
24
|
+
export function findPathLikeName(toolName, args) {
|
|
25
|
+
const visit = (value, at, isName) => {
|
|
26
|
+
if (typeof value === 'string')
|
|
27
|
+
return isName && isPathLikeName(value) ? at : null;
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
for (const [i, item] of value.entries()) {
|
|
30
|
+
const found = visit(item, `${at}[${i}]`, isName);
|
|
31
|
+
if (found)
|
|
32
|
+
return found;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (!value || typeof value !== 'object')
|
|
37
|
+
return null;
|
|
38
|
+
for (const [key, item] of Object.entries(value)) {
|
|
39
|
+
const named = NAME_KEYS.has(key)
|
|
40
|
+
|| (at === '' && key === 'name' && TOOLS_NAMING_AN_OBJECT_AS_NAME.has(toolName));
|
|
41
|
+
const found = visit(item, at ? `${at}.${key}` : key, named);
|
|
42
|
+
if (found)
|
|
43
|
+
return found;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
47
|
+
return visit(args, '', false);
|
|
48
|
+
}
|
|
49
|
+
/** The error result for a call with a path where a name goes, or null when there is none. */
|
|
50
|
+
export function refusePathAsName(toolName, args) {
|
|
51
|
+
const at = findPathLikeName(toolName, args);
|
|
52
|
+
if (at === null)
|
|
53
|
+
return null;
|
|
54
|
+
const text = `❌ \`${at}\` takes a name, not a path: it cannot contain "/" or "\\", or be "." or "..". ` +
|
|
55
|
+
'Nothing was read or written. Pass the name alone; a file or folder goes in an argument ' +
|
|
56
|
+
'that takes a path (filePath, projectPath, packagePath).';
|
|
57
|
+
return { content: [{ type: 'text', text }], isError: true };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=nameArguments.js.map
|
|
@@ -12,6 +12,7 @@ import { getConfigManager, fallbackPackagePath } from './configManager.js';
|
|
|
12
12
|
import { PackageResolver } from './packageResolver.js';
|
|
13
13
|
import { findDescriptorPath } from '../metadata/modelDescriptor.js';
|
|
14
14
|
import { aotFolderFor } from '../metadata/aotFolders.js';
|
|
15
|
+
import { isPathLikeName } from './nameArguments.js';
|
|
15
16
|
// objectType → Ax* folder: metadata/aotFolders.ts, the same map the create tool writes with.
|
|
16
17
|
/**
|
|
17
18
|
* Resolve a MODEL DESCRIPTOR's path: <root>/<Package>/Descriptor/<Model>.xml.
|
|
@@ -40,7 +41,7 @@ export async function findModelDescriptorPath(modelName, explicitPackagePath) {
|
|
|
40
41
|
(await configManager.getAutoDetectedModelName()) ||
|
|
41
42
|
process.env.D365FO_MODEL_NAME ||
|
|
42
43
|
null;
|
|
43
|
-
if (!resolvedModel)
|
|
44
|
+
if (!resolvedModel || isPathLikeName(resolvedModel))
|
|
44
45
|
return null;
|
|
45
46
|
const roots = [
|
|
46
47
|
explicitPackagePath,
|
|
@@ -103,7 +104,7 @@ export async function moduleExistenceNote(moduleName, explicitPackagePath) {
|
|
|
103
104
|
*/
|
|
104
105
|
export async function findD365FileOnDisk(objectType, objectName, modelName, explicitPackagePath) {
|
|
105
106
|
const objectFolder = aotFolderFor(objectType);
|
|
106
|
-
if (!objectFolder)
|
|
107
|
+
if (!objectFolder || isPathLikeName(objectName))
|
|
107
108
|
return null;
|
|
108
109
|
const configManager = getConfigManager();
|
|
109
110
|
// Ensure .mcp.json is loaded — lazy init so this works even when
|
|
@@ -124,6 +125,8 @@ export async function findD365FileOnDisk(objectType, objectName, modelName, expl
|
|
|
124
125
|
'Provide modelName parameter, configure .mcp.json with modelName/projectPath, or set D365FO_MODEL_NAME env var.');
|
|
125
126
|
return null;
|
|
126
127
|
}
|
|
128
|
+
if (isPathLikeName(resolvedModel))
|
|
129
|
+
return null;
|
|
127
130
|
const configPackagePath = configManager.getPackagePath() || fallbackPackagePath();
|
|
128
131
|
// Resolve the custom write root (D365FO_CUSTOM_PACKAGES_PATH).
|
|
129
132
|
// Try this before the MS PLD so we find repo-tracked objects first.
|
package/package.json
CHANGED