This repository has been archived on 2026-09-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
open-brainy/src/mcp
David Snelling 6c62bc4e9d feat: implement comprehensive type safety system with BrainyTypes API
Major enhancements for type safety and developer experience:

- Add BrainyTypes static API for type management and AI-powered suggestions
- Implement strict type validation for all 31 NounType categories
- Remove dangerous generic add() method that bypassed type safety
- Add intelligent type inference with confidence scoring
- Provide helpful error messages with typo suggestions using Levenshtein distance
- Update all internal code, examples, and documentation to use typed methods
- Enhance CLI with new type management commands (types, suggest, validate)

Breaking changes:
- Remove deprecated add() method - use addNoun() with explicit type parameter
- All addNoun() calls now require explicit type as second parameter

This release significantly improves type safety across the entire system while
maintaining backward compatibility for properly typed method calls.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 09:37:36 -07:00
..
brainyMCPAdapter.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
brainyMCPBroadcast.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
brainyMCPClient.ts feat: implement comprehensive type safety system with BrainyTypes API 2025-09-01 09:37:36 -07:00
brainyMCPService.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
index.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
mcpAugmentationToolset.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
README.md 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00

Model Control Protocol (MCP) for Brainy

This document provides information about the Model Control Protocol (MCP) implementation in Brainy, which allows external models to access Brainy data and use the augmentation pipeline as tools.

Components

The MCP implementation consists of three main components:

  1. BrainyMCPAdapter: Provides access to Brainy data through MCP
  2. MCPAugmentationToolset: Exposes the augmentation pipeline as tools
  3. BrainyMCPService: Integrates the adapter and toolset, providing WebSocket and REST server implementations for external model access

Environment Compatibility

BrainyMCPAdapter

The BrainyMCPAdapter has no environment-specific dependencies and can run in any environment where Brainy itself runs, including:

  • Browser environments
  • Node.js environments
  • Server environments

MCPAugmentationToolset

The MCPAugmentationToolset also has no environment-specific dependencies and can run in any environment where Brainy itself runs, including:

  • Browser environments
  • Node.js environments
  • Server environments

BrainyMCPService

The BrainyMCPService has been refactored to separate the core functionality from the Node.js-specific server functionality:

  1. Core Functionality: The core request handling functionality (handleMCPRequest) can run in any environment where Brainy itself runs. This is what remains in the main Brainy package.

  2. Server Functionality: The WebSocket and REST server functionality is not included in the main Brainy package to keep the browser bundle lightweight and avoid Node.js-specific dependencies. In browser or other environments, you can use the core functionality through the handleMCPRequest method.

Usage

In Any Environment (Browser, Node.js, Server)

import { BrainyData, BrainyMCPAdapter, MCPAugmentationToolset } from '@soulcraft/brainy'

// Create a BrainyData instance
const brainyData = new BrainyData()
await brainyData.init()

// Create an MCP adapter
const adapter = new BrainyMCPAdapter(brainyData)

// Create a toolset
const toolset = new MCPAugmentationToolset()

// Use the adapter to access Brainy data
const response = await adapter.handleRequest({
  type: 'data_access',
  operation: 'search',
  requestId: adapter.generateRequestId(),
  version: '1.0.0',
  parameters: {
    query: 'example query',
    k: 5
  }
})

// Use the toolset to execute augmentation pipeline tools
const toolResponse = await toolset.handleRequest({
  type: 'tool_execution',
  toolName: 'brainy_memory_storeData',
  requestId: toolset.generateRequestId(),
  version: '1.0.0',
  parameters: {
    args: ['key1', { some: 'data' }]
  }
})

In Browser Environment (Core Functionality Only)

import { BrainyData, BrainyMCPService } from '@soulcraft/brainy'

// Create a BrainyData instance
const brainyData = new BrainyData()
await brainyData.init()

// Create an MCP service (server functionality will be disabled in browser)
const mcpService = new BrainyMCPService(brainyData)

// Use the core functionality
const response = await mcpService.handleMCPRequest({
  type: 'data_access',
  operation: 'search',
  requestId: mcpService.generateRequestId(),
  version: '1.0.0',
  parameters: {
    query: 'example query',
    k: 5
  }
})