Runs the MCP server and tests with Bun runtime, with specific requirements for Bun version 1.0.0 or higher
Provides Git commit message generation with conventional commits support through prompt templates
Built with TypeScript for type safety, requiring TypeScript 5.0.0 or higher
Uses Zod for schema validation in tools, resources, and prompts, enabling type-safe parameter validation
Elysia MCP Plugin
⚠️ Under Development
A comprehensive ElysiaJS plugin for implementing Model Context Protocol (MCP) servers with HTTP transport support.
Features
HTTP Transport: Full HTTP-based MCP transport with Streamable HTTP
Session Management: Stateful session handling via headers
Type-Safe: Built with TypeScript and Zod validation
Easy Integration: Simple plugin architecture for Elysia apps
Comprehensive Support: Tools, Resources, Prompts, and Logging
Custom Logger Support: Use any logger (pino, winston, bunyan, etc.)
Error Handling: Proper JSON-RPC 2.0 error responses
Testing: Full unit test coverage with Bun test runner
Related MCP server: MCP Framework
Installation
Starter Template
To quickly get started with a pre-configured Elysia MCP project, you can use our starter template:
The elysia-mcp-starter template includes:
Pre-configured Elysia setup with MCP plugin
TypeScript configuration
Development scripts
Basic project structure
Example MCP server implementation
Quick Start
Usage
Running the Examples
Basic Example:
Multiple Servers Example:
This example demonstrates how to create multiple MCP plugins in a single Elysia application:
Math Operations Plugin (
/math) - Basic arithmetic tools:add- Add two numbersmultiply- Multiply two numberspower- Calculate base to the power of exponent
Text Utilities Plugin (
/text) - Text processing tools:uppercase- Convert text to uppercaseword_count- Count words in textreverse- Reverse text charactersreplace- Replace text with global matching
Testing with MCP Inspector
Install MCP Inspector:
npx @modelcontextprotocol/inspectorConnect to your server:
Basic Example:
http://localhost:3000/mcpMultiple Servers Example:
Math Plugin:
http://localhost:3000/mathText Plugin:
http://localhost:3000/text
Configuration Options
serverInfo: Server informationcapabilities: MCP capabilities to advertiselogger: Custom logger instance (pino, winston, etc.) - see Custom Logger sectionsetupServer: Callback to register tools, resources, and promptsbasePath: Base path for MCP endpoints (default: '/mcp')enableJsonResponse: Enable JSON response mode instead of SSE streamingstateless: Enable stateless mode (no session management)authentication: Authentication handler for protected routeseventStore: Event store for resumability support
Session Management
The plugin automatically handles session management via the Mcp-Session-Id
header. Each session maintains its own state and can be terminated cleanly.
Modular Handler Architecture
The plugin supports a modular handler architecture that allows you to create specialized endpoints for different MCP capabilities:
Custom Logger
The plugin supports custom logger instances, allowing you to use any logging library that conforms to the ILogger interface:
Using Pino Logger
Using Winston Logger
Default Console Logger
If you don't provide a custom logger, the plugin will use a default console logger when enableLogging is set to true:
Custom Logger Implementation
You can also implement your own logger:
API Reference
Tools
Register tools using the MCP Server instance:
Resources
Register resources for file or data access:
Prompts
Register reusable prompt templates following MCP best practices:
Testing
Run the comprehensive test suite:
License
MIT - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.