What is MCP?
The Model Context Protocol (MCP) is Shopify’s official validation system that checks extensions and functions against their API schemas and best practices.Why Validation Matters
Without proper validation:- ❌ Extensions fail at deploy time
- ❌ Runtime errors in production
- ❌ Poor customer experience
- ❌ Wasted development time
- ✅ Catch errors before deployment
- ✅ Guarantee API compatibility
- ✅ Follow Shopify best practices
- ✅ Faster development cycles
Validation Process
1. Component Validation
Checks that all UI components exist and are used correctly:- Component exists in the specified package
- Import path is correct (
/checkout,/admin, etc.) - Props match the component’s TypeScript definition
- Required props are provided
- Prop types are correct
2. Hook Validation
Ensures React hooks follow all rules:- Hooks are called at top level only
- Hooks are called in the same order every render
- Hooks are not called conditionally
- Hook names start with “use”
- Custom hooks follow hook rules
3. GraphQL Validation
Validates queries against Shopify’s official schema:- All fields exist in the schema
- Required field selections are present
- Fragments are used correctly for interfaces/unions
- Variables have correct types
- Directives are valid
4. Extension Target Validation
Verifies extension targets are valid:- Target exists in Shopify’s extension API
- Target is appropriate for extension type
- Module path matches target expectations
- API version supports the target
5. Function Input Validation
For Shopify Functions, validates input queries:Validation Scores
Synapse provides a score from 0-100:Score Breakdown
| Score | Rating | Meaning | Action |
|---|---|---|---|
| 95-100 | Excellent | Production-ready, no issues | Deploy immediately |
| 90-94 | Very Good | Minor style issues | Deploy, consider fixes |
| 80-89 | Good | Some warnings | Review warnings |
| 70-79 | Fair | Multiple issues | Fix before deploy |
| 60-69 | Poor | Significant problems | Requires self-correction |
| 0-59 | Failed | Critical errors | Must fix |
What Affects Your Score
Deductions:- Critical error (missing import, invalid GraphQL): -15 points
- Major warning (unused variable, incorrect prop type): -5 points
- Minor warning (missing comment, style issue): -2 points
- Best practice violation: -3 points
- Comprehensive error handling: +5 points
- TypeScript types used correctly: +3 points
- Accessibility attributes present: +2 points
- Performance optimizations: +2 points
Common Validation Errors
Import Path Error
Import Path Error
Error:
Module '@shopify/ui-extensions-react' has no exported member 'Banner'Cause: Missing /checkout or /admin in import pathFix:GraphQL Field Error
GraphQL Field Error
Error:
Cannot query field 'totalPrice' on type 'Cart'Cause: Field name doesn’t exist in schemaFix:Hook Rules Violation
Hook Rules Violation
Error:
React Hook "useCart" is called conditionallyCause: Hook inside if statement or callbackFix:Invalid Target
Invalid Target
Error:
Extension target 'checkout.custom.block' is not validCause: Target doesn’t exist in Shopify’s APIFix:Validation Report Example
When you generate code, you’ll see a report like this:How to Improve Your Score
1. Use TypeScript Types
2. Add Error Handling
3. Follow React Best Practices
4. Add Accessibility
Advanced Validation
Custom Validation Rules
You can add project-specific rules:Pre-deployment Checks
Before deploying, Synapse runs additional checks:- Bundle size analysis
- Performance profiling
- Security scanning
- Dependency audit