TrustLayer MCP Server
Provides read-only access to TrustLayer's public API, enabling users to query and retrieve data about parties, documents, projects, and other TrustLayer entities through MCP-compatible tools.
README
Unofficial TrustLayer MCP Server
Unofficial community Model Context Protocol (MCP) server for the Public TrustLayer API - read-only access.
Overview
This MCP server provides read-only access to the Public TrustLayer API data, allowing integration with:
API Documentation: This server implements the Public TrustLayer Platform API v1.0 and follows the public API documentation available at https://developers.trustlayer.io/.
- Cursor IDE
- n8n workflows
- Claude Desktop
- Other MCP-compatible tools
Features
- Read-Only Access: Only GET operations are supported (no create, update, or delete)
- Resources: List all TrustLayer entities (Parties, Documents, Projects, etc.)
- Tools: Query specific entities by ID or list with filters
- JSON Responses: All data returned as structured JSON
- HTTP Transport: Deploy as HTTP server for remote access
- Token Authentication: Support for per-request token via Authorization header
Prerequisites
- Python 3.11+
- TrustLayer API token
Installation
- Navigate to the mcp-server directory:
cd mcp-server
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.envfile:
cp env.example .env
- Edit
.envand configure:
TRUSTLAYER_API_BASE_URL=https://api.trustlayer.io
TRUSTLAYER_API_VERSION=v1
# TRUSTLAYER_API_TOKEN is optional for HTTP mode (token from Authorization header)
# Required only for stdio mode
TRUSTLAYER_API_TOKEN=your_api_token_here
Configuration Options:
TRUSTLAYER_API_BASE_URL- Base URL for TrustLayer API (default:https://api.trustlayer.io)TRUSTLAYER_API_VERSION- API version (default:v1)TRUSTLAYER_API_TOKEN- API token (required for stdio mode, optional for HTTP mode)
Usage
Running the MCP Server
The MCP server can run in two modes:
1. Stdio Mode (for local MCP clients)
The MCP server runs via stdio and is typically started by MCP clients. To test manually:
Option 1: Using the wrapper script (recommended):
# Make sure the script is executable
chmod +x run_server.sh
# Run the server
./run_server.sh
Option 2: Direct Python execution:
# Activate virtual environment
source venv/bin/activate # On Windows: venv\Scripts\activate
# Run the server
python -m src.server
2. HTTP Mode (for remote access)
To run the MCP server as an HTTP service:
# Activate virtual environment
source venv/bin/activate # On Windows: venv\Scripts\activate
# Run the HTTP server
python run_http_server.py
The server will be available at http://localhost:8000 with the following endpoints:
http://localhost:8000/- Health check and server infohttp://localhost:8000/health- Health check endpointhttp://localhost:8000/mcp- MCP protocol endpoint
Note:
- For HTTP mode: Token can be provided via
Authorizationheader (recommended) or viaTRUSTLAYER_API_TOKENenv var - For stdio mode: Token must be set in
TRUSTLAYER_API_TOKENenv var
3. Docker Mode
To run the MCP server using Docker:
# Create .env file if it doesn't exist
cp env.example .env
# Edit .env and set TRUSTLAYER_API_TOKEN (optional for HTTP mode)
# Build and start the container
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the container
docker-compose down
Rebuilding the Docker image:
If you've made changes to the code and need to rebuild the image:
# Stop and remove containers
docker-compose down
# Rebuild without cache (recommended after code changes)
docker-compose build --no-cache
# Start the container
docker-compose up -d
# Or do it all in one command
docker-compose down && docker-compose build --no-cache && docker-compose up -d
Quick rebuild and restart:
# Rebuild and restart in one command
docker-compose up -d --build
Checking if the server is running:
# Check container status
docker-compose ps
# Check health endpoint
curl http://localhost:8000/health
# View logs
docker-compose logs --tail=50
The server will be available at http://localhost:8000 with the same endpoints as HTTP mode.
Production Deployment
Systemd Service Setup
For production deployment on Linux servers, you can create a systemd service:
- Create service file:
sudo nano /etc/systemd/system/trustlayer-mcp.service
- Add the following content:
[Unit]
Description=TrustLayer MCP Server
After=network.target
[Service]
Type=simple
User=your-user
WorkingDirectory=/path/to/mcp-server
Environment="PATH=/path/to/mcp-server/venv/bin"
EnvironmentFile=/path/to/mcp-server/.env
ExecStart=/path/to/mcp-server/venv/bin/python run_http_server.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
- Activate the service:
# Reload systemd
sudo systemctl daemon-reload
# Enable auto-start
sudo systemctl enable trustlayer-mcp
# Start the service
sudo systemctl start trustlayer-mcp
# Check status
sudo systemctl status trustlayer-mcp
# View logs
sudo journalctl -u trustlayer-mcp -f
Nginx Reverse Proxy
For production, it's recommended to use Nginx as a reverse proxy:
- Create Nginx configuration:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
# For SSE/streaming
proxy_buffering off;
proxy_cache off;
}
}
- Enable SSL with Let's Encrypt:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com
Integration with Cursor
Option 1: Stdio Mode (Local)
Add to your Cursor settings (.cursor/mcp.json):
Option A: Using the wrapper script (recommended):
{
"mcpServers": {
"trustlayer": {
"command": "/path/to/mcp-server/run_server.sh",
"cwd": "/path/to/mcp-server",
"env": {
"TRUSTLAYER_API_TOKEN": "your_api_token_here",
"TRUSTLAYER_API_BASE_URL": "https://api.trustlayer.io",
"TRUSTLAYER_API_VERSION": "v1"
}
}
}
}
Option B: Direct Python execution:
{
"mcpServers": {
"trustlayer": {
"command": "/path/to/mcp-server/venv/bin/python3",
"args": ["-m", "src.server"],
"cwd": "/path/to/mcp-server",
"env": {
"PYTHONPATH": "/path/to/mcp-server",
"TRUSTLAYER_API_TOKEN": "your_api_token_here",
"TRUSTLAYER_API_BASE_URL": "https://api.trustlayer.io",
"TRUSTLAYER_API_VERSION": "v1"
}
}
}
}
Example with absolute paths (using wrapper script):
{
"mcpServers": {
"trustlayer": {
"command": "/path/to/mcp-server/run_server.sh",
"cwd": "/path/to/mcp-server",
"env": {
"TRUSTLAYER_API_TOKEN": "your_api_token_here",
"TRUSTLAYER_API_BASE_URL": "https://api.trustlayer.io",
"TRUSTLAYER_API_VERSION": "v1"
}
}
}
}
Important:
- When using the wrapper script (
run_server.sh): Just provide the full path to the script and setcwd - When using direct Python execution: Use the full path to your Python executable in the virtual environment and set
PYTHONPATH - Always set
cwdto the mcp-server directory
Option 2: HTTP Mode (Remote)
If you're running the HTTP server separately, connect via HTTP:
Basic connection (uses token from server config):
{
"mcpServers": {
"trustlayer": {
"url": "http://localhost:8000/mcp",
"transport": "streamable-http"
}
}
}
With Authorization header (recommended - token per client):
{
"mcpServers": {
"trustlayer": {
"url": "http://localhost:8000/mcp",
"transport": "streamable-http",
"headers": {
"Authorization": "Bearer your_api_token_here"
}
}
}
}
For remote servers, replace localhost:8000 with your server's address.
Note: When using Authorization header, the token is passed with each request, allowing different clients to use different tokens. This is more secure than storing tokens in server configuration.
Integration with Claude Desktop
Add to Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Stdio Mode:
{
"mcpServers": {
"trustlayer": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/mcp-server",
"env": {
"TRUSTLAYER_API_TOKEN": "your_token_here",
"TRUSTLAYER_API_BASE_URL": "https://api.trustlayer.io",
"TRUSTLAYER_API_VERSION": "v1"
}
}
}
}
HTTP Mode:
{
"mcpServers": {
"trustlayer": {
"url": "http://your-server:8000/mcp",
"transport": "streamable-http",
"headers": {
"Authorization": "Bearer your_api_token_here"
}
}
}
}
Integration with n8n
Use the MCP server as a custom node or via HTTP interface. Start the HTTP server and connect to http://your-server:8000/mcp.
Configuration example:
{
"url": "http://your-server:8000/mcp",
"transport": "streamable-http",
"headers": {
"Authorization": "Bearer your_api_token_here"
}
}
Note: Replace your-server:8000 with your actual server address and your_api_token_here with your TrustLayer API token.
Available Resources
The MCP server provides resources for:
trustlayer://parties/{id}- Individual partiestrustlayer://documents/{id}- Individual documentstrustlayer://projects/{id}- Individual projectstrustlayer://tags/{id}- Individual tagstrustlayer://compliance-profiles/{id}- Compliance profilestrustlayer://party-types/{id}- Party typestrustlayer://custom-fields/{id}- Custom fieldstrustlayer://reports/{id}- Reportstrustlayer://webhooks/{id}- Webhookstrustlayer://branding/{id}- Branding configurations
Available Tools
Get Operations
get_party- Get a party by IDget_document- Get a document by IDget_project- Get a project by IDget_contact- Get a contact by IDget_party_contacts- Get all contacts for a partyget_party_compliance_profile- Get compliance profile for a partyget_party_compliance_certificate- Get compliance certificate for a partyget_party_document_request- Get document request for a partyget_compliance_profile- Get a compliance profile by IDget_report- Get a report by ID
List Operations
list_parties- List all parties (with optional limit/offset)list_documents- List all documents (with optional limit/offset)list_projects- List all projects (with optional limit/offset)list_tags- List all tagslist_compliance_profiles- List all compliance profileslist_party_types- List all party typeslist_custom_fields- List all custom fieldslist_reports- List all reportslist_webhooks- List all webhooks
Project Structure
mcp-server/
├── src/
│ ├── __init__.py
│ ├── server.py # Main MCP server (stdio mode)
│ ├── http_server.py # HTTP MCP server
│ ├── trustlayer_client.py # TrustLayer API client
│ ├── config.py # Configuration
│ ├── resources.py # MCP resources
│ └── tools.py # MCP tools
├── run_server.sh # Stdio server launcher script
├── run_http_server.py # HTTP server launcher
├── test_server.py # Test script to verify server setup
├── test_tools.py # Test script to verify tools registration
├── pyproject.toml
├── requirements.txt
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── env.example # Environment variables example
└── README.md
Example Usage
In Cursor/Claude
You can ask questions like:
- "List all parties in TrustLayer"
- "Get details for party ID 12345"
- "Show me all documents for party 12345"
- "What compliance profile does party 12345 have?"
The MCP server will fetch the data from TrustLayer API and return it in a structured format.
Security
- Read-Only: The MCP server only supports GET operations
- Token Security: Store API tokens securely in environment variables or use Authorization headers
- No Data Modification: No create, update, or delete operations are exposed
- HTTPS Recommended: Use HTTPS in production environments
- Firewall: Restrict access through firewall to only necessary IPs
Monitoring
Health Check
The server provides a health check endpoint:
curl http://localhost:8000/health
Expected response:
{"status": "healthy"}
Logs
Docker:
docker-compose logs -f
Systemd:
sudo journalctl -u trustlayer-mcp -f
Local: Logs are output to stdout/stderr when running directly.
Troubleshooting
Token Issues
Ensure TRUSTLAYER_API_TOKEN is set correctly in your environment or .env file. For HTTP mode, you can also provide the token via Authorization header.
Connection Issues
- Verify
TRUSTLAYER_API_BASE_URLis correct - Check network connectivity
- Review server logs for error messages
- For HTTP mode, ensure the server is running:
curl http://localhost:8000/health
Port Already in Use
# Check what's using port 8000
sudo lsof -i :8000
# Or change the port in run_http_server.py
MCP Client Issues
- Ensure Python is in your PATH
- Verify the MCP server can be started manually
- Check MCP client logs for connection errors
- For stdio mode, verify paths in configuration are correct
Docker Issues
- Ensure Docker and Docker Compose are installed
- Check container logs:
docker-compose logs - Verify
.envfile exists and is properly configured - Rebuild image if code changes:
docker-compose build --no-cache
Development
Testing
Quick Verification Scripts
Test server setup and imports:
python test_server.py
This script verifies that:
- Configuration loads correctly
- Server can be imported
- Tools are available
Test tools registration:
python test_tools.py
This script verifies that tools are properly registered and can be listed.
Test Stdio Server
Option 1: Using the wrapper script:
./run_server.sh
Option 2: Direct Python execution:
source venv/bin/activate
python -m src.server
Test HTTP Server
# Start the HTTP server
python run_http_server.py
# In another terminal, test the endpoints
curl http://localhost:8000/health
curl http://localhost:8000/
Code Formatting
black src/
ruff check src/
License
Apache 2.0
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。