Development Guide
December 15, 2024 · View on GitHub
Environment Setup
-
Prerequisites
- Node.js 18+
- npm/yarn
- TypeScript
- Gemini API key
-
Installation
git clone https://github.com/aliargun/mcp-server-gemini.git
cd mcp-server-gemini
npm install
- Configuration
# Set your Gemini API key
export GEMINI_API_KEY=your_api_key_here
Development Workflow
- Start Development Server
npm run dev
- Build for Production
npm run build
- Run Tests
npm test
Project Structure
src/
├── index.ts # Main entry point
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
test/ # Test files
docs/ # Documentation
Adding Features
- Create new message handler:
if (request.method === 'newMethod') {
// Handle new method
}
- Add capability:
capabilities: {
experimental: {
newFeature: true
}
}
Testing
- Unit Tests
describe('Message Handler', () => {
it('handles new method', () => {
// Test implementation
});
});
- Integration Tests
describe('WebSocket Server', () => {
it('connects and processes messages', () => {
// Test implementation
});
});
Debugging
- Enable Debug Logging
const DEBUG = true;
if (DEBUG) console.log('Debug:', message);
- Use WebSocket Client
wscat -c ws://localhost:3005
Best Practices
-
Code Style
- Use TypeScript
- Follow existing patterns
- Document public APIs
-
Error Handling
- Use type-safe errors
- Provide meaningful messages
- Log appropriately
-
Testing
- Write unit tests
- Add integration tests
- Test error cases