PDX-515: fix(mcp): read Provar IDE SfObject org-describe cache layout#227
Merged
Merged
Conversation
RCA: provar_org_describe resolved only <workspace>/.metadata/<connection>/ and parsed native JSON or CustomObject XML, but the Provar IDE writes one <sfObject>/<fields>/<sfField> XML file per object under .metadata/.plugins/com.provar.eclipse.ui/<connection>/<env>/SfObject/, so the dir never existed (silent cache-miss) and the format could not be parsed, yielding field_count:0. Fix: prefer the IDE SfObject layout (new optional environment param, default 'default', with env fallback preferring default), add readSfObjectXml that maps sfField n/type/required attributes with container children excluded and stubs handled, keep legacy JSON/CustomObject parsing, enforce assertPathAllowed on every resolved path, and document the layout, param and cache schema in docs/mcp.md.
Quality Orchestrator🟢 LOW · 🧪 Tests to Run · Running 1 of 57 tests
▶ Run commandnpx vitest run \
unit/mcp/orgDescribeTools.test.ts⚡ quality-orchestrator · |
RCA: SfObject parser used @_t (the display label, e.g. "Person (a0D)") as the object name, diverging from the API-name contract the native-JSON cache path and describeSObjectResult follow. Fix: Prefer @_n (the API name) over @_t in readSfObjectXml and update the (k.1) test to assert the API name "provar__Person__c".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
provar_org_describepreviously returnedfield_count: 0for every object because it resolved only the legacy<workspace>/.metadata/<connection_name>/directory and parsed only native JSON /CustomObjectXML. The Provar IDE actually writes one<sfObject>/<fields>/<sfField>XML file per object under.metadata/.plugins/com.provar.eclipse.ui/<connection>/<env>/SfObject/, so the directory was never found (silent cache-miss) and the format could not be parsed..object/.xmlcaches keep working.environmentparameter (defaultdefault) selects the test-environment subdirectory; if the requested environment has no cached metadata, the tool falls back to any environment that does, preferringdefault.provar__Person__c.xmlyields 16 fields withprovar__Email__cas the only required field; the realAccount.xmlstub (detailsLoaded="false") yieldsexists: true, field_count: 0.Jira
https://provartesting.atlassian.net/browse/PDX-515
Changes
src/mcp/tools/orgDescribeTools.tsXML_PARSERnow arrays bothfieldsandsfFieldso both on-disk XML formats parse with one parser instance.readSfObjectXmlhelper parses the IDE format:name←@_n(nameless fields skipped),type←@_type(absent →unknown),nillable←NOT(@_required === 'true'),default_valuealwaysnull, display name from@_t/@_n; container<sfField>children (e.g.<referenceTos>) are not counted; stubs yield an empty field list.readXmlCacheFilenow detects<sfObject>vs<CustomObject>/<toolingObjectInfo>and dispatches; legacy parsing extracted intoreadCustomObjectXml.resolveSfObjectDirresolves the IDE layout with requested-env-first /default-preferred fallback;resolveConnectionDirprefers it before the legacy directory.assertPathAllowedis enforced on the workspace, thecom.provar.eclipse.uidir, the connection dir, and every candidateSfObjectdir;connection_nameandenvironmentare validated as identifiers (no separators /..).environmentinput param (defaultdefault); tool description and field descriptions updated per MCP authoring standards.cache_age_msreflects theSfObjectdirectory mtime when that layout is used.test/unit/mcp/orgDescribeTools.test.ts— added 9 SfObject-layout tests (happy path,field_filter=required, env fallback, env default, stub handling, dir listing, IDE-preferred-over-legacy, environment traversal rejection, workspace-outside-allowedPaths rejection). All existing JSON /CustomObject/.objectregression tests retained and passing.docs/mcp.md— documented the IDE SfObject cache layout, the newenvironmentparam (defaults todefault), the cache-layout resolution order, and the SfObject XML on-disk schema + field mapping.Test plan
yarn compile— cleannode_modules/.bin/nyc node_modules/.bin/mocha "test/**/*.test.ts"— 1500 passing, 1 pendingnode scripts/mcp-smoke.cjs— only environmental timeouts on unrelatedprovar_automation_*/provar_testrun_*tools (the smoke script spawns the globally-installed package, not this build; counts varied 4→3 across runs, confirming flakiness)yarn lint— cleanCustomer-facing behaviour note
This changes the on-disk cache layout
provar_org_describereads (it now reads the Provar IDE SfObject cache and accepts a newenvironmentparameter). The external/customer-facing docs (docs/provar-mcp-public-docs.md,docs/university-of-provar-mcp-course.md) are maintained separately by the Provar team and should be updated to reflect the new layout and parameter.🤖 Generated with Claude Code