You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-18Lines changed: 0 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,6 @@ The server uses a decoupled architecture:
143
143
***`Protocol`:** Internal bridge listening to transport events, interacting with `Processor` and `ClientStateManager`.
144
144
***`discover()` Method:** An **explicit** method on the `Server` instance to trigger attribute discovery. Takes path configurations as arguments. By default, it clears previously discovered/cached elements before scanning and saves the new results to cache (if enabled).
145
145
***`listen()` Method:** Starts the server using a specific transport. Binds the `Protocol`, starts the transport listener, and **runs the event loop (blocking)**. Performs a pre-check and warns if no elements are registered and discovery hasn't run.
146
-
***`getProtocol()` Method:** For framework integration (see below).
***Messages:**`POST /{mcpPathPrefix}/message?clientId={clientId}` (e.g., `POST /mcp/message?clientId=sse_abc123`) - Client sends requests here. The `clientId` query parameter is essential for the server to route the message correctly to the state associated with the SSE connection. The server sends the POST path (including the generated `clientId`) via the initial `endpoint` SSE event to the client, so you will never have to manually handle this.
284
283
285
-
### Custom / Framework Integration
286
-
287
-
Integrate into frameworks without the blocking `listen()` call:
288
-
289
-
1.**Build Server:**`$server = Server::make()->...->build();`, likely as a service container singleton.
290
-
2.**(Optional) Discover:**`$server->discover(...);` (Perhaps in a cache warmup command).
291
-
3.**Get Protocol:** Obtain the protocol from the server: `$protocol = $server->getProtocol();`
292
-
4.**Bridge Transport Events:** In your framework's request handling (HTTP controller, WebSocket):
293
-
* When a new connection is established: `$protocol->handleClientConnected($clientId);`
294
-
* When a raw JSON-RPC message frame is received, call: `$protocol->handleRawMessage($rawJsonFrame, $clientId);`
295
-
* When a connection closes, call: `$protocol->handleClientDisconnected($clientId, $reason);`
296
-
* Handle transport-level errors by potentially calling: `$protocol->handleTransportError($exception, $clientId);`
297
-
5.**Sending Responses:** You'll need framework-specific logic to send responses/notifications back to the correct client connection identified by `$clientId`.
298
-
299
-
This approach allows the framework to manage the event loop, sockets, and request/response objects, while leveraging the `php-mcp/server` core for MCP processing logic.
300
-
301
284
## Connecting MCP Clients
302
285
303
286
Instruct clients how to connect to your server:
@@ -565,7 +548,6 @@ See the [`examples/`](./examples/) directory:
565
548
***`05-stdio-env-variables/`**: `stdio` server with a tool that uses environment variables passed by the MCP client.
566
549
***`06-custom-dependencies-stdio/`**: `stdio` server showing DI container usage for injecting services into MCP handlers (Task Manager example).
567
550
***`07-complex-tool-schema-http/`**: `http+sse` server with a tool demonstrating complex input schemas (optionals, defaults, enums).
0 commit comments