Add MCP Schema Endpoint for API Discovery

- Implemented `/mcp` endpoint to expose server capabilities
- Created `src/mcp/schema.ts` with comprehensive tool and resource definitions
- Updated README.md with MCP Schema documentation
- Modified security middleware to allow unauthenticated access to schema endpoint
- Included detailed tool descriptions for list_devices, control, and event subscription
This commit is contained in:
jango-blockchained
2025-02-01 06:42:16 +01:00
parent aa911c179d
commit 155a6ea5ba
4 changed files with 171 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ See [SSE_API.md](docs/SSE_API.md) for complete documentation of the SSE system.
- [Configuration](#configuration)
- [Development](#development)
- [API Reference](#api-reference)
- [MCP Schema](#mcp-schema-endpoint)
- [Device Control](#device-control)
- [Add-on Management](#add-on-management)
- [Package Management](#package-management)
@@ -248,6 +249,49 @@ TEST_HASS_TOKEN=test_token # Test token
## API Reference
### MCP Schema Endpoint
The server exposes an MCP (Model Context Protocol) schema endpoint that describes all available tools and their parameters:
```http
GET /mcp
```
This endpoint returns a JSON schema describing all available tools, their parameters, and documentation resources. The schema follows the MCP specification and can be used by LLM clients to understand the server's capabilities.
Example response:
```json
{
"tools": [
{
"name": "list_devices",
"description": "List all devices connected to Home Assistant",
"parameters": {
"type": "object",
"properties": {
"domain": {
"type": "string",
"enum": ["light", "climate", "alarm_control_panel", ...]
},
"area": { "type": "string" },
"floor": { "type": "string" }
}
}
},
// ... other tools
],
"prompts": [],
"resources": [
{
"name": "Home Assistant API",
"url": "https://developers.home-assistant.io/docs/api/rest/"
}
]
}
```
Note: The `/mcp` endpoint is publicly accessible and does not require authentication, as it only provides schema information.
### Device Control
#### Common Entity Controls