Trilium MCP Server

Trilium MCP Server

Enables AI clients to manage Trilium Notes with full CRUD operations, search, calendar integration, and system administration through the Model Context Protocol.

Category
访问服务器

README

Trilium MCP Server

A comprehensive Model Context Protocol (MCP) server for Trilium Notes integration, providing complete note management functionality through MCP-compatible AI clients.

🚀 Production Ready • 🔧 15 API Endpoints • 📊 208 Tests • 🏥 Health Monitoring • 📚 Interactive API Docs

Live Server: https://your-trilium-server.example.com/mcp

Features

  • Complete Note Management: Create, read, update, delete, and search notes
  • Rich Content Support: HTML content with formatting and attachments
  • Calendar Integration: Day, week, and month notes with automatic organization
  • Advanced Search: Full-text search with filtering and structured results
  • File Attachments: Base64-encoded file attachment support
  • System Operations: Backup creation, export functionality, and system info
  • Interactive API Documentation: Beautiful HTML docs with examples and OpenAPI JSON export
  • Verbose Logging: Comprehensive request tracking and health monitoring
  • Production Deployment: HTTPS endpoint with authentication and error handling

API Documentation

For complete API documentation, see API Reference.

Interactive Documentation: Visit /docs for complete API documentation with:

  • All 15 endpoints organized by category
  • Request/response examples
  • Parameter descriptions with types and constraints
  • Known issues and workarounds
  • OpenAPI 3.0 JSON export at /docs/json
  • MCP Manifest at /mcp.json (JSON-RPC tools/list format)

Quick Start

For AI Clients (Recommended)

  1. Copy configuration from mcp-server-config.json:
{
  "mcpServers": {
    "trilium": {
      "command": "curl",
      "args": [
        "-X",
        "POST",
        "https://your-trilium-server.example.com/mcp",
        "-H",
        "Content-Type: application/json",
        "-H",
        "Accept: application/json, text/event-stream",
        "--data-binary",
        "@-"
      ]
    }
  }
}
  1. Import into your AI client:

    • Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
    • Other MCP clients: Use the universal configuration
  2. Start using - All 15 tools will be available immediately!

Direct HTTP Testing

# Test note creation
curl -X POST https://your-trilium-server.example.com/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "create_note",
      "arguments": {
        "parentId": "root",
        "title": "API Test Note",
        "content": "<h1>Hello from MCP!</h1><p>This note was created via the API.</p>"
      }
    }
  }'

# Test search functionality
curl -X POST https://your-trilium-server.example.com/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "search_notes",
      "arguments": {
        "query": "API Test",
        "limit": 5,
        "format": "structured"
      }
    }
  }'

# Get system information
curl -X POST https://your-trilium-server.example.com/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "get_app_info",
      "arguments": {}
    }
  }'

Local Development

Prerequisites

  • Node.js 18+
  • pnpm package manager
  • Trilium Notes instance with ETAPI enabled

Setup

  1. Clone and install:
git clone <repository-url>
cd trilium-mcp
pnpm install
  1. Configure environment:
cp .env.example .env
# Edit .env with your Trilium URL and token
  1. Start development server:
pnpm dev  # Auto-reload enabled
# or
pnpm start  # Production mode
  1. Health check:
curl http://localhost:3000/health

Environment Variables

Variable Description Required Default
TRILIUM_URL Trilium ETAPI URL (include /etapi path) -
TRILIUM_TOKEN ETAPI authentication token -
PORT HTTP server port 3000
NODE_ENV Environment mode development

Production Features

Comprehensive Logging

  • Request tracking: Unique IDs for every MCP request with timing
  • ETAPI monitoring: All Trilium API calls logged with request/response details
  • Health monitoring: System stats every 30 seconds (memory, connections, uptime)
  • Error handling: Full stack traces and detailed error messages
  • Connection tracking: Active/total connection counts with lifecycle logging

Health Monitoring

# View server health
curl https://my-own-trilium-mcp.fly.dev/health

# View API documentation
curl https://my-own-trilium-mcp.fly.dev/docs

# Get OpenAPI JSON spec
curl https://my-own-trilium-mcp.fly.dev/docs/json

# Get MCP Manifest (tools/list format)
curl https://my-own-trilium-mcp.fly.dev/mcp.json

# Monitor deployment logs
fly logs -a your-app-name

Security

  • HTTPS deployment with proper TLS
  • ETAPI authentication with Basic Auth
  • CORS enabled for cross-origin requests
  • Request validation with MCP protocol compliance
  • Error sanitization without sensitive data leakage

Performance Metrics

Based on comprehensive testing:

  • Response Times: 100-300ms average for most operations
  • Memory Usage: ~99MB RSS, stable memory footprint
  • Connection Handling: Proper cleanup and resource management
  • Uptime: Production-stable with comprehensive error handling
  • Success Rate: 13/15 endpoints (87%) fully working

Testing Results

The server has been comprehensively tested with real-world scenarios:

Created nested folder structure with rich HTML content ✅ All CRUD operations tested with actual data ✅ Calendar integration verified with daily/monthly notes ✅ File attachments tested with base64 encoding ✅ Search functionality confirmed with structured results ✅ System operations validated including backups and info retrieval

See Final Test Results for complete testing documentation.

Additional Resources

License

MIT License - see LICENSE file for details.


Ready to use! 🎉 Import the configuration files into your favorite MCP-compatible AI client and start managing your Trilium notes with AI assistance.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选