Skip to main content
Trinity
Guides/MCP Integration

MCP Integration

Trinity's MCP server exposes 62 tools for agent orchestration via the Model Context Protocol, enabling programmatic control from Claude Code, other MCP clients, or agent-to-agent communication.

Overview

The Model Context Protocol (MCP) is an open standard for tool-based AI integrations. Trinity implements an MCP server using FastMCP with Streamable HTTP transport on port 8080. API keys authenticate access and can be scoped to specific agents.

Authentication

1

Go to the API Keys page (/api-keys).

2

Click Create Key. Optionally scope the key to a specific agent.

3

Copy the generated key (prefixed trinity_mcp_*).

4

Use the key as a Bearer token in the Authorization header.

Connecting from Claude Code

Add Trinity as an MCP server in your Claude Code configuration:

{
  "mcpServers": {
    "trinity": {
      "type": "url",
      "url": "http://localhost:8080/mcp",
      "headers": {
        "Authorization": "Bearer <your-api-key>"
      }
    }
  }
}

Tool Categories

The MCP server organizes 62 tools across these modules:

ModuleToolsDescription
agents.ts17Agent lifecycle, credentials, SSH, local deploy, GitHub sync
chat.ts3Chat, history, logs
schedules.ts8Schedule CRUD and execution history
executions.ts3Execution queries, async polling, activity monitoring
skills.ts7Skill management and assignment
tags.ts5Agent tagging
systems.ts4System manifest deployment
subscriptions.ts6Subscription management
monitoring.ts3Fleet health
nevermined.ts4Payment configuration
notifications.ts1Agent notifications
events.ts4Event pub/sub
docs.ts1Agent documentation

API Key Management

EndpointMethodDescription
/api/mcp/keysPOSTCreate API key
/api/mcp/keysGETList API keys
/api/mcp/keys/{key_id}DELETERevoke API key

Nevermined x402 Payments

Monetize agents with per-request payments using the Nevermined x402 payment protocol. Users pay per chat message; agents earn credits.

Setup

1

Open the agent detail page and navigate to payment settings.

2

Enter the NVM API Key, Agent ID, and Plan ID from Nevermined.

3

Enable payments. The agent now has a paid chat endpoint: POST /api/paid/{agent_name}/chat.

Payment Flow

Client -> POST /api/paid/{agent}/chat (no token)
  <- 402 Payment Required (includes payment info)

Client -> Purchases credits via Nevermined checkout page
Client -> POST /api/paid/{agent}/chat (payment-signature header)
  <- 200 OK (agent response, 1 credit deducted)

Payment API

EndpointMethodDescription
/api/paid/{agent_name}/chatPOSTPaid chat (returns 402/403/200)
/api/paid/{agent_name}/infoGETPayment requirements (no auth)
/api/nevermined/agents/{name}/configPOST/GET/DELETEConfigure payment settings
/api/nevermined/agents/{name}/config/togglePUTEnable or disable payments

Limitations

API keys are invalidated when the backend restarts.
Agent-scoped keys cannot access tools outside their assigned agent.
MCP clients must be manually reconnected after a backend restart.
Only one Nevermined plan per agent. Settlement failures must be retried manually.