{"id":29646330,"url":"https://github.com/xp-forge/mcp","last_synced_at":"2026-01-03T20:13:13.323Z","repository":{"id":299095574,"uuid":"1002040755","full_name":"xp-forge/mcp","owner":"xp-forge","description":"Model Context Protocol","archived":false,"fork":false,"pushed_at":"2025-06-14T17:12:47.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-14T17:24:40.572Z","etag":null,"topics":["mcp-client","modelcontextprotocol","php7","php8","xp-framework"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-forge.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-06-14T15:33:02.000Z","updated_at":"2025-06-14T17:12:29.000Z","dependencies_parsed_at":"2025-06-14T17:34:50.222Z","dependency_job_id":null,"html_url":"https://github.com/xp-forge/mcp","commit_stats":null,"previous_names":["xp-forge/mcp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/xp-forge/mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-forge","download_url":"https://codeload.github.com/xp-forge/mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fmcp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266413570,"owners_count":23924760,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["mcp-client","modelcontextprotocol","php7","php8","xp-framework"],"created_at":"2025-07-22T02:38:54.725Z","updated_at":"2026-01-03T20:13:13.318Z","avatar_url":"https://github.com/xp-forge.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Model Context Protocol\n======================\n\n[![Build status on GitHub](https://github.com/xp-forge/mcp/workflows/Tests/badge.svg)](https://github.com/xp-forge/mcp/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-forge/mcp/version.svg)](https://packagist.org/packages/xp-forge/mcp)\n\nImplements the [Model Context Protocol](https://modelcontextprotocol.io/) for the XP Framework.\n\nClient\n------\nConnecting to an MCP server:\n\n```php\nuse io\\modelcontextprotocol\\McpClient;\nuse util\\cmd\\Console;\n\n// Use streamable HTTP\n$client= new McpClient('http://localhost:3001');\n\n// Use standard I/O\n$client= new McpClient(['docker', 'run', '--rm', '-i', 'mcp/time']);\n\n$response= $client-\u003ecall('tools/list');\nConsole::writeLine($response-\u003evalue());\n```\n\nServer\n------\nUses the [xp-forge/web](https://github.com/xp-forge/web) library:\n\n```php\nuse io\\modelcontextprotocol\\McpServer;\nuse io\\modelcontextprotocol\\server\\{Tool, Param};\nuse web\\Application;\n\nclass Test extends Application {\n\n  public function routes() {\n    return new McpServer([\n      'greeting' =\u003e new class() {\n\n        /** Sends a greeting */\n        #[Tool]\n        public function greet(#[Param('Whom to greet')] $name= null) {\n          return 'Hello, '.($name ?? 'unknown user');\n        }\n      }\n    ]);\n  }\n}\n```\n\nRun this via `xp -supervise web Test`.\n\nOrganizing code\n---------------\nMCP tools, resources and prompts may be organized into classes as follows:\n\n```php\nnamespace com\\example\\api;\n\nuse io\\modelcontextprotocol\\server\\{Resource, Prompt, Tool, Param, Implementation};\n\n#[Implementation]\nclass Greeting {\n\n  /** Dynamic greeting for a user */\n  #[Resource('greeting://user/{name}')]\n  public function get($name) {\n    return \"Hello {$name}\";\n  }\n\n  /** Greets users */\n  #[Prompt]\n  public function user(\n    #[Param('Whom to greet')] $name,\n    #[Param(type: ['type' =\u003e 'string', 'enum' =\u003e ['casual', 'friendly']])] $style= 'casual'\n  ) {\n    return \"Write a {$style} greeting for {$name}\";\n  }\n\n  /** Sends a given greeting by email */\n  #[Tool]\n  public function send(\n    #[Param('Recipient email address')] $recipient,\n    #[Param('The text to send')] $greeting\n  ) {\n    // TBI\n  }\n}}\n```\n\nThe web application then becomes this:\n\n```php\nuse io\\modelcontextprotocol\\McpServer;\nuse web\\Application;\n\nclass Test extends Application {\n\n  public function routes() {\n    return new McpServer('com.example.api');\n  }\n}\n```\n\nAuthentication\n--------------\nTo add OAuth2 authentication to your server, use the following:\n\n```php\nuse io\\modelcontextprotocol\\McpServer;\nuse io\\modelcontextprotocol\\server\\{ImplementationsIn, OAuth2Gateway, Clients, UseSession};\nuse web\\Application;\nuse web\\session\\InFileSystem;\n\nclass Test extends Application {\n\n  public function routes() {\n    $clients= new class() extends Clients { /* TBI */ };\n\n    $sessions= (new InFileSystem())-\u003enamed('oauth');\n    $gateway= new OAuth2Gateway('/oauth', $clients, new UseSession($sessions));\n\n    $auth= /* Some class extending web.auth.Authentication */;\n\n    $server= new McpServer(new ImplementationsIn('impl'));\n    return [\n      '/mcp'   =\u003e $gateway-\u003eauthenticate($server),\n      '/oauth' =\u003e $gateway-\u003eflow($auth, $sessions),\n      '/.well-known/oauth-protected-resource'   =\u003e $gateway-\u003eresource(),\n      '/.well-known/oauth-authorization-server' =\u003e $gateway-\u003emetadata(),\n    ];\n  }\n}\n```\n\nSee also\n--------\n* https://github.com/modelcontextprotocol/servers\n* https://modelcontextprotocol.io/docs/learn/server-concepts\n* https://modelcontextprotocol.io/specification/2025-06-18\n* https://deadprogrammersociety.com/2025/03/calling-mcp-servers-the-hard-way.html\n* https://blog.christianposta.com/understanding-mcp-authorization-with-dynamic-client-registration/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fmcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-forge%2Fmcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fmcp/lists"}