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
30 changes: 25 additions & 5 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:
pull-requests: write

jobs:
tests:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -22,16 +22,36 @@ jobs:
php-version: ${{ matrix.php }}
coverage: "none"

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

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

- name: Tests
run: vendor/bin/phpunit --exclude-group inspector
run: vendor/bin/phpunit --testsuite=unit

inspector:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

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

- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: '22'

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

- name: Tests
run: vendor/bin/phpunit --testsuite=inspector

qa:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.phpunit.cache
.php-cs-fixer.cache
composer.lock
coverage
vendor
examples/**/dev.log
examples/**/sessions
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ phpstan:
tests:
vendor/bin/phpunit

unit-tests:
vendor/bin/phpunit --testsuite=unit

inspector-tests:
vendor/bin/phpunit --testsuite=inspector

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

ci: ci-stable

Expand Down
4 changes: 2 additions & 2 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ parameters:
- tests/
excludePaths:
- examples/cli/vendor/* (?)
- tests/Capability/Discovery/Fixtures/
- tests/Capability/Discovery/SchemaGeneratorFixture.php
- tests/Unit/Capability/Discovery/Fixtures/
- tests/Unit/Capability/Discovery/SchemaGeneratorFixture.php
treatPhpDocTypesAsCertain: false
ignoreErrors:
-
Expand Down
7 changes: 5 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
failOnWarning="true">

<testsuites>
<testsuite name="default">
<directory>tests</directory>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="inspector">
<directory>tests/Inspector</directory>
</testsuite>
</testsuites>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Example;
namespace Mcp\Tests\Inspector;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand Down
29 changes: 29 additions & 0 deletions tests/Inspector/ManualStdioExampleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Inspector;

use Mcp\Tests\Inspector\InspectorSnapshotTestCase;

final class ManualStdioExampleTest extends InspectorSnapshotTestCase
{
public static function provideMethods(): array
{
return [
...parent::provideListMethods(),
];
}

protected function getServerScript(): string
{
return \dirname(__DIR__, 2).'/examples/03-manual-registration-stdio/server.php';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Example;
namespace Mcp\Tests\Inspector;

use PHPUnit\Framework\Attributes\Group;

#[Group('inspector')]
final class StdioCalculatorExampleTest extends InspectorSnapshotTestCase
{
public static function provideMethods(): array
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"prompts": [
{
"name": "personalized_greeting",
"description": "A manually registered prompt template.",
"arguments": [
{
"name": "userName",
"description": "the name of the user",
"required": true
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"resources": [
{
"name": "application_version",
"uri": "app://version",
"description": "A manually registered resource providing app version.",
"mimeType": "text/plain"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"tools": [
{
"name": "echo_text",
"description": "A manually registered tool to echo input.",
"inputSchema": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "the text to echo"
}
},
"required": [
"text"
]
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Attribute;
namespace Mcp\Tests\Unit\Capability\Attribute;

use Mcp\Capability\Prompt\Completion\ProviderInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Attribute;
namespace Mcp\Tests\Unit\Capability\Attribute;

use Mcp\Capability\Attribute\CompletionProvider;
use Mcp\Tests\Fixtures\Enum\StatusEnum;
use Mcp\Tests\Unit\Fixtures\Enum\StatusEnum;
use PHPUnit\Framework\TestCase;

class CompletionProviderTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Attribute;
namespace Mcp\Tests\Unit\Capability\Attribute;

use Mcp\Capability\Attribute\McpPrompt;
use PHPUnit\Framework\TestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Attribute;
namespace Mcp\Tests\Unit\Capability\Attribute;

use Mcp\Capability\Attribute\McpResourceTemplate;
use PHPUnit\Framework\TestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Attribute;
namespace Mcp\Tests\Unit\Capability\Attribute;

use Mcp\Capability\Attribute\McpResource;
use PHPUnit\Framework\TestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Attribute;
namespace Mcp\Tests\Unit\Capability\Attribute;

use Mcp\Capability\Attribute\McpTool;
use PHPUnit\Framework\TestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery;
namespace Mcp\Tests\Unit\Capability\Discovery;

use Mcp\Capability\Discovery\CachedDiscoverer;
use Mcp\Capability\Discovery\Discoverer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery;
namespace Mcp\Tests\Unit\Capability\Discovery;

use Mcp\Capability\Discovery\Discoverer;
use Mcp\Capability\Prompt\Completion\EnumCompletionProvider;
Expand All @@ -19,12 +19,12 @@
use Mcp\Capability\Registry\ResourceReference;
use Mcp\Capability\Registry\ResourceTemplateReference;
use Mcp\Capability\Registry\ToolReference;
use Mcp\Tests\Capability\Attribute\CompletionProviderFixture;
use Mcp\Tests\Capability\Discovery\Fixtures\DiscoverableToolHandler;
use Mcp\Tests\Capability\Discovery\Fixtures\InvocablePromptFixture;
use Mcp\Tests\Capability\Discovery\Fixtures\InvocableResourceFixture;
use Mcp\Tests\Capability\Discovery\Fixtures\InvocableResourceTemplateFixture;
use Mcp\Tests\Capability\Discovery\Fixtures\InvocableToolFixture;
use Mcp\Tests\Unit\Capability\Attribute\CompletionProviderFixture;
use Mcp\Tests\Unit\Capability\Discovery\Fixtures\DiscoverableToolHandler;
use Mcp\Tests\Unit\Capability\Discovery\Fixtures\InvocablePromptFixture;
use Mcp\Tests\Unit\Capability\Discovery\Fixtures\InvocableResourceFixture;
use Mcp\Tests\Unit\Capability\Discovery\Fixtures\InvocableResourceTemplateFixture;
use Mcp\Tests\Unit\Capability\Discovery\Fixtures\InvocableToolFixture;
use PHPUnit\Framework\TestCase;

class DiscoveryTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery;
namespace Mcp\Tests\Unit\Capability\Discovery;

use Mcp\Capability\Discovery\DocBlockParser;
use phpDocumentor\Reflection\DocBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery;
namespace Mcp\Tests\Unit\Capability\Discovery;

use Mcp\Tests\Capability\Discovery\Missing;

/**
* A stub class for testing DocBlock parsing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery\Fixtures;
namespace Mcp\Tests\Unit\Capability\Discovery\Fixtures;

use Mcp\Capability\Attribute\CompletionProvider;
use Mcp\Capability\Attribute\McpPrompt;
use Mcp\Tests\Capability\Attribute\CompletionProviderFixture;
use Mcp\Tests\Unit\Capability\Attribute\CompletionProviderFixture;

class DiscoverablePromptHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery\Fixtures;
namespace Mcp\Tests\Unit\Capability\Discovery\Fixtures;

use Mcp\Capability\Attribute\McpResource;
use Mcp\Schema\Annotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery\Fixtures;
namespace Mcp\Tests\Unit\Capability\Discovery\Fixtures;

use Mcp\Capability\Attribute\CompletionProvider;
use Mcp\Capability\Attribute\McpResourceTemplate;
use Mcp\Tests\Capability\Attribute\CompletionProviderFixture;
use Mcp\Tests\Unit\Capability\Attribute\CompletionProviderFixture;

class DiscoverableTemplateHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery\Fixtures;
namespace Mcp\Tests\Unit\Capability\Discovery\Fixtures;

use Mcp\Capability\Attribute\McpTool;
use Mcp\Schema\ToolAnnotations;
use Mcp\Tests\Fixtures\Enum\BackedStringEnum;
use Mcp\Tests\Unit\Fixtures\Enum\BackedStringEnum;

class DiscoverableToolHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery\Fixtures;
namespace Mcp\Tests\Unit\Capability\Discovery\Fixtures;

use Mcp\Capability\Attribute\CompletionProvider;
use Mcp\Capability\Attribute\McpPrompt;
use Mcp\Capability\Attribute\McpResourceTemplate;
use Mcp\Tests\Fixtures\Enum\PriorityEnum;
use Mcp\Tests\Fixtures\Enum\StatusEnum;
use Mcp\Tests\Unit\Fixtures\Enum\PriorityEnum;
use Mcp\Tests\Unit\Fixtures\Enum\StatusEnum;

class EnhancedCompletionHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery\Fixtures;
namespace Mcp\Tests\Unit\Capability\Discovery\Fixtures;

use Mcp\Capability\Attribute\McpPrompt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Mcp\Tests\Capability\Discovery\Fixtures;
namespace Mcp\Tests\Unit\Capability\Discovery\Fixtures;

use Mcp\Capability\Attribute\McpResource;

Expand Down
Loading