{"id":47336804,"url":"https://github.com/RedberryProducts/mcp-client-laravel","last_synced_at":"2026-04-01T02:00:33.934Z","repository":{"id":317418966,"uuid":"1009459294","full_name":"RedberryProducts/mcp-client-laravel","owner":"RedberryProducts","description":"Laravel-native client for Model Context Protocol (MCP) servers. Built by Redberry (Diamond-tier Laravel partner). Used by LarAgent and other frameworks to enable AI agent functionality.","archived":false,"fork":false,"pushed_at":"2026-01-12T03:42:31.000Z","size":157,"stargazers_count":13,"open_issues_count":8,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-19T07:38:53.458Z","etag":null,"topics":["agent-integration","ai-agents","ai-framework","chatbot","context","laravel","laravel-ai","laravel-package","llm","mcp","mcp-client","memory","openai","php","prompt-engineering","redberry","tools"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedberryProducts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"Redberry"}},"created_at":"2025-06-27T07:01:20.000Z","updated_at":"2025-12-19T10:51:51.000Z","dependencies_parsed_at":"2025-09-30T19:29:55.791Z","dependency_job_id":null,"html_url":"https://github.com/RedberryProducts/mcp-client-laravel","commit_stats":null,"previous_names":["redberryproducts/mcp-client-laravel"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/RedberryProducts/mcp-client-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedberryProducts%2Fmcp-client-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedberryProducts%2Fmcp-client-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedberryProducts%2Fmcp-client-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedberryProducts%2Fmcp-client-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedberryProducts","download_url":"https://codeload.github.com/RedberryProducts/mcp-client-laravel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedberryProducts%2Fmcp-client-laravel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31262837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T01:56:54.585Z","status":"online","status_checked_at":"2026-04-01T02:00:07.777Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-integration","ai-agents","ai-framework","chatbot","context","laravel","laravel-ai","laravel-package","llm","mcp","mcp-client","memory","openai","php","prompt-engineering","redberry","tools"],"created_at":"2026-03-17T22:00:50.933Z","updated_at":"2026-04-01T02:00:33.899Z","avatar_url":"https://github.com/RedberryProducts.png","language":"PHP","funding_links":["https://github.com/sponsors/Redberry"],"categories":["Natural Language Processing"],"sub_categories":["MCP \u0026 Agent Tooling"],"readme":"# MCP Client for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/redberry/mcp-client-laravel.svg?style=flat-square)](https://packagist.org/packages/redberry/mcp-client-laravel)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/redberryproducts/mcp-client-laravel/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/redberryproducts/mcp-client-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/redberryproducts/mcp-client-laravel/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/redberryproducts/mcp-client-laravel/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/redberry/mcp-client-laravel.svg?style=flat-square)](https://packagist.org/packages/redberry/mcp-client-laravel)\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eLaravel-native client for Model Context Protocol (MCP) servers\u003c/strong\u003e\u003cbr\u003e\n  Built and maintained by \u003ca href=\"[https://redberry.international](https://redberry.international/?utm_source=github\u0026utm_medium=github_mcp_readme\u0026utm_campaign=AI+service+campaign)\"\u003eRedberry\u003c/a\u003e, a Diamond-tier official Laravel partner.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"[https://redberry.international/ai-agent-development/](https://redberry.international/ai-agent-development/?utm_source=github\u0026utm_medium=github_mcp_readme\u0026utm_campaign=AI+service+campaign)\"\u003eAI PoC Sprint\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## 🚀 What is This?\n\nThis package provides a Laravel-native client for interacting with **Model Context Protocol (MCP)** servers — enabling your Laravel application to communicate with external tools, structured resources, and memory services in a standardized way.\n\nIt is **framework-agnostic** and can be used in any Laravel application. Agent frameworks like [LarAgent](https://github.com/MaestroError/LarAgent) use this package internally to enable tool use, memory management, and reasoning across distributed contexts.\n\nUse it to:\n\n- Connect to any MCP-compliant server over HTTP or STDIO\n- Discover and call tools defined on MCP servers\n- Access structured memory and contextual resources\n- Extend your Laravel apps with AI-ready interfaces to external agents or toolchains\n\n\u003e 🚀 Looking to build an AI agent in Laravel? [Talk to us]([https://redberry.international/ai-agent-development/](https://redberry.international/ai-agent-development/?utm_source=github\u0026utm_medium=github_mcp_readme\u0026utm_campaign=AI+service+campaign)) about our 5-week PoC sprint — from idea to working prototype.\n\n## Installation\n_Note that while project is running with `php artisan serve` **STDIO** transporter doesn't work_\n\nYou can install the package via composer:\n\n```bash\ncomposer require redberry/mcp-client-laravel\n```\n\nAfter installation, publish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=\"mcp-client-config\"\n```\n\nThis will create a `config/mcp-client.php` file in your application.\n\n## Configuration\n\nThe published configuration file contains settings for your MCP servers. Here's an example configuration:\n\n```php\nreturn [\n    'servers' =\u003e [\n        'github' =\u003e [\n            'type' =\u003e \\Redberry\\MCPClient\\Enums\\Transporters::HTTP,\n            'base_url' =\u003e 'https://api.githubcopilot.com/mcp',\n            'timeout' =\u003e 30,\n            'token' =\u003e env('GITHUB_API_TOKEN', null),\n        ],\n        'npx_mcp_server' =\u003e [\n            'type' =\u003e \\Redberry\\MCPClient\\Enums\\Transporters::STDIO,\n            'command' =\u003e [\n                'npx',\n                '-y',\n                '@modelcontextprotocol/server-memory',\n            ],\n            'timeout' =\u003e 30,\n            'cwd' =\u003e base_path(),\n        ],\n    ],\n];\n```\n\n### Configuration Options\n\n#### HTTP Transporter\n\n-   `type`: Set to `Redberry\\MCPClient\\Enums\\Transporters::HTTP` for HTTP connections\n-   `base_url`: The base URL of the MCP server\n-   `timeout`: Request timeout in seconds\n-   `token`: Authentication token (if required)\n\n#### STDIO Transporter\n\n-   `type`: Set to `Redberry\\MCPClient\\Enums\\Transporters::STDIO` for STDIO connections\n-   `command`: Array of command parts to execute the MCP server\n-   `timeout`: Command timeout in seconds\n-   `cwd`: Current working directory for the command\n\n## Usage\n\n### Basic Usage\n\n```php\nuse Redberry\\MCPClient\\Facades\\MCPClient;\n\n// Connect to a specific MCP server defined in your config\n$client = MCPClient::connect('github');\n\n// Get available tools from the MCP server\n$tools = $client-\u003etools();\n\n// Get available resources from the MCP server\n$resources = $client-\u003eresources();\n```\n\n### Using Dependency Injection\n\n```php\nuse Redberry\\MCPClient\\MCPClient;\n\nclass MyService\n{\n    public function __construct(private MCPClient $mcpClient)\n    {\n    }\n\n    public function getToolsFromGithub()\n    {\n        return $this-\u003emcpClient-\u003econnect('github')-\u003etools();\n    }\n}\n```\n\n### Working with Collections\n\nThe `tools()` and `resources()` methods return a `Collection` object that provides helpful methods for working with the results:\n\n```php\n// Get all tools as an array\n$allTools = $client-\u003etools()-\u003eall();\n\n// Get only specific tools by name\n$specificTools = $client-\u003etools()-\u003eonly('tool1', 'tool2');\n\n// Exclude specific tools\n$filteredTools = $client-\u003etools()-\u003eexcept('tool3');\n\n// Map over tools\n$mappedTools = $client-\u003etools()-\u003emap(function ($tool) {\n    return $tool['name'];\n});\n```\n\n### Call tools\n\nThe `callTool` method is used to execute specific tool. Here is the signature:\n\n```php\npublic function callTool(string $toolName, mixed $params = []): mixed;\n```\n\nExample:\n\n```php\n$result = $client-\u003ecallTool('create_entities', [\n    'entities' =\u003e [\n        [\n            'name' =\u003e 'John Doe',\n            'entityType' =\u003e 'PERSON',\n            'observations' =\u003e ['Test observation 1', 'Test observation 2'],\n        ]\n    ],\n]);\n```\n\n### Read Resources\n\nThe `readResource` method is used to retrieve the resource by the `uri`.\n\n```php\npublic function readResource(string $uri): mixed;\n```\n\nExample:\n\n```php\n$result = $client-\u003ereadResource(\"file:///project/src/main.rs\");\n```\n\n## Advanced Usage\n\n### Creating Custom Transporters\n\nIf you need to create a custom transporter, you can extend the `Transporter` interface and implement your own transport mechanism. Then register it in the `TransporterFactory`.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n-   [Nika Jorjoliani](https://github.com/nikajorjika)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRedberryProducts%2Fmcp-client-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRedberryProducts%2Fmcp-client-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRedberryProducts%2Fmcp-client-laravel/lists"}