Search by

ayasoftware / magento2-mcp-api

hmatardeveloper

Magento 2 MCP API - Additional REST API endpoints for Magento 2 MCP Server

Package info

github.com/ayasoftware/magento2-mcp-api

Type:magento2-module

pkg:composer/ayasoftware/magento2-mcp-api

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.3.1 2026-09-14 22:28 UTC

This package is auto-updated.

Last update: 2026-09-15 13:26:42 UTC


README

Additional REST API endpoints for Magento 2 MCP Server that extend Magento's native capabilities.

Version

Current Version: 1.3.1

Installation

composer require ayasoftware/magento2-mcp-api
php bin/magento module:enable Ayasoftware_McpApi
php bin/magento setup:upgrade
php bin/magento cache:flush

Features

Indexer Management

Advanced indexer operations beyond Magento's default REST API.

Coupon Management

Update individual coupon properties (not available in Magento's default REST API).

Cache Management

Flush or clean caches over REST. Magento exposes cache management through the CLI and admin only, with no REST route at all, so an API client has no way to clear a cache without this module.

Layout

  • composer.json
  • src/registration.php
  • src/etc/module.xml
  • src/etc/acl.xml
  • src/etc/di.xml
  • src/etc/webapi.xml
  • src/Api/IndexerManagementInterface.php
  • src/Model/IndexerManagement.php
  • src/Api/CouponManagementInterface.php
  • src/Model/CouponManagement.php

Endpoints

Indexer Management

  • POST /V1/mg_indexer_reindex - Reindex all indexers
  • GET /V1/mg_indexer_info - Get info for all indexers
  • GET /V1/mg_indexer_info/:indexerId - Get info for specific indexer
  • POST /V1/mg_indexer_reindex/:indexerId - Reindex specific indexer
  • POST /V1/mg_indexer_reindex_search - Reindex search index only
  • GET /V1/mg_indexer_status - Get status for all indexers
  • GET /V1/mg_indexer_status/:indexerId - Get status for specific indexer
  • POST /V1/mg_indexer_reindex_invalid - Reindex only the indexers Magento has marked invalid

Cache Management

  • POST /V1/mg_cache_flush - Flush every cache storage (equivalent to bin/magento cache:flush)
  • POST /V1/mg_cache_clean - Clean named cache types, body {"types": ["config", "layout"]}
  • GET /V1/mg_cache_info - List the cache types this store knows about and whether each is enabled

Flush Cache Example

curl -X POST "https://your-store.com/rest/V1/mg_cache_flush"   -H "Authorization: Bearer your-access-token"   -H "Content-Type: application/json"   -d '{}'

Cleaning an unknown type is rejected, and the response lists the valid types.

Coupon Management

  • PUT /V1/mg_coupon/:couponId - Update coupon properties

Update Coupon Example

curl -X PUT "https://your-store.com/rest/V1/mg_coupon/123" \
  -H "Authorization: Bearer your-access-token" \
  -H "Content-Type: application/json" \
  -d '{
    "couponData": {
      "code": "SUMMER2026",
      "usage_limit": 1000,
      "usage_per_customer": 5,
      "expiration_date": "2026-08-31"
    }
  }'

Updatable Fields:

  • code - Coupon code string
  • usage_limit - Maximum number of times coupon can be used
  • usage_per_customer - Maximum uses per customer
  • times_used - Current usage count
  • expiration_date - Expiration date (Y-m-d format)
  • is_primary - Whether this is the primary coupon for the rule

Changelog

1.3.1

Republishes 1.3.0 unchanged. The 1.3.0 tag was moved to a different commit after release, and Packagist keeps published versions immutable, so the code is reissued here under a new version. No functional difference from 1.3.0.

1.3.0

  • Added cache management: mg_cache_flush, mg_cache_clean and mg_cache_info. Magento has no REST route for caches, so API clients previously had no way to clear one.
  • Added mg_indexer_reindex_invalid to rebuild only the indexers Magento has marked invalid.
  • Fixed indexer identity. indexer_id was read from the indexer collection's array key, which is a row number rather than the indexer id. Every by-id lookup therefore reported the indexer missing, and listings returned ids like "0" and "1". Responses now carry the real id, such as catalog_product_price.
  • Fixed indexer status, which was read through getData('status') and always came back as an empty string. It now uses getStatus().

Both fixes change the shape of existing responses, which is why this is a minor version rather than a patch.

License

MIT