Skip to content

Commit 965d22a

Browse files
authored
Enhance MCP tool interface and improve documentation for v1.3.0 (#31)
* docs(stubs): enhance documentation and examples for MCP stubs * Refactor ToolInterface communication patterns for v1.3.0 - Remove ProcessMessageType::PROTOCOL enum (consolidated into HTTP) - Replace confusing messageType() with intuitive isStreaming() boolean - Enhance migration command to support v1.0.x, v1.1.x, v1.2.x → v1.3.0 - Update example tools to use new isStreaming() pattern - Improve documentation with comprehensive v1.3.0 guidance - Add deprecated features section for v2.0.0 planning * Remove unnecessary documentation * fix: make isStreaming() method optional for backward compatibility - Remove isStreaming() requirement from ToolInterface to prevent fatal errors - Existing tools without isStreaming() method now work without modification - ToolsCallHandler already has fallback logic using method_exists() - Update stub documentation to clarify isStreaming() is optional - Maintain full backward compatibility for v1.1.x and v1.2.x tools Fixes upgrade issues where users got fatal error: "Class contains 1 abstract method and must implement isStreaming()" * Fix styling --------- Co-authored-by: kargnas <[email protected]>
1 parent 295468e commit 965d22a

19 files changed

+726
-154
lines changed

README.md

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,22 @@
2626
<a href="README.es.md">Español</a>
2727
</p>
2828

29-
## ⚠️ Breaking Changes in v1.1.0
29+
## ⚠️ Version Information & Breaking Changes
30+
31+
### v1.3.0 Changes (Current)
32+
33+
Version 1.3.0 introduces improvements to the `ToolInterface` for better communication control:
34+
35+
**New Features:**
36+
- Added `isStreaming(): bool` method for clearer communication pattern selection
37+
- Improved migration tools supporting upgrades from v1.1.x, v1.2.x to v1.3.0
38+
- Enhanced stub files with comprehensive v1.3.0 documentation
39+
40+
**Deprecated Features:**
41+
- `messageType(): ProcessMessageType` method is now deprecated (will be removed in v2.0.0)
42+
- Use `isStreaming(): bool` instead for better clarity and simplicity
43+
44+
### Breaking Changes in v1.1.0
3045

3146
Version 1.1.0 introduced a significant and breaking change to the `ToolInterface`. If you are upgrading from v1.0.x, you **must** update your tool implementations to conform to the new interface.
3247

@@ -154,17 +169,23 @@ use OPGG\LaravelMcpServer\Enums\ProcessMessageType; // Import the enum
154169

155170
class MyNewTool implements ToolInterface
156171
{
157-
// Add the new messageType() method
172+
/**
173+
* @deprecated since v1.3.0, use isStreaming() instead. Will be removed in v2.0.0
174+
*/
158175
public function messageType(): ProcessMessageType
159176
{
160-
// Return the appropriate message type, e.g., for a standard tool
161-
return ProcessMessageType::SSE;
177+
return ProcessMessageType::HTTP;
178+
}
179+
180+
public function isStreaming(): bool
181+
{
182+
return false; // Most tools should return false
162183
}
163184

164-
public function name(): string { return 'MyNewTool'; } // Renamed
165-
public function description(): string { return 'This is my new tool.'; } // Renamed
166-
public function inputSchema(): array { return []; } // Renamed
167-
public function annotations(): array { return []; } // Renamed
185+
public function name(): string { return 'MyNewTool'; }
186+
public function description(): string { return 'This is my new tool.'; }
187+
public function inputSchema(): array { return []; }
188+
public function annotations(): array { return []; }
168189
public function execute(array $arguments): mixed { /* ... */ }
169190
}
170191
```
@@ -309,9 +330,14 @@ use OPGG\LaravelMcpServer\Enums\ProcessMessageType;
309330

310331
interface ToolInterface
311332
{
312-
// Determines how the tool's messages are processed, often related to the transport.
333+
/**
334+
* @deprecated since v1.3.0, use isStreaming() instead. Will be removed in v2.0.0
335+
*/
313336
public function messageType(): ProcessMessageType;
314337

338+
// NEW in v1.3.0: Determines if this tool requires streaming (SSE) instead of standard HTTP.
339+
public function isStreaming(): bool;
340+
315341
// The unique, callable name of your tool (e.g., 'get-user-details').
316342
public function name(): string;
317343

@@ -331,7 +357,9 @@ interface ToolInterface
331357

332358
Let's dive deeper into some of these methods:
333359

334-
**`messageType(): ProcessMessageType`**
360+
**`messageType(): ProcessMessageType` (Deprecated in v1.3.0)**
361+
362+
⚠️ **This method is deprecated since v1.3.0.** Use `isStreaming(): bool` instead for better clarity.
335363

336364
This method specifies the type of message processing for your tool. It returns a `ProcessMessageType` enum value. The available types are:
337365

@@ -340,6 +368,18 @@ This method specifies the type of message processing for your tool. It returns a
340368

341369
For most tools, especially those designed for the primary `streamable_http` provider, you'll return `ProcessMessageType::HTTP`.
342370

371+
**`isStreaming(): bool` (New in v1.3.0)**
372+
373+
This is the new, more intuitive method for controlling communication patterns:
374+
375+
- `return false`: Use standard HTTP request/response (recommended for most tools)
376+
- `return true`: Use Server-Sent Events for real-time streaming
377+
378+
Most tools should return `false` unless you specifically need real-time streaming capabilities like:
379+
- Real-time progress updates for long-running operations
380+
- Live data feeds or monitoring tools
381+
- Interactive tools requiring bidirectional communication
382+
343383
**`name(): string`**
344384

345385
This is the identifier for your tool. It should be unique. Clients will use this name to request your tool. For example: `get-weather`, `calculate-sum`.
@@ -752,6 +792,44 @@ You can also translate specific languages:
752792
python scripts/translate_readme.py es ko
753793
```
754794
795+
## Deprecated Features for v2.0.0
796+
797+
The following features are deprecated and will be removed in v2.0.0. Please update your code accordingly:
798+
799+
### ToolInterface Changes
800+
801+
**Deprecated since v1.3.0:**
802+
- `messageType(): ProcessMessageType` method
803+
- **Replacement:** Use `isStreaming(): bool` instead
804+
- **Migration Guide:** Return `false` for HTTP tools, `true` for streaming tools
805+
- **Automatic Migration:** Run `php artisan mcp:migrate-tools` to update your tools
806+
807+
**Example Migration:**
808+
809+
```php
810+
// Old approach (deprecated)
811+
public function messageType(): ProcessMessageType
812+
{
813+
return ProcessMessageType::HTTP;
814+
}
815+
816+
// New approach (v1.3.0+)
817+
public function isStreaming(): bool
818+
{
819+
return false; // Use false for HTTP, true for streaming
820+
}
821+
```
822+
823+
### Removed Features
824+
825+
**Removed in v1.3.0:**
826+
- `ProcessMessageType::PROTOCOL` enum case (consolidated into `ProcessMessageType::HTTP`)
827+
828+
**Planning for v2.0.0:**
829+
- Complete removal of `messageType()` method from `ToolInterface`
830+
- All tools will be required to implement `isStreaming()` method only
831+
- Simplified tool configuration and reduced complexity
832+
755833
## License
756834
757835
This project is distributed under the MIT license.

0 commit comments

Comments
 (0)