Skip to main content

Agent Tools

Agents use three types of tools: API tools (HTTP endpoints), Database tools (SQL queries), and MCP tools (external MCP servers). All tools are resolved at runtime via the ToolRegistry.

Tool Types

TypeSchemaDescription
api_configHTTP toolCalls external REST APIs
db_configSQL toolExecutes parameterized SQL queries
MCP toolsMCP serverTools from connected MCP servers

Database Connections

Database connections are managed through the /api/database-configs endpoints with secure credential storage via Vault.

Security Architecture

┌─────────────────────────────────────────────────┐
│ private_context_connections │
├─────────────────────────────────────────────────┤
│ connection_config: { │
│ "supabase_url": "https://xxx.supabase.co" │ ← NO KEY
│ } │
│ vault_secret_id: "MY_SUPABASE_KEY" │ ← REFERENCE
└─────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────┐
│ tenant_api_secrets │
├─────────────────────────────────────────────────┤
│ name: "MY_SUPABASE_KEY" │
│ encrypted_value: "iv:authTag:data" │ ← AES-256-GCM
└─────────────────────────────────────────────────┘
Credential Security

Never store passwords or API keys directly in connection_config. Use the Vault Secrets system (tenant_api_secrets) for secure credential storage with AES-256-GCM encryption.

Supported Providers

Supabase:

FieldLocationDescription
supabase_urlconnection_configSupabase project URL
supabase_anon_keyvaultAnon key (via vault_secret_id)

PostgreSQL:

FieldLocationDescription
hostconnection_configServer hostname
portconnection_configPort (default: 5432)
databaseconnection_configDatabase name
usernameconnection_configUser
passwordvaultPassword (via vault_secret_id)
sslconnection_configUse SSL (boolean)

Connection Endpoints

EndpointMethodAuthDescription
GET /api/database-configsGETJWT / API KeyList connections
GET /api/database-configs/:idGETJWT / API KeyGet connection details
POST /api/database-configsPOSTJWT onlyCreate connection
PATCH /api/database-configs/:idPATCHJWT onlyUpdate connection
DELETE /api/database-configs/:idDELETEJWT onlySoft delete
POST /api/database-configs/:id/restorePOSTJWT onlyRestore deleted

Schema Cache

EndpointMethodDescription
GET /api/database-configs/:id/schemaGETGet cached schema
POST /api/database-configs/:id/refresh-schemaPOSTRefresh schema (connects to DB)
GET /api/database-configs/:id/freshnessGETCheck if refresh is needed
Vault Integration

The refresh-schema endpoint automatically resolves vault credentials before connecting. No need to send credentials in the request.

Semantic Cache

EndpointMethodDescription
GET /api/database-configs/:id/semanticGETGet semantic cache
POST /api/database-configs/:id/refresh-semanticPOSTUpdate semantic data
POST /api/database-configs/:id/enrich-semanticPOSTAuto-enrich from schema

Connection Testing

POST /api/db/test-connection (Recommended)

Unified endpoint for testing PostgreSQL and Supabase connections.

{
"provider": "supabase",
"connection_config": {
"supabase_url": "https://xxx.supabase.co",
"supabase_anon_key": "eyJ..."
}
}

Response:

{
"success": true,
"latency_ms": 135,
"provider": "supabase",
"details": {
"host_reachable": true,
"auth_successful": true,
"database_accessible": true
}
}

MCP Tools

MCP (Model Context Protocol) tools connect agents to external business systems like ERPs, CRMs, and proprietary APIs. Each agent can have up to 10 MCP servers configured.

How It Works

  1. Configure an MCP server for your agent via the REST API or MCP Builder tools
  2. The platform connects to the server, loads available tools, and caches them for 5 minutes
  3. Tools are automatically prefixed with the server name to avoid naming collisions (e.g., erp_listar_pedidos)
  4. Authentication is resolved securely via Vault (Bearer token or API Key)

Supported Transports

TransportUse Case
httpRecommended. Streamable HTTP with automatic SSE fallback
sseLegacy SSE-only servers
stdioLocal servers via stdin/stdout

Reliability Features

FeatureDescription
Auto-recoveryServers that go down are automatically retried on the next agent request. If reconnection succeeds, status returns to active
Health checkPeriodic checks every 60s detect degraded servers and update their status
Tool call timeoutEach MCP tool call has a 30-second timeout to prevent indefinite blocking
Connection timeoutInitial connection to an MCP server times out after 10 seconds
Graceful shutdownAll MCP connections are properly closed during server shutdown

