https://github.com/msmygit/linklibrary-mcp
An MCP server implementation for https://LinkLibrary.ai
https://github.com/msmygit/linklibrary-mcp
Last synced: 5 months ago
JSON representation
An MCP server implementation for https://LinkLibrary.ai
- Host: GitHub
- URL: https://github.com/msmygit/linklibrary-mcp
- Owner: msmygit
- License: mit
- Created: 2025-07-31T23:21:40.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-01T00:22:53.000Z (11 months ago)
- Last Synced: 2025-08-01T00:46:32.996Z (11 months ago)
- Language: TypeScript
- Size: 110 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# @msmygit/linklibrary-mcp






A high-performance, production-ready Model Context Protocol (MCP) server that provides AI assistants with programmatic access to [LinkLibrary.ai](https://linklibrary.ai) bookmark management capabilities.
## ๐ Features
### โจ Core Features
- **๐ Secure Authentication** - JWT-based authentication with automatic token refresh
- **๐ Bookmark Management** - Create, retrieve, and organize bookmarks with rich metadata
- **๐ Collections & Tags** - Manage bookmark organization with collections and tags
- **๐ Advanced Search** - Powerful search with multiple filters and operators
- **๐ Analytics** - Get insights about your bookmark usage and patterns
- **๐ค AI Integration** - Works seamlessly with Claude Desktop, VSCode, and other MCP clients
### ๐๏ธ Architecture Features
- **โก High Performance** - In-memory caching with LRU eviction and TTL
- **๐ก๏ธ Rate Limiting** - Configurable rate limiting with sliding window
- **๐ Metrics Driven** - Comprehensive performance monitoring and logging
- **๐ Retry Logic** - Automatic retry with exponential backoff
- **๐ Error Handling** - Robust error handling with proper error types
- **๐งช Test Coverage** - Comprehensive test suite with mocking
## ๐ ๏ธ Installation
### For End Users
The package is published on npm and can be used directly with MCP clients:
```json
{
"mcpServers": {
"linklibrary-mcp": {
"command": "npx",
"args": ["-y", "@msmygit/linklibrary-mcp@latest"],
"env": {
"LL_USERNAME": "your_email@example.com",
"LL_PASSWORD": "your_password"
}
}
}
}
```
### For Developers
```bash
npm install @msmygit/linklibrary-mcp
```
## ๐ง Configuration
### Environment Variables
| Variable | Description | Default | Required |
|----------|-------------|---------|----------|
| `LL_USERNAME` | LinkLibrary.ai email address | - | Yes* |
| `LL_PASSWORD` | LinkLibrary.ai password | - | Yes* |
| `LL_TOKEN` | LinkLibrary.ai API token | - | Yes* |
| `LINKLIBRARY_API_URL` | API base URL | `https://api.linklibrary.ai/api/v1` | No |
| `API_TIMEOUT_MS` | API request timeout | `30000` | No |
| `API_MAX_RETRIES` | Maximum retry attempts | `3` | No |
| `CACHE_TTL_SECONDS` | Cache TTL in seconds | `300` | No |
| `CACHE_MAX_SIZE` | Maximum cache entries | `1000` | No |
| `RATE_LIMIT_REQUESTS` | Rate limit requests per window | `100` | No |
| `RATE_LIMIT_WINDOW_MS` | Rate limit window in ms | `60000` | No |
| `LOG_LEVEL` | Logging level | `info` | No |
| `ENABLE_METRICS` | Enable performance metrics | `false` | No |
*Either `LL_USERNAME`/`LL_PASSWORD` or `LL_TOKEN` is required.
### MCP Client Configuration
#### Claude Desktop
Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS/Linux) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
```json
{
"mcpServers": {
"linklibrary-mcp": {
"command": "npx",
"args": ["-y", "@msmygit/linklibrary-mcp@latest"],
"env": {
"LL_USERNAME": "your_email@example.com",
"LL_PASSWORD": "your_password",
"ENABLE_METRICS": "true"
}
}
}
}
```
#### VSCode
Add to your VSCode settings:
```json
{
"mcp.servers": {
"linklibrary-mcp": {
"command": "npx",
"args": ["-y", "@msmygit/linklibrary-mcp@latest"],
"env": {
"LL_USERNAME": "your_email@example.com",
"LL_PASSWORD": "your_password"
}
}
}
}
```
## ๐ ๏ธ Available Tools
### Authentication
- `authenticate` - Authenticate with LinkLibrary credentials
### Bookmark Management
- `get_links` - Retrieve bookmarks with filtering and pagination
- `create_link` - Create new bookmarks with metadata
### Organization
- `get_collections` - Retrieve user collections
- `get_tags` - Retrieve user tags
### Search & Analytics
- `search_advanced` - Advanced search with multiple filters
- `get_user_stats` - Get user statistics and insights
## ๐ก Usage Examples
Once connected to your MCP client, you can ask:
- "Show me my recent bookmarks"
- "Create a bookmark for this article about AI"
- "Search for machine learning resources in my Development collection"
- "Show me my bookmark statistics for this month"
- "What are my most used tags?"
## ๐๏ธ Architecture
### Core Components
```
linklibrary-mcp/
โโโ src/
โ โโโ types.ts # TypeScript type definitions
โ โโโ config.ts # Configuration management
โ โโโ server.ts # Main MCP server implementation
โ โโโ services/
โ โ โโโ api-client.ts # HTTP client with retry logic
โ โ โโโ auth-service.ts # Authentication management
โ โโโ utils/
โ โโโ logger.ts # Structured logging with metrics
โ โโโ cache.ts # In-memory LRU cache
โ โโโ rate-limiter.ts # Rate limiting implementation
โโโ scripts/
โ โโโ build.js # Build script
โโโ tests/
โ โโโ server.test.ts # Comprehensive test suite
โโโ package.json # npm package configuration
```
### Performance Features
#### ๐ Caching
- **In-memory LRU cache** with configurable TTL
- **Automatic cache invalidation** on data changes
- **Cache hit rate monitoring** and statistics
#### โก Rate Limiting
- **Sliding window rate limiting** for API protection
- **Configurable limits** per operation type
- **Rate limit monitoring** and reporting
#### ๐ Metrics & Monitoring
- **Performance metrics** collection and reporting
- **Request/response timing** with percentiles
- **Error rate tracking** and alerting
- **Cache performance** monitoring
#### ๐ Retry Logic
- **Exponential backoff** for transient failures
- **Configurable retry attempts** and delays
- **Smart retry conditions** (5xx errors, timeouts)
## ๐งช Development
### Prerequisites
- Node.js 18+
- npm or yarn
### Setup
```bash
git clone
cd linklibrary-mcp
npm install
```
### Development Commands
```bash
# Build the package
npm run build
# Run in development mode
npm run dev
# Run tests
npm test
# Run tests with coverage
npm test -- --coverage
# Lint code
npm run lint
# Format code
npm run format
```
### Testing
The project includes comprehensive tests:
- **Unit tests** for all services and utilities
- **Integration tests** for API interactions
- **Mock testing** for external dependencies
- **Performance tests** for caching and rate limiting
```bash
# Run all tests
npm test
# Run specific test suites
npm test -- --testNamePattern="Authentication"
npm test -- --testNamePattern="Cache"
```
### Building for Production
```bash
# Build the package
npm run build
# Test the built package
npm start
# Publish to npm
npm publish
```
## ๐ Performance
### Benchmarks
- **Response Time**: < 100ms for cached requests
- **Throughput**: 1000+ requests per minute
- **Memory Usage**: < 50MB for typical usage
- **Cache Hit Rate**: > 80% for read operations
### Monitoring
Enable metrics collection by setting `ENABLE_METRICS=true`:
```bash
export ENABLE_METRICS=true
npx @msmygit/linklibrary-mcp
```
Metrics include:
- Request count and response times
- Cache hit/miss rates
- Rate limit usage
- Error rates and types
## ๐ Security
### Security Features
- **No local storage** - credentials not stored locally
- **Environment variables** - secure credential management
- **API authentication** - uses LinkLibrary.ai's secure API
- **Rate limiting** - protection against abuse
- **Input validation** - comprehensive parameter validation
- **Error sanitization** - no sensitive data in error messages
### Best Practices
- Use environment variables for credentials
- Enable metrics only in development
- Monitor rate limit usage
- Regularly update dependencies
- Use HTTPS for all API communications
## ๐ Troubleshooting
### Common Issues
#### Authentication Errors
```bash
# Check environment variables
echo $LL_USERNAME
echo $LL_PASSWORD
# Verify API connectivity
curl -I https://linklibrary.ai/api/health
```
#### Performance Issues
```bash
# Check cache statistics
# Enable debug logging
export LOG_LEVEL=debug
# Monitor rate limits
# Check rate limit configuration
```
#### Connection Issues
```bash
# Test API connectivity
curl https://linklibrary.ai/api/health
# Check network configuration
ping linklibrary.ai
```
### Debug Mode
Enable debug logging for troubleshooting:
```bash
export LOG_LEVEL=debug
export ENABLE_METRICS=true
npx @msmygit/linklibrary-mcp
```
## ๐ License
MIT License - see [LICENSE](LICENSE) file for details.
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
### Development Guidelines
- Follow TypeScript best practices
- Add tests for new features
- Update documentation as needed
- Follow the existing code style
- Ensure all tests pass before submitting
## ๐ Support
- **Documentation**: [LinkLibrary.ai](https://linklibrary.ai)
- **Issues**: [GitHub Issues](https://github.com/msmygit/linklibrary-mcp/issues)
- **Email**: linklibrary.ai@gmail.com
## ๐ Links
- [LinkLibrary.ai](https://linklibrary.ai) - Main service
- [MCP Documentation](https://modelcontextprotocol.io/) - Protocol specification
- [npm Package](https://www.npmjs.com/package/@msmygit/linklibrary-mcp) - Package page
- [GitHub Repository](https://github.com/msmygit/linklibrary-mcp) - Source code
---
**Built with โค๏ธ for the AI community**