Skip to content

Commit 7cd0864

Browse files
committed
Add linebreak to make it readable in IDE
1 parent 575f2f2 commit 7cd0864

File tree

5 files changed

+65
-29
lines changed

5 files changed

+65
-29
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# MCP PHP SDK
22

3-
The official PHP SDK for Model Context Protocol (MCP). It provides a framework-agnostic API for implementing MCP servers and clients in PHP.
3+
The official PHP SDK for Model Context Protocol (MCP). It provides a framework-agnostic API for implementing MCP servers
4+
and clients in PHP.
45

56
> [!IMPORTANT]
6-
> This SDK is currently in active development with ongoing refinement of its architecture and features. While functional, the API may experience changes as we work toward stabilization.
7+
> This SDK is currently in active development with ongoing refinement of its architecture and features. While
8+
> functional, the API may experience changes as we work toward stabilization.
79
>
810
> If you want to help us stabilize the SDK, please see the [issue tracker](https://github.com/modelcontextprotocol/php-sdk/issues).
911
10-
This project represents a collaboration between [the PHP Foundation](https://thephp.foundation/) and the [Symfony project](https://symfony.com/). It adopts development practices and standards from the Symfony project, including [Coding Standards](https://symfony.com/doc/current/contributing/code/standards.html) and the [Backward Compatibility Promise](https://symfony.com/doc/current/contributing/code/bc.html).
12+
This project represents a collaboration between [the PHP Foundation](https://thephp.foundation/) and the [Symfony project](https://symfony.com/). It adopts
13+
development practices and standards from the Symfony project, including [Coding Standards](https://symfony.com/doc/current/contributing/code/standards.html) and the
14+
[Backward Compatibility Promise](https://symfony.com/doc/current/contributing/code/bc.html).
1115

1216
Until the first major release, this SDK is considered [experimental](https://symfony.com/doc/current/contributing/code/experimental.html).
1317

@@ -249,11 +253,14 @@ $server = Server::builder()
249253

250254
## Contributing
251255

252-
We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project. See the [contributing guide](CONTRIBUTING.md) to get started before you [report issues](https://github.com/modelcontextprotocol/php-sdk/issues) and [send pull requests](https://github.com/modelcontextprotocol/php-sdk/pulls).
256+
We are passionate about supporting contributors of all levels of experience and would love to see you get involved in
257+
the project. See the [contributing guide](CONTRIBUTING.md) to get started before you [report issues](https://github.com/modelcontextprotocol/php-sdk/issues) and [send pull requests](https://github.com/modelcontextprotocol/php-sdk/pulls).
253258

254259
## Credits
255260

256-
The starting point for this SDK was the [PHP-MCP](https://github.com/php-mcp/server) project, initiated by [Kyrian Obikwelu](https://github.com/CodeWithKyrian), and the [Symfony AI initiative](https://github.com/symfony/ai). We are grateful for the work done by both projects and their contributors, which created a solid foundation for this SDK.
261+
The starting point for this SDK was the [PHP-MCP](https://github.com/php-mcp/server) project, initiated by
262+
[Kyrian Obikwelu](https://github.com/CodeWithKyrian), and the [Symfony AI initiative](https://github.com/symfony/ai). We are grateful for the work
263+
done by both projects and their contributors, which created a solid foundation for this SDK.
257264

258265
## License
259266

docs/examples.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Examples
22

3-
The MCP PHP SDK includes comprehensive examples demonstrating different patterns and use cases. Each example showcases specific features and can be run independently to understand how the SDK works.
3+
The MCP PHP SDK includes comprehensive examples demonstrating different patterns and use cases. Each example showcases
4+
specific features and can be run independently to understand how the SDK works.
45

56
## Table of Contents
67

@@ -13,7 +14,8 @@ The MCP PHP SDK includes comprehensive examples demonstrating different patterns
1314

1415
## Getting Started
1516

16-
All examples are located in the `examples/` directory and use the SDK dependencies from the root project. Most examples can be run directly without additional setup.
17+
All examples are located in the `examples/` directory and use the SDK dependencies from the root project. Most examples
18+
can be run directly without additional setup.
1719

1820
### Prerequisites
1921

docs/mcp-elements.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# MCP Elements
22

3-
MCP elements are the core capabilities of your server: Tools, Resources, Resource Templates, and Prompts. These elements define what your server can do and how clients can interact with it. The PHP MCP SDK provides both attribute-based discovery and manual registration methods.
3+
MCP elements are the core capabilities of your server: Tools, Resources, Resource Templates, and Prompts. These elements
4+
define what your server can do and how clients can interact with it. The PHP MCP SDK provides both attribute-based
5+
discovery and manual registration methods.
46

57
## Table of Contents
68

@@ -26,7 +28,8 @@ MCP defines four types of capabilities:
2628

2729
Each capability can be registered using two methods:
2830

29-
1. **Attribute-Based Discovery**: Use PHP attributes (`#[McpTool]`, `#[McpResource]`, etc.) on methods or classes. The server automatically discovers and registers them.
31+
1. **Attribute-Based Discovery**: Use PHP attributes (`#[McpTool]`, `#[McpResource]`, etc.) on methods or classes. The
32+
server automatically discovers and registers them.
3033

3134
2. **Manual Registration**: Explicitly register capabilities using `ServerBuilder` methods (`addTool()`, `addResource()`, etc.).
3235

@@ -315,7 +318,8 @@ public function getFile(string $path): string
315318

316319
## Resource Templates
317320

318-
Resource templates are **dynamic resources** that use parameterized URIs with variables. They follow all the same rules as static resources (URI schemas, return values, MIME types, etc.) but accept variables using [RFC 6570 URI template syntax](https://datatracker.ietf.org/doc/html/rfc6570).
321+
Resource templates are **dynamic resources** that use parameterized URIs with variables. They follow all the same rules
322+
as static resources (URI schemas, return values, MIME types, etc.) but accept variables using [RFC 6570 URI template syntax](https://datatracker.ietf.org/doc/html/rfc6570).
319323

320324
```php
321325
use Mcp\Capability\Attribute\McpResourceTemplate;
@@ -476,7 +480,9 @@ The SDK automatically validates that all messages have valid roles and converts
476480

477481
## Completion Providers
478482

479-
Completion providers help MCP clients offer auto-completion suggestions for Resource Templates and Prompts. Unlike Tools and static Resources (which can be listed via `tools/list` and `resources/list`), Resource Templates and Prompts have dynamic parameters that benefit from completion hints.
483+
Completion providers help MCP clients offer auto-completion suggestions for Resource Templates and Prompts. Unlike Tools
484+
and static Resources (which can be listed via `tools/list` and `resources/list`), Resource Templates and Prompts have
485+
dynamic parameters that benefit from completion hints.
480486

481487
### Completion Provider Types
482488

@@ -572,11 +578,13 @@ public function getUserProfile(
572578

573579
> **Important**
574580
>
575-
> Completion providers only offer **suggestions** to users. Users can still input any value, so **always validate parameters** in your handlers. Providers don't enforce validation - they're purely for UX improvement.
581+
> Completion providers only offer **suggestions** to users. Users can still input any value, so **always validate
582+
> parameters** in your handlers. Providers don't enforce validation - they're purely for UX improvement.
576583
577584
## Schema Generation and Validation
578585

579-
The SDK automatically generates JSON schemas for **tool parameters** using a sophisticated priority system. Schema generation applies to both attribute-discovered and manually registered tools.
586+
The SDK automatically generates JSON schemas for **tool parameters** using a sophisticated priority system. Schema
587+
generation applies to both attribute-discovered and manually registered tools.
580588

581589
### Schema Generation Priority
582590

@@ -682,7 +690,8 @@ public function makeApiRequest(string $endpoint, string $method, array $headers)
682690
}
683691
```
684692

685-
**Warning:** Only use complete schema override if you're well-versed with JSON Schema specification and have complex validation requirements that cannot be achieved through the priority system.
693+
**Warning:** Only use complete schema override if you're well-versed with JSON Schema specification and have complex
694+
validation requirements that cannot be achieved through the priority system.
686695

687696
## Discovery vs Manual Registration
688697

docs/server-builder.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Server Builder
22

3-
The server `Builder` is a fluent builder class that simplifies the creation and configuration of an MCP server instance. It provides methods for setting server information, configuring discovery, registering capabilities, and customizing various aspects of the server behavior.
3+
The server `Builder` is a fluent builder class that simplifies the creation and configuration of an MCP server instance.
4+
It provides methods for setting server information, configuring discovery, registering capabilities, and customizing
5+
various aspects of the server behavior.
46

57
## Table of Contents
68

@@ -40,7 +42,8 @@ $server = (new Builder())
4042
->build();
4143
```
4244

43-
Both methods return a `Builder` instance that you can configure with fluent methods. The `build()` method returns the final `Server` instance ready for use.
45+
Both methods return a `Builder` instance that you can configure with fluent methods. The `build()` method returns the
46+
final `Server` instance ready for use.
4447

4548
## Server Configuration
4649

@@ -126,7 +129,8 @@ $server = Server::builder()
126129
- If scanning `lib/` and there's `lib/tests/`, it will be excluded
127130
- But if `vendor/` and `tests/` are at the same level as `src/`, they're not scanned anyway (not in `scanDirs`)
128131

129-
> **Performance**: Always use a cache in production. The first run scans and caches all discovered MCP elements, making subsequent server startups nearly instantaneous.
132+
> **Performance**: Always use a cache in production. The first run scans and caches all discovered MCP elements, making
133+
> subsequent server startups nearly instantaneous.
130134
131135
## Session Management
132136

@@ -282,15 +286,17 @@ $server = Server::builder()
282286
);
283287
```
284288

285-
**Note:** `name` and `description` are optional for all manual registrations. If not provided, they will be derived from the handler's method name and docblock.
289+
**Note:** `name` and `description` are optional for all manual registrations. If not provided, they will be derived from
290+
the handler's method name and docblock.
286291

287292
For more details on MCP elements, handlers, and attribute-based discovery, see [MCP Elements](mcp-elements.md).
288293

289294
## Service Dependencies
290295

291296
### Container
292297

293-
The container is used to resolve handlers and their dependencies when handlers inject dependencies in their constructors. The SDK includes a basic container with simple auto-wiring capabilities.
298+
The container is used to resolve handlers and their dependencies when handlers inject dependencies in their constructors.
299+
The SDK includes a basic container with simple auto-wiring capabilities.
294300

295301
```php
296302
use Mcp\Capability\Registry\Container;
@@ -340,7 +346,8 @@ $server = Server::builder()
340346

341347
## Custom Capability Handlers
342348

343-
**Advanced customization for specific use cases.** Override the default capability handlers when you need completely custom behavior for how tools are executed, resources are read, or prompts are generated. Most users should stick with the default implementations.
349+
**Advanced customization for specific use cases.** Override the default capability handlers when you need completely custom
350+
behavior for how tools are executed, resources are read, or prompts are generated. Most users should stick with the default implementations.
344351

345352
The default handlers work by:
346353
1. Looking up registered tools/resources/prompts by name/URI
@@ -350,7 +357,8 @@ The default handlers work by:
350357

351358
### Custom Tool Caller
352359

353-
Replace how tool execution requests are processed. Your custom `ToolCallerInterface` receives a `CallToolRequest` (with tool name and arguments) and must return a `CallToolResult`.
360+
Replace how tool execution requests are processed. Your custom `ToolCallerInterface` receives a `CallToolRequest` (with
361+
tool name and arguments) and must return a `CallToolResult`.
354362

355363
```php
356364
use Mcp\Capability\Tool\ToolCallerInterface;
@@ -377,7 +385,8 @@ $server = Server::builder()
377385

378386
### Custom Resource Reader
379387

380-
Replace how resource reading requests are processed. Your custom `ResourceReaderInterface` receives a `ReadResourceRequest` (with URI) and must return a `ReadResourceResult`.
388+
Replace how resource reading requests are processed. Your custom `ResourceReaderInterface` receives a `ReadResourceRequest`
389+
(with URI) and must return a `ReadResourceResult`.
381390

382391
```php
383392
use Mcp\Capability\Resource\ResourceReaderInterface;
@@ -402,7 +411,8 @@ $server = Server::builder()
402411

403412
### Custom Prompt Getter
404413

405-
Replace how prompt generation requests are processed. Your custom `PromptGetterInterface` receives a `GetPromptRequest` (with prompt name and arguments) and must return a `GetPromptResult`.
414+
Replace how prompt generation requests are processed. Your custom `PromptGetterInterface` receives a `GetPromptRequest`
415+
(with prompt name and arguments) and must return a `GetPromptResult`.
406416

407417
```php
408418
use Mcp\Capability\Prompt\PromptGetterInterface;
@@ -426,7 +436,10 @@ $server = Server::builder()
426436
->setPromptGetter(new CustomPromptGetter());
427437
```
428438

429-
> **Warning**: Custom capability handlers bypass the entire default registration system (discovered attributes, manual registration, container resolution, etc.). You become responsible for all aspect of execution, including error handling, logging, and result formatting. Only use this for very specific advanced use cases like custom authentication, complex routing, or integration with external systems.
439+
> **Warning**: Custom capability handlers bypass the entire default registration system (discovered attributes, manual
440+
> registration, container resolution, etc.). You become responsible for all aspect of execution, including error handling,
441+
> logging, and result formatting. Only use this for very specific advanced use cases like custom authentication, complex
442+
> routing, or integration with external systems.
430443
431444
## Complete Example
432445

docs/transports.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Transports
22

3-
Transports handle the communication layer between MCP servers and clients. The PHP MCP SDK provides two main transport implementations: STDIO for command-line integration and HTTP for web-based communication.
3+
Transports handle the communication layer between MCP servers and clients. The PHP MCP SDK provides two main transport
4+
implementations: STDIO for command-line integration and HTTP for web-based communication.
45

56
## Table of Contents
67

@@ -45,7 +46,8 @@ $transport = new StdioTransport(
4546
- **`logger`** (optional): `LoggerInterface` - PSR-3 logger for debugging. Defaults to `NullLogger`.
4647

4748
> [!IMPORTANT]
48-
> When using STDIO transport, **never** write to `STDOUT` in your handlers as it's reserved for JSON-RPC communication. Use `STDERR` for debugging instead.
49+
> When using STDIO transport, **never** write to `STDOUT` in your handlers as it's reserved for JSON-RPC communication.
50+
> Use `STDERR` for debugging instead.
4951
5052
### Example Server Script
5153

@@ -90,7 +92,8 @@ For MCP clients like Claude Desktop:
9092

9193
## HTTP Transport
9294

93-
The HTTP transport was designed to sit between any PHP project, regardless of the HTTP implementation or how they receive and process requests and send responses. It provides a flexible architecture that can integrate with any PSR-7 compatible application.
95+
The HTTP transport was designed to sit between any PHP project, regardless of the HTTP implementation or how they receive
96+
and process requests and send responses. It provides a flexible architecture that can integrate with any PSR-7 compatible application.
9497

9598
```php
9699
use Psr\Http\Message\ServerRequestInterface;
@@ -114,7 +117,8 @@ $transport = new StreamableHttpTransport(
114117

115118
### Architecture
116119

117-
The HTTP transport doesn't run its own web server. Instead, it processes PSR-7 requests and returns PSR-7 responses that your application can handle however it needs to:
120+
The HTTP transport doesn't run its own web server. Instead, it processes PSR-7 requests and returns PSR-7 responses that
121+
your application can handle however it needs to:
118122

119123
```
120124
Your Web App → PSR-7 Request → StreamableHttpTransport → PSR-7 Response → Your Web App
@@ -294,7 +298,8 @@ You should route **all methods** to your MCP endpoint, not just POST.
294298

295299
### Session Management
296300

297-
HTTP transport requires persistent sessions since PHP doesn't maintain state between requests. Unlike STDIO transport where in-memory sessions work fine, HTTP transport needs a persistent session store:
301+
HTTP transport requires persistent sessions since PHP doesn't maintain state between requests. Unlike STDIO transport
302+
where in-memory sessions work fine, HTTP transport needs a persistent session store:
298303

299304
```php
300305
use Mcp\Server\Session\FileSessionStore;

0 commit comments

Comments
 (0)