Skip to main content

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
With MCP validation:
  • ✅ 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:
What MCP Checks:
  • 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:
What MCP Checks:
  • 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:
What MCP Checks:
  • 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:
What MCP Checks:
  • 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

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
Bonuses:
  • Comprehensive error handling: +5 points
  • TypeScript types used correctly: +3 points
  • Accessibility attributes present: +2 points
  • Performance optimizations: +2 points

Common Validation Errors

Error: Module '@shopify/ui-extensions-react' has no exported member 'Banner'Cause: Missing /checkout or /admin in import pathFix:
Error: Cannot query field 'totalPrice' on type 'Cart'Cause: Field name doesn’t exist in schemaFix:
Error: React Hook "useCart" is called conditionallyCause: Hook inside if statement or callbackFix:
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

Next Steps

Self-Correction

How automatic fixes work

Best Practices

Write code that passes validation

Debugging

Fix validation errors manually

Extension Standards

Shopify’s quality guidelines