Skip to main content
Glama

Sitecore MCP Server

by GaryWenneker
SCHEMA-MIGRATION-REQUIRED.md•6.51 kB
# CRITICAL: Schema Migration Required - Search API Changed **Date**: October 16, 2025 **Status**: 🚨 BREAKING CHANGES FOUND **Priority**: HIGH --- ## 🚨 Problem Summary The `/items/master` schema has **COMPLETELY DIFFERENT** search API than `/edge`. The current code uses old `/edge` syntax which doesn't work. ### Current Issues 1. āŒ `executeQuery()` - Uses old `where: { name, value, operator }` syntax (BROKEN) 2. āŒ `searchItems()` - Same old syntax (BROKEN) 3. āœ… `getChildren()` - Fixed in v1.2.1 (WORKING) 4. āœ… `getItem()`, `getFieldValue()`, `getTemplate()` - Never used search (WORKING) --- ## šŸ“Š Schema Test Results Ran `test-schema-validation.ps1`: ### āœ… PASSING (7/8): 1. āœ… `item()` → Direct Item object 2. āœ… `item().children()` → Direct [Item] array 3. āœ… `item().field()` → Direct string 4. āœ… `item().fields()` → [ItemField] array 5. āœ… `item().template` → Direct Template object 6. āœ… Endpoint `/items/master` → Correct 7. āœ… `children(first: N)` → Pagination works ### āŒ FAILING (1/8): 8. āŒ `search()` → Uses wrong syntax --- ## šŸ” Correct /items/master Search Schema ### Search Arguments ```graphql search( first: Int # Limit results after: String # Cursor (default: "0") rootItem: String # Path/ID to search under keyword: String # Keyword search fieldsEqual: [ItemSearchFieldQuery] # Field equality fieldsContain: [ItemSearchFieldQuery] # Field contains language: String # Language filter # Many more filters... ) ``` ### Return Type Structure ```graphql type ContentSearchResults { results: ContentSearchResultConnection! # Main results facets: [FacetResult] # Search facets totalCount: Int! # Total matches } type ContentSearchResultConnection { items: [SearchResultItem]! # āš ļø Items array (not direct!) pageInfo: PageInfo # Pagination info } type SearchResultItem { item: Item! # āš ļø Wrapped in 'item'! } ``` ### Correct Query Example ```graphql query { search( keyword: "home" rootItem: "/sitecore/content" first: 10 ) { results { items { # āš ļø Access via .items item { # āš ļø Then via .item id name path } } } totalCount } } ``` ### Access Pattern ```typescript // āŒ OLD (doesn't work): const items = result.search.results; // āœ… NEW (correct): const items = result.search.results.items.map(i => i.item); ``` --- ## šŸ› ļø Required Code Changes ### Priority 1: Disable Broken Tools Until search is fixed, these tools will return errors: - `sitecore_query` (uses executeQuery) - `sitecore_search` (uses searchItems) **Recommendation**: Add try/catch with clear error message: ```typescript throw new Error( "Search API migration in progress. " + "This tool currently doesn't work with /items/master schema. " + "Use sitecore_get_item or sitecore_get_children instead." ); ``` ### Priority 2: Fix Search Methods #### File: `src/sitecore-service.ts` **Method 1: `executeQuery()` (line ~200)** ```typescript // Current (BROKEN): search( where: { name: "_path", value: $path, operator: CONTAINS } first: $first language: $language ) { results { id name } // āŒ Wrong structure } // Should be: search( rootItem: $path first: $first language: $language ) { results { items { // āœ… Correct structure item { id name displayName path template { id name } } } } totalCount } ``` **Method 2: `searchItems()` (line ~270)** ```typescript // Current (BROKEN): search( where: { name: "_name", value: $searchText, operator: CONTAINS } first: $first ) { results { id name } // āŒ Wrong structure } // Should be: search( keyword: $searchText rootItem: $rootPath first: $first ) { results { items { // āœ… Correct structure item { id name path } } } totalCount } ``` --- ## āš ļø Impact Assessment ### Tools Currently Broken 1. āŒ `sitecore_query` - Query execution (uses search) 2. āŒ `sitecore_search` - Search items (uses search) 3. āŒ `sitecore_command` - Natural language "search" commands ### Tools Still Working 1. āœ… `sitecore_get_item` - Get single item 2. āœ… `sitecore_get_children` - Get children (fixed v1.2.1) 3. āœ… `sitecore_get_field_value` - Get field value 4. āœ… `sitecore_get_template` - Get template info 5. āœ… `sitecore_scan_schema` - Schema scanning (if introspection works) ### User Impact - **Low**: Most common operations (get item, children, fields) still work - **Medium**: Search functionality is broken - **Workaround**: Use `get_children` recursively or manually --- ## šŸ“ Action Items ### Immediate (This Session) - [x] Document schema differences - [x] Create SCHEMA-REFERENCE.md with correct patterns - [x] Update copilot-instructions.md - [x] Remove all /edge references - [ ] Add error messages to broken search tools - [ ] Update documentation (README, etc.) ### Next Session - [ ] Rewrite `executeQuery()` with new search syntax - [ ] Rewrite `searchItems()` with new search syntax - [ ] Test all search scenarios - [ ] Update natural language parser for search commands - [ ] Full regression testing ### Future - [ ] Add advanced search filters (fieldsEqual, fieldsContain) - [ ] Add facet support - [ ] Add search result highlighting - [ ] Performance optimization --- ## šŸŽÆ Workarounds for Users Until search is fixed: ### Instead of Search: ```typescript // āŒ Broken: /sitecore search articles // āœ… Use: /sitecore get children /sitecore/content // Then manually filter results ``` ### Instead of Query: ```typescript // āŒ Broken: /sitecore query /sitecore/content//*[@@templatename='Article'] // āœ… Use: /sitecore get children /sitecore/content // Then check template names manually ``` --- ## šŸ“š References - **SCHEMA-REFERENCE.md** - Complete schema documentation - **SCHEMA-FIX-CHILDREN.md** - Children fix (v1.2.1) - **test-schema-validation.ps1** - Schema validation tests - **graphql-schema-full.json** - Full schema JSON (217 MB) --- **Status**: Documentation complete, code fixes pending **Version**: 1.2.1 (search broken), next 1.3.0 (search fixed) **Priority**: HIGH - Search is core functionality

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GaryWenneker/SitecoreMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server