WARP.md•3.93 kB
# WARP.md
This file provides guidance to WARP (warp.dev) when working with code in this repository.
## Project Overview
Fusion MCP Server is a Model Context Protocol (MCP) server that provides enhanced AI interactions through fusion algorithms and data transformation capabilities. It implements the MCP specification to expose AI tools for data analysis and transformation.
## Core Architecture
The server follows a single-file architecture pattern with clear separation of concerns:
- **FusionMCPServer Class**: Main server implementation that handles MCP protocol communication
- **Tool Registration**: Uses MCP SDK's request handler pattern for tool discovery and execution
- **Transport Layer**: Communicates via stdio using StdioServerTransport
- **Tool Handlers**: Individual methods for each tool (`fusion_analyze`, `fusion_transform`)
### Key Components
- `src/index.js` - Main entry point containing the complete server implementation
- Tool handlers are implemented as async methods within the FusionMCPServer class
- JSON schema validation is handled through MCP SDK's built-in schemas
- All communication follows MCP protocol standards for request/response format
## Development Commands
### Basic Operations
```bash
# Install dependencies
npm install
# Start the server in production mode
npm start
# Start development server with auto-reload
npm run dev
# Run tests
npm test
# Run linting
npm run lint
# Format code
npm run format
```
### Development Workflow
The server uses Node.js's built-in `--watch` flag for development, eliminating the need for external tools like nodemon. The `dev` script automatically restarts the server when source files change.
## MCP Tool Implementation
The server exposes two main tools:
### fusion_analyze
- **Purpose**: Analyze data using statistical, ML, or hybrid methods
- **Input Schema**: `data` (required), `method` (optional: "statistical", "ml", "hybrid")
- **Implementation**: Located in `handleAnalyze()` method
### fusion_transform
- **Purpose**: Transform data between different formats using fusion techniques
- **Input Schema**: `input` (required), `target_format` (required)
- **Implementation**: Located in `handleTransform()` method
### Adding New Tools
To add new MCP tools:
1. Add tool definition to the `ListToolsRequestSchema` handler array
2. Add case statement to `CallToolRequestSchema` handler switch
3. Implement handler method following the pattern: `async handleToolName(args)`
4. Return response in MCP format with `content` array containing `type: "text"` objects
## Technical Requirements
- **Node.js**: >= 18.0.0 (specified in package.json engines)
- **Module System**: ES modules (`"type": "module"` in package.json)
- **MCP SDK**: Uses `@modelcontextprotocol/sdk` version ^0.4.0
- **Development Tools**: ESLint ^8.57.0, Prettier ^3.0.0
## Testing Strategy
The project uses Node.js's built-in test runner (`node --test`). Tests should be created following Node.js test conventions and placed appropriately within the project structure.
## Code Standards
- **ES Modules**: All imports/exports use ES module syntax
- **Async/Await**: Consistent use of async/await for asynchronous operations
- **Error Handling**: Proper error throwing for unknown tools and invalid requests
- **JSON Schema**: All tool inputs validated through MCP SDK schema validation
- **Code Formatting**: Prettier configuration for consistent code style
- **Linting**: ESLint for code quality and style enforcement
## MCP Protocol Compliance
The server implements core MCP protocol features:
- Tool listing via `ListToolsRequestSchema`
- Tool execution via `CallToolRequestSchema`
- Proper request/response format with content arrays
- Error handling for unknown tools
- Stdio transport for communication
When extending functionality, maintain compliance with MCP specification standards for request/response formats and tool schema definitions.