**feat: enhance environment detection, adaptive storage, and introduce MCP service details**

### Changes:
- **README Enhancements**:
  - Added detection capabilities for browser, Node.js, and serverless environments with optimized configuration.
  - Expanded details on adaptive storage strategies based on the detected environment.
  - Included new information on the Model Control Protocol (MCP), including components like `BrainyMCPAdapter` and `MCPAugmentationToolset`.

- **Terminology Updates**:
  - Replaced "restore sparse data" terminology with "import sparse data" in code samples and CLI commands for clarity (e.g., `importSparseData` method and `brainy import-sparse` command).
  - Updated related examples for consistency with new term usage.

- **Cross-Environment Compatibility**:
  - Highlighted dynamic imports and storage migration for seamless operation in different environments.
  - Described augmented browser support and streamlined development practices.

- **MCP Documentation**:
  - Detailed REST and WebSocket APIs for interacting with Brainy through MCP.
  - Outlined configuration options like rate limiting and authentication for MCP services.

- **cloud-wrapper/README.md**:
  - Added configuration details for MCP services, including specific usage of ports, API keys, and CORS settings.
  - Expanded API scopes by introducing MCP-related endpoints for real-time and batch interactions.

### Purpose:
Enhanced documentation to reflect recent updates to environment detection, storage optimization, and MCP services. The changes improve clarity, usability, and developer understanding across environments and interaction protocols.
This commit is contained in:
David Snelling 2025-06-20 10:56:59 -07:00
parent b9f8466d5d
commit fe8eb38e1f
2 changed files with 102 additions and 7 deletions

View file

@ -9,6 +9,8 @@ A standalone web service wrapper for the [Brainy](https://github.com/soulcraft/b
## Features
- RESTful API for all Brainy operations
- WebSocket API for real-time updates and subscriptions
- Model Control Protocol (MCP) service for external model access
- Support for multiple storage backends (Memory, FileSystem, S3)
- Configurable via environment variables
- Deployment scripts for AWS, Google Cloud, and Cloudflare
@ -66,6 +68,18 @@ When using `STORAGE_TYPE=s3`, the following environment variables are required:
- `S3_REGION`: The S3 region (default: `us-east-1`)
- `S3_ENDPOINT` (optional): Custom endpoint for S3-compatible services
### MCP Service Configuration
The Model Control Protocol (MCP) service can be configured using the following environment variables:
- `MCP_WS_PORT`: Port for the MCP WebSocket server (if not set, WebSocket server is disabled)
- `MCP_REST_PORT`: Port for the MCP REST server (if not set, REST server is disabled)
- `MCP_ENABLE_AUTH`: Enable authentication for MCP requests (`true` or `false`)
- `MCP_API_KEYS`: Comma-separated list of API keys for authentication
- `MCP_RATE_LIMIT_REQUESTS`: Maximum number of requests per time window
- `MCP_RATE_LIMIT_WINDOW_MS`: Time window for rate limiting in milliseconds (default: `60000`)
- `MCP_ENABLE_CORS`: Enable CORS for MCP REST server (`true` or `false`)
## Local Development
1. Build the project:
@ -82,7 +96,7 @@ When using `STORAGE_TYPE=s3`, the following environment variables are required:
## API Endpoints
Brainy Cloud Wrapper provides both REST API and WebSocket API for interacting with the database.
Brainy Cloud Wrapper provides REST API, WebSocket API, and Model Control Protocol (MCP) API for interacting with the database.
### REST API
@ -222,6 +236,37 @@ When subscribed, you'll receive messages when relevant events occur:
}
```
### MCP API
The Model Control Protocol (MCP) API provides a standardized interface for external models to access Brainy data and use the augmentation pipeline as tools. The MCP API is available through both WebSocket and REST endpoints.
#### MCP REST API Endpoints
- `POST /mcp/data`: Access Brainy data (search, get, add, etc.)
- `POST /mcp/tools`: Execute augmentation pipeline tools
- `POST /mcp/system`: Get system information
- `POST /mcp/auth`: Authenticate with the MCP service
- `GET /mcp/tools`: Get available tools
#### MCP WebSocket
Connect to the MCP WebSocket server at `ws://your-server:MCP_WS_PORT` and send JSON messages in the MCP format:
```json
{
"type": "DATA_ACCESS",
"requestId": "unique-request-id",
"version": "1.0",
"operation": "search",
"parameters": {
"query": "Your search query",
"k": 5
}
}
```
For detailed documentation on the MCP API, see the [MCP documentation](../src/mcp/README.md).
## Cloud Deployment
### AWS Lambda and API Gateway