### Install packages Source: https://sanvex.vercel.app/docs/getting-started/quickstart Install the necessary Sanvex packages using Composer. ```bash composer require sanvex/core sanvex/cli sanvex/github ``` -------------------------------- ### Call the driver Source: https://sanvex.vercel.app/docs/getting-started/quickstart Example of how to call the GitHub driver to list repositories. ```php use Sanvex\Core\SanvexManager; public function repos(SanvexManager $manager) { return $manager->resolveDriver('github') ->repositories() ->list(['per_page' => 10]); } ``` -------------------------------- ### Set up tenant-scoped credentials Source: https://sanvex.vercel.app/docs/getting-started/installation Sets up tenant-scoped credentials for a driver, using Notion API key as an example. ```bash php artisan sanvex:setup notion --api-key="secret_..." \ --owner-type=App\\Models\\Team --owner-id=1 ``` -------------------------------- ### Install core and CLI Source: https://sanvex.vercel.app/docs/getting-started/installation Installs the core Sanvex package and the command-line interface. ```bash composer require sanvex/core sanvex/cli ``` -------------------------------- ### List installed drivers Source: https://sanvex.vercel.app/docs/getting-started/installation Lists all installed Sanvex drivers. ```bash php artisan sanvex:list ``` -------------------------------- ### Gmail Driver Usage Examples Source: https://sanvex.vercel.app/docs/drivers/gmail PHP examples demonstrating how to use the Gmail driver to list, get, and send messages, and list threads. ```php $gmail = $manager->resolveDriver('gmail'); $gmail->messages()->list(['maxResults' => 10]); $gmail->messages()->get(['id' => 'message-id']); $gmail->messages()->send([...]); $gmail->threads()->list(); ``` -------------------------------- ### CLI setup for API key and bot token Source: https://sanvex.vercel.app/docs/concepts/authentication Demonstrates how to set up API keys and bot tokens for different drivers using the `sanvex:setup` command. ```bash # Global scope (default owner: global/default) php artisan sanvex:setup github --api-key="ghp_..." # Slack bot token php artisan sanvex:setup slack --bot-token="xoxb-..." # Tenant-scoped php artisan sanvex:setup notion --api-key="secret_..." \ --owner-type=App\Models\Team --owner-id=1 ``` -------------------------------- ### Install GitHub Driver Source: https://sanvex.vercel.app/docs/drivers/github Installs the GitHub driver package and runs database migrations. ```bash composer require sanvex/github php artisan migrate ``` -------------------------------- ### Typical install set - Minimal Source: https://sanvex.vercel.app/docs/concepts/packages Minimal install set with one driver and PHP only. ```bash composer require sanvex/core sanvex/cli sanvex/github php artisan migrate php artisan sanvex:setup github --api-key="ghp_..." ``` -------------------------------- ### Store credentials Source: https://sanvex.vercel.app/docs/getting-started/quickstart Set up the GitHub integration by providing your API key. ```bash php artisan sanvex:list php artisan sanvex:setup github --api-key="ghp_..." ``` -------------------------------- ### Run migrations Source: https://sanvex.vercel.app/docs/getting-started/quickstart Run the database migrations to set up the necessary tables. ```bash php artisan migrate ``` -------------------------------- ### Setup Command Source: https://sanvex.vercel.app/docs/drivers The general command to set up a Sanvex driver. ```bash php artisan sanvex:setup {driver} [--api-key=] [--bot-token=] [--owner-type=] [--owner-id=] ``` -------------------------------- ### Install Notion Driver Source: https://sanvex.vercel.app/docs/drivers/notion Installs the Sanvex Notion driver and runs database migrations. ```bash composer require sanvex/notion php artisan migrate ``` -------------------------------- ### Install Source: https://sanvex.vercel.app/docs/integrations/mcp Install the sanvex/mcp package using Composer. ```bash composer require sanvex/mcp ``` -------------------------------- ### Install drivers Source: https://sanvex.vercel.app/docs/getting-started/installation Installs packages for external services like GitHub, Gmail, Linear, Notion, and Slack. ```bash composer require sanvex/github # composer require sanvex/gmail # composer require sanvex/linear # composer require sanvex/notion # composer require sanvex/slack ``` -------------------------------- ### Publish configuration Source: https://sanvex.vercel.app/docs/getting-started/installation Publishes the Sanvex configuration file to the application. ```bash php artisan vendor:publish --tag=sanvex-config ``` -------------------------------- ### Typical install set - With agent tooling Source: https://sanvex.vercel.app/docs/concepts/packages Typical install set with agent tooling. ```bash composer require sanvex/core sanvex/cli sanvex/github sanvex/mcp # or composer require sanvex/core sanvex/cli sanvex/github sanvex/laravel-ai ``` -------------------------------- ### Install Slack Driver Source: https://sanvex.vercel.app/docs/drivers/slack Commands to install the Slack driver using Composer and run migrations. ```bash composer require sanvex/slack php artisan migrate ``` -------------------------------- ### Local DB Usage Example Source: https://sanvex.vercel.app/docs/drivers/slack Example of how to use the Slack driver's local database methods. ```php $slack->db()->messages()->list(); $slack->db()->channels()->list(); ``` -------------------------------- ### Usage Example Source: https://sanvex.vercel.app/docs/drivers/slack Example of how to use the Slack driver to interact with Slack API methods. ```php $slack = $manager->resolveDriver('slack'); $slack->channels()->list(); $slack->messages()->post(['channel' => 'C123', 'text' => 'Hello']); $slack->users()->info(['user' => 'U123']); ``` -------------------------------- ### sanvex/core Source: https://sanvex.vercel.app/docs/concepts/packages Install the core package. ```bash composer require sanvex/core ``` -------------------------------- ### Usage Example Source: https://sanvex.vercel.app/docs/drivers/github Demonstrates how to use the GitHub driver to list repositories, create issues, and merge pull requests. ```php $github = $manager->resolveDriver('github'); $github->repositories()->list(['per_page' => 10]); $github->issues()->create([ 'owner' => 'org', 'repo' => 'repo', 'title' => 'Bug report', ]); $github->pullRequests()->merge(['owner' => 'org', 'repo' => 'repo', 'pull_number' => 42]); ``` -------------------------------- ### Setup with Integration Token (API Key) Source: https://sanvex.vercel.app/docs/drivers/notion Sets up the Notion driver using an API key. ```bash php artisan sanvex:setup notion --api-key="secret_..." ``` -------------------------------- ### Tenant-Scoped Setup with API Key Source: https://sanvex.vercel.app/docs/drivers/github Sets up the GitHub driver with an API key for a specific tenant. ```bash php artisan sanvex:setup github --api-key="ghp_..." \ --owner-type=App\Models\User --owner-id=1 ``` -------------------------------- ### Install Linear Driver Source: https://sanvex.vercel.app/docs/drivers/linear Commands to install the Linear driver using Composer and run database migrations. ```bash composer require sanvex/linear php artisan migrate ``` -------------------------------- ### Install Gmail Driver Source: https://sanvex.vercel.app/docs/drivers/gmail Commands to install the Gmail driver using Composer and run migrations. ```bash composer require sanvex/gmail php artisan migrate ``` -------------------------------- ### Optional agent packages Source: https://sanvex.vercel.app/docs/getting-started/installation Installs optional agent packages for MCP server and Laravel AI SDK tools. ```bash composer require sanvex/mcp # MCP server composer require sanvex/laravel-ai # Laravel AI SDK tools ``` -------------------------------- ### sanvex/cli Source: https://sanvex.vercel.app/docs/concepts/packages Install the CLI package. ```bash composer require sanvex/cli ``` -------------------------------- ### Setup GitHub Driver with API Key Source: https://sanvex.vercel.app/docs/drivers/github Sets up the GitHub driver using a personal access token (API key). ```bash php artisan sanvex:setup github --api-key="ghp_..." ``` -------------------------------- ### Usage Example Source: https://sanvex.vercel.app/docs/drivers/notion Demonstrates how to resolve the Notion driver and use its methods to interact with Notion API. ```php $notion = $manager->resolveDriver('notion'); $notion->pages()->list(['page_size' => 10]); $notion->databases()->query(['database_id' => '...']); $notion->search()->list(['query' => 'roadmap']); ``` -------------------------------- ### Setup with OAuth (Environment Variables) Source: https://sanvex.vercel.app/docs/drivers/notion Configures environment variables for OAuth authentication with Notion. ```env NOTION_CLIENT_ID=your-client-id NOTION_CLIENT_SECRET=your-client-secret NOTION_REDIRECT_URI=https://your-app.test/sanvex/notion/callback NOTION_AUTH_TYPE=oauth_2 NOTION_SUCCESS_REDIRECT=/ ``` -------------------------------- ### Verify driver configuration Source: https://sanvex.vercel.app/docs/getting-started/installation Verifies if a driver is configured using the SanvexManager. ```php use Sanvex\Core\SanvexManager; $driver = app(SanvexManager::class)->resolveDriver('github'); $configured = $driver->isConfigured(); // true after setup ``` -------------------------------- ### sanvex/laravel-ai Source: https://sanvex.vercel.app/docs/concepts/packages Install the laravel-ai package. ```bash composer require sanvex/laravel-ai ``` -------------------------------- ### Setup Slack Driver with API Key Source: https://sanvex.vercel.app/docs/drivers/slack Command to set up the Slack driver using an API key (user token). ```bash php artisan sanvex:setup slack --api-key="xoxp-..." ``` -------------------------------- ### Tenant-scoped setup Source: https://sanvex.vercel.app/docs/concepts/tenancy Sets up credentials with specific owner type and ID for tenant-specific configurations. ```bash php artisan sanvex:setup slack --bot-token="xoxb-..." \ --owner-type=App\Models\Team --owner-id=42 ``` -------------------------------- ### Driver packages Source: https://sanvex.vercel.app/docs/concepts/packages Install only the drivers you use. ```bash composer require sanvex/github sanvex/slack ``` -------------------------------- ### Setup Linear Driver with API Key Source: https://sanvex.vercel.app/docs/drivers/linear Command to set up the Linear driver using an API key. ```bash php artisan sanvex:setup linear --api-key="lin_api..." ``` -------------------------------- ### Setup Slack Driver with Bot Token Source: https://sanvex.vercel.app/docs/drivers/slack Command to set up the Slack driver using a bot token. ```bash php artisan sanvex:setup slack --bot-token="xoxb-..." ``` -------------------------------- ### Stdio server Source: https://sanvex.vercel.app/docs/integrations/mcp Start the MCP server over stdin/stdout. This can be used with IDEs like Claude Desktop or Cursor. ```bash php artisan sanvex:mcp-stdio ``` -------------------------------- ### Local DB Usage Source: https://sanvex.vercel.app/docs/drivers/notion Example of using the local database functionality with the Notion driver. ```php $notion->db()->pages()->list(); ``` -------------------------------- ### Single Action Tool Example Source: https://sanvex.vercel.app/docs/integrations/laravel-ai Use a single tool that accepts driver, resource, action, and args to execute any exposed operation. ```php use Sanvex\LaravelAi\Ai\SanvexAi; public function agent(SanvexAi $sanvex) { return SomeAgent::make() ->tools([$sanvex->tool()]) ->prompt('List my GitHub repositories'); } ``` -------------------------------- ### Linear Driver Usage Example Source: https://sanvex.vercel.app/docs/drivers/linear PHP code demonstrating how to resolve the Linear driver and interact with its issues and projects APIs. ```php $linear = $manager->resolveDriver('linear'); $linear->issues()->list(); $linear->issues()->create([...]); $linear->projects()->get(['id' => 'project-id']); ``` -------------------------------- ### Local DB Usage Example Source: https://sanvex.vercel.app/docs/drivers/linear PHP code to interact with the local database for Linear issues. ```php $linear->db()->issues()->list(); ``` -------------------------------- ### Local DB Access for Gmail Driver Source: https://sanvex.vercel.app/docs/drivers/gmail PHP example showing how to access local database records for messages using the Gmail driver. ```php $gmail->db()->messages()->list(); ``` -------------------------------- ### Run migrations via CLI helper Source: https://sanvex.vercel.app/docs/concepts/database Alternatively, run the Sanvex core migrations using the CLI helper. ```bash php artisan sanvex:migrate ``` -------------------------------- ### Local DB Usage Source: https://sanvex.vercel.app/docs/drivers/github Shows how to interact with the local database storage for repositories and issues via the GitHub driver. ```php $github->db()->repositories()->list(); $github->db()->issues()->list(); ``` -------------------------------- ### Basic pattern Source: https://sanvex.vercel.app/docs/getting-started/usage Each driver exposes resources as methods on the driver instance. ```php $github = $manager->resolveDriver('github'); $github->repositories()->get(['owner' => 'laravel', 'repo' => 'framework']); $github->issues()->list(['owner' => 'laravel', 'repo' => 'framework']); $github->pullRequests()->create([...]); ``` -------------------------------- ### Check configuration Source: https://sanvex.vercel.app/docs/getting-started/usage Before calling a driver, verify credentials are stored. ```php $driver = $manager->resolveDriver('github'); if (! $driver->isConfigured()) { // Run: php artisan sanvex:setup github --api-key=... } ``` -------------------------------- ### Enable Run script tool Source: https://sanvex.vercel.app/docs/integrations/mcp Enable the RunScriptTool by setting SANVEX_MCP_ALLOW_RUN_SCRIPT to true in the .env file. This is disabled by default due to security risks. ```env SANVEX_MCP_ALLOW_RUN_SCRIPT=true ``` -------------------------------- ### Custom drivers Source: https://sanvex.vercel.app/docs/concepts/packages Register custom drivers in config/sanvex.php. ```php 'drivers' => [ \App\Sanvex\AcmeDriver::class, ], ``` -------------------------------- ### Multi-tenancy Source: https://sanvex.vercel.app/docs/getting-started/usage Scope credentials and driver instances to an owner. ```php $notion = ->for(auth()->user()) ->resolveDriver('notion'); $pages = $notion->pages()->list(['page_size' => 10]); ``` -------------------------------- ### Runtime usage with owner context Source: https://sanvex.vercel.app/docs/concepts/tenancy Resolves a driver instance scoped to a specific owner (e.g., authenticated user). ```php use Sanvex\Core\SanvexManager; public function pages(SanvexManager $manager) { return $manager ->for(auth()->user()) ->resolveDriver('notion') ->pages() ->list(['page_size' => 10]); } ``` -------------------------------- ### Enable HTTP SSE Source: https://sanvex.vercel.app/docs/integrations/mcp Enable HTTP transport for the MCP server by setting SANVEX_MCP_ENABLE_SERVER to true in the .env file. ```env SANVEX_MCP_ENABLE_SERVER=true ``` -------------------------------- ### Inspect Metadata Source: https://sanvex.vercel.app/docs/integrations/laravel-ai Inspect available drivers and actions without executing them. ```php $metadata = app(SanvexAi::class)->metadata(); // or filter: $metadata = app(SanvexAi::class)->metadata(['github']); ``` -------------------------------- ### Generate a dedicated KEK Source: https://sanvex.vercel.app/docs/concepts/database Generate a dedicated Key Encryption Key (KEK) for encrypting credentials. ```bash php artisan sanvex:keygen ``` -------------------------------- ### Global scope usage Source: https://sanvex.vercel.app/docs/concepts/tenancy Resolves a driver instance using the global scope, which is the default. ```php // Same as for(null)->resolveDriver('github') $manager->resolveDriver('github'); ``` -------------------------------- ### Per-Operation Tools for Specific Drivers Source: https://sanvex.vercel.app/docs/integrations/laravel-ai Generate one Laravel AI tool per driver resource action. ```php $sanvex->driver('github')->tools(); // or multiple drivers: $sanvex->drivers(['github', 'slack'])->tools(); ``` -------------------------------- ### System Driver for Introspection Source: https://sanvex.vercel.app/docs/integrations/laravel-ai The tool always allows 'driver: "system"' for introspection purposes. ```json { "driver": "system", "resource": "drivers", "action": "list.configured", "args": {} } ``` -------------------------------- ### Local database access Source: https://sanvex.vercel.app/docs/getting-started/usage Some drivers cache entities in `sv_entities`. Access them via `db()`. ```php $github = $manager->resolveDriver('github'); $repos = $github->db()->repositories()->list(); ``` -------------------------------- ### Filter Per-Operation Tools Source: https://sanvex.vercel.app/docs/integrations/laravel-ai Filter the generated tools by read-only status and exclude specific actions. ```php $sanvex->driver('github') ->readOnly() ->except(['repositories.delete']) ->tools(); ``` -------------------------------- ### Restrict Single Action Tool to Specific Drivers Source: https://sanvex.vercel.app/docs/integrations/laravel-ai Limit the single action tool to a specified list of drivers. ```php $sanvex->tool(['github', 'slack']); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.