Labsco
Leantime logo

Leantime MCP Bridge

โ˜… 8

from Leantime

An MCP proxy bridge for the Leantime project management system, forwarding JSON-RPC messages with proper authentication.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

Leantime MCP Bridge

A robust Model Context Protocol (MCP) proxy bridge for Leantime project management system. Built with TypeScript and the official MCP SDK, this tool provides a reliable bridge between MCP clients and Leantime servers.

โœจ Features

  • Built with Official MCP SDK: Uses @modelcontextprotocol/sdk for robust protocol handling
  • Multiple Authentication Methods: Bearer, API Key, Token, and X-API-Key headers
  • Protocol Version Support: MCP 2025-03-26 (latest) with backward compatibility
  • Advanced Transport Support: HTTP/HTTPS, Server-Sent Events (SSE), and streaming responses
  • TypeScript Implementation: Type-safe, maintainable codebase

Pre-Requisites

๐Ÿ”ง How It Works

  1. Protocol Handling: Uses official MCP SDK for robust JSON-RPC message handling
  2. Authentication: Adds appropriate authentication headers based on chosen method
  3. Transport Layer: Supports both regular HTTP responses and Server-Sent Events (SSE)
  4. Error Handling: Comprehensive error handling with proper JSON-RPC error responses
  5. Session Management: Tracks MCP session IDs for stateful interactions
  6. Retry Logic: Exponential backoff with jitter prevents thundering herd problems
  7. Smart Caching: Caches tool/resource/prompt lists to reduce server load

๐Ÿ”„ Advanced Features

Retry Logic with Exponential Backoff

  • Automatic retries: Failed requests are automatically retried (default: 3 attempts)
  • Exponential backoff: Delay doubles with each retry (1s โ†’ 2s โ†’ 4s...)
  • Jitter: Random ยฑ25% variation prevents thundering herd effect
  • Configurable: Customize max retries and base delay via CLI options

Smart Response Caching

  • Automatic caching: tools/list, resources/list, and prompts/list responses are cached
  • TTL-based expiry: Cached responses expire after 5 minutes
  • Memory efficient: Automatic cleanup of expired cache entries
  • Configurable: Use --no-cache to disable for development/testing

Production-Ready Reliability

  • Connection resilience: Handles network interruptions gracefully
  • Request tracking: Numbered requests for easy debugging
  • Comprehensive logging: Detailed logs to stderr (won't interfere with MCP communication)
  • Graceful shutdown: Clean termination on SIGINT/SIGTERM

๐Ÿ—๏ธ Architecture

v2.0 Improvements over v1.x

  • TypeScript Rewrite: Type-safe implementation with better maintainability
  • Official SDK Integration: Uses @modelcontextprotocol/sdk instead of custom implementation
  • Enhanced Authentication: Support for multiple authentication methods
  • Better Error Handling: Proper JSON-RPC error responses and logging
  • Protocol Negotiation: Automatic protocol version negotiation
  • Streaming Support: Full support for SSE and streaming responses

Protocol Support

  • Primary: MCP 2025-03-26 (latest specification)
  • Fallback: MCP 2024-11-05 (backward compatibility)
  • Auto-negotiation: Automatically detects and uses appropriate protocol version

๐Ÿงช Development

Prerequisites

  • Node.js 18.0.0 or higher
  • TypeScript 5.4.0 or higher
  • Access to a Leantime instance with MCP support

Building from Source

# Clone the repository
git clone https://github.com/leantime/leantime-mcp.git
cd leantime-mcp

# Install dependencies
npm install

# Build TypeScript
npm run build

# Test locally
echo '{"jsonrpc":"2.0","id":1,"method":"ping"}' | node dist/index.js https://your-leantime.com/mcp --token your-token

Development Mode

# Watch for changes and rebuild
npm run dev

๐Ÿ›ก๏ธ Security Considerations

  • HTTPS Only: Always use HTTPS in production environments
  • Token Security: Store tokens securely and avoid logging them
  • SSL Verification: Only use --insecure flag in development
  • Token Rotation: Consider implementing token rotation for long-running processes
  • Network Security: Ensure proper network security between proxy and Leantime server

๐Ÿ› Error Handling

The proxy includes comprehensive error handling for:

  • Network Issues: Connection timeouts, DNS resolution failures
  • Authentication: Invalid tokens, expired credentials
  • Protocol Errors: Malformed JSON-RPC messages, protocol mismatches
  • Server Errors: HTTP errors, invalid responses from Leantime
  • Transport Issues: SSE connection problems, streaming errors

All error messages are logged to stderr to avoid interfering with MCP communication on stdout.

๐Ÿ“Š Logging

The proxy provides detailed logging for debugging:

[LeantimeMCP] Initializing Leantime MCP Proxy...
[LeantimeMCP] Server: https://leantime.example.com/mcp
[LeantimeMCP] Auth Method: Bearer
[LeantimeMCP] SSL verification: enabled
[LeantimeMCP] Protocol version: 2025-03-26
[LeantimeMCP] Ready to handle MCP requests...

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with TypeScript
  4. Add tests if applicable
  5. Build and test (npm run build && npm test)
  6. Submit a pull request

๐Ÿ’ฌ Support

For issues and questions:

๐Ÿ“‹ Changelog

1.6.0 (Latest)

  • ๐ŸŽ‰ Complete TypeScript rewrite using official MCP SDK
  • โœจ Multiple authentication methods (Bearer, ApiKey, Token, X-API-Key)
  • ๐Ÿš€ Enhanced protocol support (MCP 2025-03-26 + backward compatibility)
  • ๐Ÿ”ง Improved error handling and logging
  • ๐Ÿ“ก Better transport layer with SSE and streaming support
  • ๐Ÿ›ก๏ธ Enhanced security and session management
  • ๐Ÿ“ฆ Smaller codebase (80% reduction) with better maintainability
  • ๐Ÿ”„ Advanced retry logic with exponential backoff and jitter
  • ๐Ÿ’พ Smart caching for tool lists and schemas (5-minute TTL)
  • โšก Production-ready connection resilience and error recovery

1.x.x (Legacy)

  • Basic MCP proxy functionality
  • HTTP/HTTPS support
  • Bearer token authentication only
  • SSL verification bypass option