Skip to content

Commit 63dc146

Browse files
committed
Kicking off the SDK based on Symfony's MCP SDK
1 parent 0044ffb commit 63dc146

File tree

89 files changed

+3922
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3922
-0
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.git* export-ignore
2+
/examples export-ignore
3+
/tests export-ignore
4+
/.php-cs-fixer.dist.php export-ignore
5+
/phpstan.dist.neon export-ignore
6+
/phpunit.xml.dist export-ignore

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @chr-hertel @Nyholm @CodeWithKyrian

.github/workflows/pipeline.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: pipeline
2+
on: pull_request
3+
4+
permissions:
5+
contents: read
6+
pull-requests: write
7+
8+
jobs:
9+
tests:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
php: ['8.2', '8.3', '8.4']
14+
dependencies: ['lowest', 'highest']
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php }}
23+
coverage: "none"
24+
25+
- name: Install Composer
26+
uses: "ramsey/composer-install@v3"
27+
with:
28+
dependency-versions: "${{ matrix.dependencies }}"
29+
30+
- name: Composer Validation
31+
run: composer validate --strict
32+
33+
- name: Install PHP Dependencies
34+
run: composer install --no-scripts
35+
36+
- name: Tests
37+
run: vendor/bin/phpunit
38+
39+
qa:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Setup PHP
46+
uses: shivammathur/setup-php@v2
47+
with:
48+
php-version: '8.2'
49+
coverage: "none"
50+
51+
- name: Install Composer
52+
uses: "ramsey/composer-install@v3"
53+
54+
- name: Composer Validation
55+
run: composer validate --strict
56+
57+
- name: Install PHP Dependencies
58+
run: composer install --no-scripts
59+
60+
- name: Code Style PHP
61+
run: vendor/bin/php-cs-fixer fix --dry-run
62+
63+
- name: PHPStan
64+
run: vendor/bin/phpstan analyse

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.phpunit.cache
2+
.php-cs-fixer.cache
3+
composer.lock
4+
vendor

.php-cs-fixer.dist.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (!file_exists(__DIR__.'/src')) {
13+
exit(0);
14+
}
15+
16+
$fileHeaderParts = [
17+
<<<'EOF'
18+
This file is part of the official PHP MCP SDK.
19+
20+
A collaboration between Symfony and the PHP Foundation.
21+
22+
EOF,
23+
<<<'EOF'
24+
25+
For the full copyright and license information, please view the LICENSE
26+
file that was distributed with this source code.
27+
EOF,
28+
];
29+
30+
return (new PhpCsFixer\Config())
31+
// @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7777
32+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
33+
->setRules([
34+
'@Symfony' => true,
35+
'@Symfony:risky' => true,
36+
'protected_to_private' => false,
37+
'declare_strict_types' => false,
38+
'header_comment' => [
39+
'header' => implode('', $fileHeaderParts),
40+
],
41+
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
42+
])
43+
->setRiskyAllowed(true)
44+
->setFinder((new PhpCsFixer\Finder())->in(__DIR__))
45+
;

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CHANGELOG
2+
=========
3+
4+
0.1
5+
---
6+
7+
* Add Model Context Protocol (MCP) implementation for LLM-application communication
8+
* Add JSON-RPC based protocol handling with `JsonRpcHandler`
9+
* Add three core MCP capabilities:
10+
- Resources: File-like data readable by clients (API responses, file contents)
11+
- Tools: Functions callable by LLMs (with user approval)
12+
- Prompts: Pre-written templates for specific tasks
13+
* Add multiple transport implementations:
14+
- Symfony Console Transport for testing and CLI applications
15+
- Stream Transport supporting Server-Sent Events (SSE) and HTTP streaming
16+
- STDIO transport for command-line interfaces
17+
* Add capability chains for organizing features:
18+
- `ToolChain` for tool management
19+
- `ResourceChain` for resource management
20+
- `PromptChain` for prompt template management
21+
* Add Server component managing transport connections
22+
* Add request/notification handlers for MCP operations
23+
* Add standardized interface enabling LLMs to interact with external systems
24+
* Add support for building LLM "plugins" with extra context capabilities

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
MIT License
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.PHONY: deps-stable deps-low cs rector phpstan tests coverage run-examples ci ci-stable ci-lowest
2+
3+
deps-stable:
4+
composer update --prefer-stable
5+
6+
deps-low:
7+
composer update --prefer-lowest
8+
9+
cs:
10+
vendor/bin/php-cs-fixer fix --diff --verbose
11+
12+
phpstan:
13+
vendor/bin/phpstan --memory-limit=-1
14+
15+
tests:
16+
vendor/bin/phpunit
17+
18+
coverage:
19+
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage
20+
21+
ci: ci-stable
22+
23+
ci-stable: deps-stable cs phpstan tests
24+
25+
ci-lowest: deps-low cs phpstan tests

composer.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "mcp/sdk",
3+
"type": "library",
4+
"description": "Model Context Protocol SDK for Client and Server applications in PHP",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Christopher Hertel",
9+
"email": "[email protected]"
10+
},
11+
{
12+
"name": "Tobias Nyholm",
13+
"email": "[email protected]"
14+
},
15+
{
16+
"name": "Kyrian Obikwelu",
17+
"email": "[email protected]"
18+
}
19+
],
20+
"require": {
21+
"php": "^8.2",
22+
"psr/log": "^1.0 || ^2.0 || ^3.0",
23+
"symfony/uid": "^6.4 || ^7.0"
24+
},
25+
"require-dev": {
26+
"phpstan/phpstan": "^2.1",
27+
"phpunit/phpunit": "^11.5",
28+
"symfony/console": "^6.4 || ^7.0",
29+
"psr/cache": "^3.0",
30+
"php-cs-fixer/shim": "^3.84"
31+
},
32+
"suggest": {
33+
"symfony/console": "To use SymfonyConsoleTransport for STDIO",
34+
"psr/cache": "To use CachePoolStore with SSE Transport"
35+
},
36+
"autoload": {
37+
"psr-4": {
38+
"Mcp\\": "src/"
39+
}
40+
},
41+
"autoload-dev": {
42+
"psr-4": {
43+
"Mcp\\Tests\\": "tests/"
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)