Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.git* export-ignore
/examples export-ignore
/tests export-ignore
/.php-cs-fixer.dist.php export-ignore
/phpstan.dist.neon export-ignore
/phpunit.xml.dist export-ignore
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @chr-hertel @Nyholm @CodeWithKyrian
64 changes: 64 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: pipeline
on: pull_request

permissions:
contents: read
pull-requests: write

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.1', '8.2', '8.3', '8.4']
dependencies: ['lowest', 'highest']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: "none"

- name: Install Composer
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: Composer Validation
run: composer validate --strict

- name: Install PHP Dependencies
run: composer install --no-scripts

- name: Tests
run: vendor/bin/phpunit

qa:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: "none"

- name: Install Composer
uses: "ramsey/composer-install@v3"

- name: Composer Validation
run: composer validate --strict

- name: Install PHP Dependencies
run: composer install --no-scripts

- name: Code Style PHP
run: vendor/bin/php-cs-fixer fix --dry-run

- name: PHPStan
run: vendor/bin/phpstan analyse
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.phpunit.cache
.php-cs-fixer.cache
composer.lock
vendor
45 changes: 45 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (!file_exists(__DIR__.'/src')) {
exit(0);
}

$fileHeaderParts = [
<<<'EOF'
This file is part of the official PHP MCP SDK.
A collaboration between Symfony and the PHP Foundation.

EOF,
<<<'EOF'
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF,
];

return (new PhpCsFixer\Config())
// @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7777
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'protected_to_private' => false,
'declare_strict_types' => false,
'header_comment' => [
'header' => implode('', $fileHeaderParts),
],
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
])
->setRiskyAllowed(true)
->setFinder((new PhpCsFixer\Finder())->in(__DIR__))
;
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CHANGELOG
=========

0.1
---

* Add Model Context Protocol (MCP) implementation for LLM-application communication
* Add JSON-RPC based protocol handling with `JsonRpcHandler`
* Add three core MCP capabilities:
- Resources: File-like data readable by clients (API responses, file contents)
- Tools: Functions callable by LLMs (with user approval)
- Prompts: Pre-written templates for specific tasks
* Add multiple transport implementations:
- Symfony Console Transport for testing and CLI applications
- Stream Transport supporting Server-Sent Events (SSE) and HTTP streaming
- STDIO transport for command-line interfaces
* Add capability chains for organizing features:
- `ToolChain` for tool management
- `ResourceChain` for resource management
- `PromptChain` for prompt template management
* Add Server component managing transport connections
* Add request/notification handlers for MCP operations
* Add standardized interface enabling LLMs to interact with external systems
* Add support for building LLM "plugins" with extra context capabilities
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.PHONY: deps-stable deps-low cs rector phpstan tests coverage run-examples ci ci-stable ci-lowest

deps-stable:
composer update --prefer-stable

deps-low:
composer update --prefer-lowest

cs:
vendor/bin/php-cs-fixer fix --diff --verbose

phpstan:
vendor/bin/phpstan --memory-limit=-1

tests:
vendor/bin/phpunit

coverage:
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage

ci: ci-stable

ci-stable: deps-stable cs phpstan tests

ci-lowest: deps-low cs phpstan tests
46 changes: 46 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "mcp/sdk",
"type": "library",
"description": "Model Context Protocol SDK for Client and Server applications in PHP",
"license": "MIT",
"authors": [
{
"name": "Christopher Hertel",
"email": "[email protected]"
},
{
"name": "Tobias Nyholm",
"email": "[email protected]"
},
{
"name": "Kyrian Obikwelu",
"email": "[email protected]"
}
],
"require": {
"php": "^8.1",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"symfony/uid": "^6.4 || ^7.0"
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.5",
"symfony/console": "^6.4 || ^7.0",
"psr/cache": "^3.0",
"php-cs-fixer/shim": "^3.84"
},
"suggest": {
"symfony/console": "To use SymfonyConsoleTransport for STDIO",
"psr/cache": "To use CachePoolStore with SSE Transport"
},
"autoload": {
"psr-4": {
"Mcp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Mcp\\Tests\\": "tests/"
}
}
}
Loading