1. Go to this page and download the library: Download jigar-dhulla/swiggy-mcp library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jigar-dhulla / swiggy-mcp example snippets
use JigarDhulla\SwiggyMcp\Auth\OAuth;
$oauth = new OAuth(redirectUri: 'http://localhost:8080/callback');
$clientId = $oauth->register(); // one-time; save it and reuse it
$login = $oauth->authorize($clientId); // save $login->toArray() in the session
header('Location: '.$login->url);
$token = $oauth->exchange($login, $callbackUrl); // checks state, returns an AccessToken
$token->value; // the bearer token
$token->expiresAt; // tokens last 5 days and can't be refreshed
use JigarDhulla\SwiggyMcp\Swiggy;
$swiggy = new Swiggy($token);
$addresses = $swiggy->instamart()->call('get_addresses');
$results = $swiggy->instamart()->call('search_products', [
'addressId' => $addresses['addresses'][0]['id'],
'query' => 'milk',
]);
$swiggy = new Swiggy(
$token,
httpClient: $psr18Client, // set timeouts and proxies here
sessions: new CacheSessionStore($psr16Cache), // share MCP sessions across processes
retry: new RetryPolicy(retries: 5), // or RetryPolicy::none()
logger: $psr3Logger, // every call logged, never the token
clientName: 'my-agent',
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.