Skip to content

Commit 93e2ac7

Browse files
committed
Add test command and server disable option for MCP tools
1 parent 03ea85a commit 93e2ac7

File tree

5 files changed

+461
-3
lines changed

5 files changed

+461
-3
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ class MyCustomTool implements ToolInterface
9292
}
9393
```
9494

95+
### Testing MCP Tools
96+
97+
The package includes a special command for testing your MCP tools without needing a real MCP client:
98+
99+
```bash
100+
# Test a specific tool interactively
101+
php artisan mcp:test-tool MyCustomTool
102+
103+
# List all available tools
104+
php artisan mcp:test-tool --list
105+
106+
# Test with specific JSON input
107+
php artisan mcp:test-tool MyCustomTool --input='{"param":"value"}'
108+
```
109+
110+
This helps you rapidly develop and debug tools by:
111+
112+
- Showing the tool's input schema and validating inputs
113+
- Executing the tool with your provided input
114+
- Displaying formatted results or detailed error information
115+
- Supporting complex input types including objects and arrays
116+
95117
## Advanced Features
96118

97119
### Pub/Sub Architecture with SSE Adapters
@@ -126,6 +148,25 @@ The default Redis adapter can be configured as follows:
126148
],
127149
```
128150

151+
## Environment Variables
152+
153+
The package supports the following environment variables to allow configuration without modifying the config files:
154+
155+
| Variable | Description | Default |
156+
|----------|-------------|--------|
157+
| `MCP_SERVER_ENABLED` | Enable or disable the MCP server | `true` |
158+
| `MCP_REDIS_CONNECTION` | Redis connection name from database.php | `default` |
159+
160+
### Example .env Configuration
161+
162+
```
163+
# Disable MCP server in specific environments
164+
MCP_SERVER_ENABLED=false
165+
166+
# Use a specific Redis connection for MCP
167+
MCP_REDIS_CONNECTION=mcp
168+
```
169+
129170
## License
130171

131172
This project is distributed under the MIT license.

config/mcp-server.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<?php
22

33
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| MCP Server Activation
7+
|--------------------------------------------------------------------------
8+
|
9+
| Enable or disable the MCP server functionality. When disabled, no routes
10+
| will be registered and the server will not respond to any requests.
11+
|
12+
*/
13+
'enabled' => env('MCP_SERVER_ENABLED', true),
14+
415
/*
516
|--------------------------------------------------------------------------
617
| Server Information
@@ -46,9 +57,7 @@
4657
| Server-Sent Events Provider
4758
|--------------------------------------------------------------------------
4859
|
49-
| When set to true, the MCPServer will be registered as a singleton in the
50-
| application container. This allows for easy access to the server instance
51-
| throughout the application when using the SSE transport.
60+
| The type of server provider to use. Currently only 'sse' is supported.
5261
|
5362
*/
5463
'server_provider' => 'sse',

src/Console/Commands/MakeMcpToolCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ public function handle()
7979
$this->comment(" {$fullClassName}::class,");
8080
$this->comment(" ],");
8181
}
82+
83+
// Display testing instructions
84+
$this->newLine();
85+
$this->info("You can now test your tool with the following command:");
86+
$this->comment(" php artisan mcp:test-tool " . $className);
87+
$this->info("Or view all available tools:");
88+
$this->comment(" php artisan mcp:test-tool --list");
8289

8390
return 0;
8491
}

0 commit comments

Comments
 (0)