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
- Validation & Error Handling - Ensures correct data formats and secure execution.
68
+
69
+
This class acts as the server component in the MCP architecture, interfacing with AI clients to process requests. It follows a JSON-RPC 2.0 protocol, ensuring a standardized communication format.
70
+
71
+
### Properties
72
+
73
+
| Name | Visibility modifier | Description |
74
+
| --- | --- | --- |
75
+
|`$data`| private | Stores structured data (e.g., users, products). |
76
+
|`$tools`| private | Registered AI-callable tools (functions AI can invoke). |
77
+
|`$resources`| private | Registered data resources accessible to AI. |
78
+
79
+
### Methods
80
+
81
+
| Name | Description |
82
+
| --- | --- |
83
+
|`Server::__construct()`| Constructor. Initializes sample user and product data. These datasets are accessible via JSON-RPC requests. |
84
+
|`Server::register_tool()`| Registers AI-callable functions (`tools`). Each tool must include identifier (`name`) and function to execute (`callable`); `description` and `inputSchema` are optional. |
85
+
|`Server::register_resource()`| Registers structured data for AI access. |
86
+
|`Server::get_capabilities()`| Retrives server capabilities and returns the list of available tools and resources. Used by AI clients to understand what functions and data are accessible. |
|`Server::process_method_call()`| Determines whether the request is for fetching capabilities (`get_capabilities`), accessing data (`get_users`, `get_products`), or executing a tool (`calculate_total`, `greet`, etc.) |
89
+
|`Server::handle_data_request()`| Extracts requested resource and returns structured data. |
90
+
|`Server::execute_tool()`| Calls registered AI tools and validates input against schema. |
0 commit comments