Skip to content

Commit a6953e1

Browse files
committed
Add MCP Inspector test
1 parent 6107946 commit a6953e1

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

code_samples/mcp/src/Mcp/ExampleTools.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
use Ibexa\Contracts\Mcp\Attribute\McpTool;
66
use Ibexa\Contracts\Mcp\McpCapabilityInterface;
7+
use Mcp\Schema\Icon;
78
use Mcp\Schema\ToolAnnotations;
89

910
final readonly class ExampleTools implements McpCapabilityInterface
1011
{
1112
#[McpTool(
1213
name: 'greet',
1314
description: 'Greet a user by name',
15+
icons: [new Icon(
16+
src: 'https://openmoji.org/data/color/svg/1F44B.svg',
17+
)],
1418
annotations: new ToolAnnotations(
1519
readOnlyHint: true,
1620
destructiveHint: false,

docs/ai/mcp/mcp_config.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ It has several arguments to describe the tool usage and output:
160160

161161
## Example
162162

163+
### Configure MCP server
164+
163165
This example introduce an `example` MCP server with a single `greet` tool.
164166
It's enabled on all SiteAccesses.
165167
It's accessible with the path `/mcp/example` (for example, on `http://localhost/mcp/example` and `http://localhost/admin/mcp/example`).
@@ -171,19 +173,25 @@ In a new `config/packages/mcp.yaml` file, the configuration of the MCP server:
171173
[[= include_file('code_samples/mcp/config/packages/mcp.yaml') =]]
172174
```
173175

176+
### Create tool class
177+
174178
Then, a `McpCapabilityInterface` containing a `greetByName` function with a `McpTool` attribute,
175179
the `App\Mcp\ExampleTools` class listed in the server's `tools`:
176180

177181
``` php
178182
[[= include_file('code_samples/mcp/src/Mcp/ExampleTools.php') =]]
179183
```
180184

185+
### Create MCP server list command
186+
181187
To check the server configuration, a short command using the MCP server configuration registry (injected through `McpServerConfigurationRegistryInterface` and autowiring):
182188

183189
``` php
184190
[[= include_file('code_samples/mcp/src/Command/McpServerListCommand.php') =]]
185191
```
186192

193+
### cURL test
194+
187195
To test the `example` MCP server, a sequence of `curl` commands is used to simulate an AI to MCP server communication.
188196

189197
- Ask for a [JWT token through REST](/api/rest_api/rest_api_reference/rest_api_reference.html#tag/User-Token/operation/api_usertokenjwt_post)
@@ -261,4 +269,39 @@ The `greet` [tool usage](https://modelcontextprotocol.io/specification/draft/ser
261269
}
262270
```
263271

264-
TODO: Connect an AI client to the MCP server. [Copilot CLI MCP server addition](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers) is strangely asking for some OAuth ID even with a proper JWT/Bearer header.
272+
### MCP Inspector test
273+
274+
To test your server, you can use the [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector).
275+
It's even possible to use it as a DDEV add-on with [`craftpulse/ddev-mcp-inspector`](https://github.com/craftpulse/ddev-mcp-inspector).
276+
You still need to ask for a JWT token through REST and use it in the MCP Inspector configuration to connect to your server.
277+
278+
To use the MCP Inspector for this example, the settings are:
279+
280+
- Transport Type: Streamable HTTP
281+
- URL: addition of the actual domain and the server `path`, for example `http://localhost/mcp/example`
282+
- Connection Type: Via Proxy
283+
- Authentication:
284+
- Custom Headers:
285+
- ✓ Authorization
286+
- Bearer <JWT token obtained through REST>
287+
- OAuth 2.0 Flow: leave unedited
288+
289+
![Screenshot of the left pannel of the MCP Inspector with the connection settings for the example MCP server](img/mcp-inspector-config.png "MCP Inspector connection settings")
290+
291+
In the right panel, in the **Tools** tab, click **List Tools** button in the left column.
292+
The `greet` tool appears preceded by its icon.
293+
It can be selected and tested in the right column.
294+
295+
![Screenshot of the right pannel of the MCP Inspector with the list of tools obtained from the example MCP server, and the test of the `greet` tool](img/mcp-inspector-greet.png "MCP Inspector `greet` tool test")
296+
297+
### TODO: Copilot CLI test
298+
299+
TODO: Test the server with [Copilot CLI](https://docs.github.com/en/copilot/concepts/agents/copilot-cli/about-copilot-cli).
300+
301+
TODO: Create an .mcp.json file at the project root so the MCP server will only exist for a session of Copilot CLI opened from project root (for example, in a terminal tab of your IDE).
302+
303+
TODO: [Copilot CLI MCP server addition](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers) is strangely asking for some OAuth ID even with a proper JWT/Bearer header.
304+
305+
### TODO: Other clients?
306+
307+
TODO: Connect AI clients to the MCP server.

0 commit comments

Comments
 (0)