Skip to content
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy Documentation

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: write

jobs:
deploy:
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: Install Composer
uses: "ramsey/composer-install@v3"

- name: Generate API Documentation
run: make docs

- name: Copy API docs into docs directory
run: cp -r build/docs docs/api

- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
enable_jekyll: true
3 changes: 3 additions & 0 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ jobs:

- name: PHPStan
run: vendor/bin/phpstan analyse

- name: Documentation
run: make docs
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ vendor
examples/**/dev.log
examples/**/cache
examples/**/sessions

# phpDocumentor
build/
.phpdoc/
phpDocumentor.phar
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: deps-stable deps-low cs rector phpstan tests coverage run-examples ci ci-stable ci-lowest
.PHONY: deps-stable deps-low cs rector phpstan tests coverage run-examples ci ci-stable ci-lowest docs

deps-stable:
composer update --prefer-stable
Expand Down Expand Up @@ -29,3 +29,8 @@ ci: ci-stable
ci-stable: deps-stable cs phpstan tests

ci-lowest: deps-low cs phpstan tests

docs:
vendor/bin/phpdoc
@grep -q 'No errors have been found' build/docs/reports/errors.html || \
(echo "Documentation errors found. See build/docs/reports/errors.html" && exit 1)
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@
"symfony/uid": "^6.4 || ^7.3 || ^8.0"
},
"require-dev": {
"laminas/laminas-httphandlerrunner": "^2.12",
"nyholm/psr7": "^1.8",
"nyholm/psr7-server": "^1.1",
"phar-io/composer-distributor": "^1.0.2",
"php-cs-fixer/shim": "^3.91",
"phpdocumentor/shim": "^3",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.5",
"psr/cache": "^3.0",
"psr/simple-cache": "^3.0",
"symfony/cache": "^6.4 || ^7.3 || ^8.0",
"symfony/console": "^6.4 || ^7.3 || ^8.0",
"symfony/process": "^6.4 || ^7.3 || ^8.0",
"nyholm/psr7": "^1.8",
"nyholm/psr7-server": "^1.1",
"laminas/laminas-httphandlerrunner": "^2.12"
"symfony/process": "^6.4 || ^7.3 || ^8.0"
},
"autoload": {
"psr-4": {
Expand All @@ -69,7 +71,8 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": false
"php-http/discovery": false,
"phpdocumentor/shim": true
}
}
}
2 changes: 2 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include:
- _*
12 changes: 12 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=api/">
<link rel="canonical" href="api/">
<title>MCP PHP SDK Documentation</title>
</head>
<body>
<p>Redirecting to <a href="api/">API Documentation</a>...</p>
</body>
</html>
25 changes: 25 additions & 0 deletions phpdoc.dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor
configVersion="3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.phpdoc.org"
xsi:noNamespaceSchemaLocation="https://docs.phpdoc.org/latest/phpdoc.xsd"
>
<title>MCP PHP SDK</title>
<paths>
<output>build/docs</output>
</paths>
<version number="latest">
<api>
<source dsn=".">
<path>src</path>
</source>
<output>api</output>
<ignore>
<path>vendor/**/*</path>
<path>tests/**/*</path>
</ignore>
</api>
</version>
<setting name="graphs.enabled" value="true"/>
</phpdocumentor>
6 changes: 3 additions & 3 deletions src/JsonRpc/MessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class MessageFactory
/**
* Registry of all known message classes that have methods.
*
* @var array<int, class-string<Request|Notification>>
* @var list<class-string<Request>|class-string<Notification>>
*/
private const REGISTERED_MESSAGES = [
Schema\Notification\CancelledNotification::class,
Expand Down Expand Up @@ -68,7 +68,7 @@ final class MessageFactory
];

/**
* @param array<int, class-string<Request|Notification>> $registeredMessages
* @param list<class-string<Request>|class-string<Notification>> $registeredMessages
*/
public function __construct(
private readonly array $registeredMessages,
Expand Down Expand Up @@ -151,7 +151,7 @@ private function createMessage(array $data): MessageInterface
/**
* Finds the registered message class for a given method name.
*
* @return class-string<Request|Notification>
* @return class-string<Request>|class-string<Notification>
*
* @throws InvalidInputMessageException
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Server/Session/Psr16StoreSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
use Symfony\Component\Uid\Uuid;

/**
* @author luoyue <1569097443@qq.com>
*
* PSR-16 compliant cache-based session store.
*
* This implementation uses any PSR-16 compliant cache as the storage backend
* for session data. Each session is stored with a prefixed key using the session ID.
*
* @author luoyue <1569097443@qq.com>
*/
class Psr16StoreSession implements SessionStoreInterface
{
Expand Down