MCP Server Status

StatusBehavior
activeNormal operation — tools are loaded
errorServer had a failure — platform will attempt auto-recovery on next request
inactiveDisabled — tools are not loaded
Auto-Recovery

You don't need to manually restart MCP servers that encounter transient errors. The platform automatically retries connection on the next agent request and restores the server to active status upon success.

MCP Server Endpoints

Full CRUD for managing MCP servers linked to agents.

EndpointMethodAuthDescription
GET /api/mcp-serversGETJWT / API KeyList MCP servers (optional filters: agent_id, status)
GET /api/mcp-servers/:idGETJWT / API KeyGet MCP server details (includes config)
POST /api/mcp-serversPOSTJWT onlyRegister a new MCP server for an agent
PATCH /api/mcp-servers/:idPATCHJWT onlyUpdate MCP server configuration
DELETE /api/mcp-servers/:idDELETEJWT onlyRemove MCP server (hard delete)
POST /api/mcp-servers/:id/invalidate-cachePOSTJWT onlyInvalidate tool cache for a specific server
POST /api/mcp-servers/invalidate-cachePOSTJWT onlyInvalidate tool cache for ALL servers in the tenant

Create / Update fields:

FieldRequiredTypeDescription
agent_idCreate onlyUUIDAgent to link the server to
nameCreate onlystringServer display name
endpointCreate onlystringServer URL or stdio command
descriptionNostringOptional description
transportNohttp | sse | stdioTransport type (default: http)
auth_methodNonone | bearer | api_key | oauthAuth method (default: none)
configNoobjectAdditional config (vault_secret_id, headers, timeout, defaults_from_context)
statusUpdate onlyactive | inactiveServer status
Cache Invalidation

After updating tools on your external MCP server, call the invalidate-cache endpoint to force the platform to reload the tool list immediately instead of waiting for the 5-minute cache TTL.


api_config Authentication

API tools support authenticated requests to external APIs. The auth configuration uses prefix as the canonical field:

FieldRequiredDescription
prefixYes*Auth prefix: "Bearer", "Basic", or "" (for API key)
secret_refRecommendedReference to encrypted secret in tenant_api_secrets
typeDeprecatedLegacy field — use prefix instead. If only type is provided, it is automatically inferred to prefix

Example:

{
"editor_schema": {
"api": {
"base_url": "https://api.example.com",
"auth": {
"prefix": "Bearer",
"secret_ref": "MY_API_TOKEN"
},
"endpoints": [{ "name": "list_items", "method": "GET", "path": "/items" }]
}
}
}
auth.type is Deprecated

The auth.type field is deprecated in a previous release. If provided without prefix, the runtime infers: bearerBearer, basicBasic, api_key"". A deprecation warning will appear in validation results. Migrate to auth.prefix for clarity.


db_config Schema Contract

The db_config schema defines SQL query tools. Required fields in schema_data:

FieldRequiredDescription
connection_idYesUUID referencing private_context_connections
tool_definitionYesTool name, description, and input_schema
query_templateYesSQL with $1, $2 parameters
parameter_mappingYesArray mapping input fields to $N positions
result_mappingNoFormat (raw/table/summary), max_rows (default: 100)

Authentication Summary

Database Connections

EndpointMethodJWTAPI Key
GET /api/database-configsGETYesYes
GET /api/database-configs/:idGETYesYes
GET /api/database-configs/:id/schemaGETYesYes
GET /api/database-configs/:id/semanticGETYesYes
POST /api/database-configsPOSTYesNo
PATCH /api/database-configs/:idPATCHYesNo
DELETE /api/database-configs/:idDELETEYesNo
POST /api/database-configs/:id/refresh-schemaPOSTYesNo
POST /api/db/test-connectionPOSTYesNo

MCP Servers

EndpointMethodJWTAPI Key
GET /api/mcp-serversGETYesYes
GET /api/mcp-servers/:idGETYesYes
POST /api/mcp-serversPOSTYesNo
PATCH /api/mcp-servers/:idPATCHYesNo
DELETE /api/mcp-servers/:idDELETEYesNo
POST /api/mcp-servers/:id/invalidate-cachePOSTYesNo
POST /api/mcp-servers/invalidate-cachePOSTYesNo