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

@@ -6,6 +6,7 @@ import { sseManager } from './sse/index.js';
import { ILogger } from "@digital-alchemy/core";
import express from 'express';
import { rateLimiter, securityHeaders, validateRequest, sanitizeInput, errorHandler } from './security/index.js';
import { MCP_SCHEMA } from './mcp/schema.js';
// Load environment variables based on NODE_ENV
const envFile = process.env.NODE_ENV === 'production'
@@ -42,6 +43,12 @@ app.use(sanitizeInput);
// Initialize LiteMCP
const server = new LiteMCP('home-assistant', '0.1.0');
// MCP schema endpoint - no auth required as it's just the schema
app.get('/mcp', (_req, res) => {
// Return the MCP schema without requiring authentication
res.json(MCP_SCHEMA);
});
// Health check endpoint
app.get('/health', (req, res) => {
res.json({