{"id":26178956,"url":"https://github.com/php-llm/mcp-demo","last_synced_at":"2025-06-14T21:02:49.159Z","repository":{"id":281252502,"uuid":"944695416","full_name":"php-llm/mcp-demo","owner":"php-llm","description":"Demo application for the Model Context Protocol SDK","archived":false,"fork":false,"pushed_at":"2025-03-07T20:26:56.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T21:25:02.322Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/php-llm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-03-07T20:00:13.000Z","updated_at":"2025-03-07T20:26:59.000Z","dependencies_parsed_at":"2025-03-07T21:35:28.424Z","dependency_job_id":null,"html_url":"https://github.com/php-llm/mcp-demo","commit_stats":null,"previous_names":["php-llm/mcp-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/php-llm/mcp-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-llm%2Fmcp-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-llm%2Fmcp-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-llm%2Fmcp-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-llm%2Fmcp-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-llm","download_url":"https://codeload.github.com/php-llm/mcp-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-llm%2Fmcp-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259884416,"owners_count":22926440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-03-11T21:48:11.565Z","updated_at":"2025-06-14T21:02:49.107Z","avatar_url":"https://github.com/php-llm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP MCP Demo\n\nSimple demo gluing together [MCP](https://modelcontextprotocol.io/) with Symfony and [LLM Chain](https://github.com/php-llm/llm-chain) - heavily inspired by @lyrixx [MCP blog post](https://jolicode.com/blog/mcp-the-open-protocol-that-turns-llm-chatbots-into-intelligent-agents).\n\n## Requirements\n\n* PHP 8.4\n* Composer\n* Symfony CLI\n* NPX\n\n## Installation\n\nSetting up the Symfony project:\n\n```bash\ngit clone git@github.com:php-llm/mcp-demo.git\ncd mcp-demo\ncomposer install\nsymfony serve -d --no-tls\n```\n\nRunning the MCP Inspector:\n\n```bash\nnpx -y @modelcontextprotocol/inspector\n```\n\n## Usage\n\nOpen the MCP Inspector in your browser, for example at `http://localhost:5173/`.\n\nFor STDIO use:\n* Transport Type: `STDIO`\n* Command: `/path/to/mcp-demo/bin/console`\n* Arguments: `mcp`\n\nFor SSE use:\n* Transport Type: `SSE`\n* URL: `http://localhost:8000/mcp/sse` (port might differ)\n\nClick `Connect` and you should be able to use the tools of the Symfony app via the MCP Inspector.\n\n![demo.png](demo.png)\n\n## SDK\n\nServer integration points for are tailored to Symfony Console and HttpFoundation (Laravel compatible).\n\n### Example Console Command for STDIO\n\n```php\n#[AsCommand('mcp', 'Starts an MCP server')]\nclass McpCommand extends Command\n{\n    public function __construct(\n        private readonly Server $server,\n    ) {\n        parent::__construct();\n    }\n\n    protected function execute(InputInterface $input, OutputInterface $output): int\n    {\n        $this-\u003eserver-\u003econnect(\n            new SymfonyConsoleTransport($input, $output)\n        );\n\n        return Command::SUCCESS;\n    }\n}\n```\nSee [McpCommand.php](src/Command/McpCommand.php) for the full example.\n\n### Example Controller for Server-Sent Events\n\n```php\n#[AsController]\n#[Route('/mcp', name: 'mcp_')]\nfinal readonly class McpController\n{\n    public function __construct(\n        private Server $server,\n        private CachePoolStore $store,\n        private UrlGeneratorInterface $urlGenerator,\n    ) {\n    }\n\n    #[Route('/sse', name: 'sse', methods: ['GET'])]\n    public function sse(): StreamedResponse\n    {\n        $id = Uuid::v4();\n        $endpoint = $this-\u003eurlGenerator-\u003egenerate('mcp_messages', ['id' =\u003e $id], UrlGeneratorInterface::ABSOLUTE_URL);\n        $transport = new StreamTransport($endpoint, $this-\u003estore, $id);\n\n        return new StreamedResponse(fn() =\u003e $this-\u003eserver-\u003econnect($transport), headers: [\n            'Content-Type' =\u003e 'text/event-stream',\n            'Cache-Control' =\u003e 'no-cache',\n            'X-Accel-Buffering' =\u003e 'no',\n        ]);\n    }\n\n    #[Route('/messages/{id}', name: 'messages', methods: ['POST'])]\n    public function messages(Request $request, Uuid $id): Response\n    {\n        $this-\u003estore-\u003epush($id, $request-\u003egetContent());\n\n        return new Response();\n    }\n}\n```\nSee [McpController.php](src/Controller/McpController.php) for the full example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-llm%2Fmcp-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-llm%2Fmcp-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-llm%2Fmcp-demo/lists"}