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:
Create a virtual environment:
Install dependencies:
Create a
.envfile:
Edit
.envand configure:
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):
Option 2: Direct Python execution:
2. HTTP Mode (for remote access)
To run the MCP server as an HTTP service:
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 varFor stdio mode: Token must be set in
TRUSTLAYER_API_TOKENenv var
3. Docker Mode
To run the MCP server using Docker:
Rebuilding the Docker image:
If you've made changes to the code and need to rebuild the image:
Quick rebuild and restart:
Checking if the server is running:
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:
Add the following content:
Activate the service:
Nginx Reverse Proxy
For production, it's recommended to use Nginx as a reverse proxy:
Create Nginx configuration:
Enable SSL with Let's Encrypt:
Integration with Cursor
Option 1: Stdio Mode (Local)
Add to your Cursor settings (.cursor/mcp.json):
Option A: Using the wrapper script (recommended):
Option B: Direct Python execution:
Example with absolute paths (using wrapper script):
Important:
When using the wrapper script (
run_server.sh): Just provide the full path to the script and setcwdWhen using direct Python execution: Use the full path to your Python executable in the virtual environment and set
PYTHONPATHAlways 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):
With Authorization header (recommended - token per client):
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:
HTTP Mode:
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:
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
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:
Expected response:
Logs
Docker:
Systemd:
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 correctCheck 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
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 logsVerify
.envfile exists and is properly configuredRebuild image if code changes:
docker-compose build --no-cache
Development
Testing
Quick Verification Scripts
Test server setup and imports:
This script verifies that:
Configuration loads correctly
Server can be imported
Tools are available
Test tools registration:
This script verifies that tools are properly registered and can be listed.
Test Stdio Server
Option 1: Using the wrapper script:
Option 2: Direct Python execution:
Test HTTP Server
Code Formatting
License
Apache 2.0