Skip to main content
Glama
ozipi
by ozipi
README.md4.94 kB
# Constants Directory This directory contains all static definitions, schemas, and prompts used throughout the Brainloop MCP server. It serves as the single source of truth for tool definitions and sampling configurations. ## Overview Constants define the "what" of the MCP server: - What tools are available - What parameters they accept - What prompts guide AI responses - What schemas validate data ## Directory Structure ### Core Files #### `tools.ts` Master list of all available tools: - Exports array of tool definitions - Each tool references its schema in `/tool` directory - Used by `tool-handlers.ts` to list available tools #### `message-handler.ts` Message formatting utilities: - Structures Brainloop content for display - Formats course, lesson, and progress data - Provides consistent output format ### Server Configuration (`/server`) Server-level configuration and constants: - **`server-config.ts`** - MCP server metadata and capabilities - Protocol version and feature declarations - Session and rate limiting configuration ### Tool Definitions (`/tool`) Each file defines a tool's schema and metadata: #### Brainloop Management Tools - **`create-brainloop.ts`** - Create new learning courses - **`view-brainloops.ts`** - List user's courses - **`get-brainloop.ts`** - Get course details - **`expand-brainloop.ts`** - Add content to courses #### Lesson and Unit Tools - **`get-unit-lessons.ts`** - Get lessons in a unit - **`get-lesson.ts`** - Get lesson details - **`update-lesson.ts`** - Update lesson content - **`update-unit.ts`** - Update unit information #### Interaction Tools - **`create-interaction.ts`** - Create lesson interactions - **`create-prompt.ts`** - Create questions/exercises - **`get-lesson-prompts.ts`** - Get all prompts for a lesson ### Sampling Definitions (`/sampling`) Prompts and schemas for AI-assisted operations: - **`suggest-action.ts`** - Action suggestion prompts - **`index.ts`** - Exports all sampling messages ## Schema Structure Each tool definition follows this pattern: ```typescript export const TOOL_NAME = { name: 'tool_name', description: 'What this tool does', inputSchema: { type: 'object', properties: { param1: { type: 'string', description: 'Parameter description' }, param2: { type: 'number', description: 'Another parameter', minimum: 0 } }, required: ['param1'] } }; ``` ## Sampling Message Structure Sampling definitions include: ```typescript export const SAMPLING_NAME = { systemPrompt: 'Instructions for the AI', schemaName: 'response_schema_name', schemaDescription: 'What the schema represents', schema: { // JSON Schema for validating AI responses } }; ``` ## Key Patterns ### Consistent Naming - Tool constants: `TOOL_NAME` (uppercase) - Sampling constants: `SAMPLING_NAME` (uppercase) - Schema properties: `camelCase` ### Schema Validation All schemas use JSON Schema Draft 7: - Required fields clearly marked - Descriptions for all properties - Type constraints and validations - Examples where helpful ### Prompt Engineering Sampling prompts follow best practices: - Clear instructions - Expected format specification - Examples when needed - Constraints and guidelines ## Adding New Tools To add a new tool: 1. **Create Schema File** ```typescript // /tool/my-new-tool.ts export const MY_NEW_TOOL = { name: 'my_new_tool', description: 'What it does', inputSchema: { ... } }; ``` 2. **Add to Tools List** ```typescript // tools.ts import { MY_NEW_TOOL } from './tool/my-new-tool'; export const TOOLS = [ // ... existing tools MY_NEW_TOOL ]; ``` 3. **Create Handler** Implement the handler in `/handlers/tools/` ## Adding Sampling Operations For AI-assisted operations: 1. **Create Sampling Definition** ```typescript // /sampling/my-operation.ts export const MY_OPERATION_SAMPLING = { systemPrompt: 'Generate a ...', schema: { ... } }; ``` 2. **Export from Index** ```typescript // /sampling/index.ts export * from './my-operation'; ``` 3. **Implement Callback** Create callback handler in `/handlers/callbacks/` ## Best Practices ### Schema Design - Make required fields minimal - Provide sensible defaults - Use clear, descriptive names - Add helpful descriptions ### Prompt Design - Be specific about output format - Include examples for complex tasks - Set clear boundaries - Guide tone and style ### Validation - Use strict type checking - Validate string formats - Set reasonable limits - Provide clear error messages ## Maintenance When updating schemas: 1. Consider backward compatibility 2. Update handler validation 3. Test with various inputs 4. Update documentation This directory is the foundation of the MCP server's interface - changes here affect how AI clients interact with Brainloop.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ozipi/brainloop-mcp-server-v2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server