Tool Integration
Register MCP tools, configure tool sets, and grant tool access
Builder/Admin Guide: Tool Integration
This guide covers how to register MCP (Model Context Protocol) tools, grant them to agents, and monitor their usage. It is intended for builders who create tools and grant them to agents, and admins who manage tool security and access policies.
Where to manage tools: Agent Studio > Tools (
http://localhost:3001/studio/tools).
Table of Contents
- What Are MCP Tools?
- The MCP Gateway (L5)
- The MCP Tool Registry
- Tool Structure
- Registering a New MCP Tool
- Granting Tools to Agents
- Tool Signing with Sigstore
- Tool Grant Enforcement at Runtime
- Monitoring Tool Usage
- Built-in Mock Tools
- Building Custom MCP Tools
- Common Tool Integration Patterns
- Troubleshooting Tool Issues
What Are MCP Tools?
MCP (Model Context Protocol) tools are external capabilities that agents can invoke to interact with systems, services, and data sources. Tools are the bridge between an agent's reasoning (LLM-powered) and the real world (APIs, databases, services).
Examples of what tools do:
- Search a knowledge base for relevant documents.
- Create a support ticket in Jira.
- Send an email or Slack message.
- Query a database.
- Scrape a web page for structured data.
- Book a calendar event.
- Execute code in a sandbox.
MCP is the universal interoperability protocol that standardizes how agents discover, authenticate with, and invoke tools regardless of whether the agent runs on the Pro-Code or n8n runtime.
The MCP Gateway (L5)
The MCP Gateway sits at Layer 5 of the platform architecture. It is the central enforcement point for all tool interactions:
Agent --> MCP Gateway --> Tool Server
|
+-- Grant Check (is this tool granted to this agent?)
+-- Rate Limit Check (has the agent exceeded its rate limit?)
+-- Time Window Check (is the tool available at this time?)
+-- HITL Check (does this invocation require human approval?)
+-- Audit Log (record the decision and invocation)
Gateway Responsibilities
| Function | Description |
|---|---|
| Tool Routing | Routes tool invocations to the correct MCP server endpoint. |
| Authentication | Authenticates the agent's identity (SPIFFE) before allowing tool access. |
| Authorization | Checks the agent's tool grants before forwarding the request. |
| Rate Limiting | Enforces per-tool, per-agent rate limits (stored in Redis). |
| HITL Triggering | Pauses execution and creates an approval request when requireApproval: true. |
| Audit Logging | Records every tool invocation decision (allow/deny) in the decision audit log. |
The MCP Tool Registry
The Tool Registry is the catalog of all available tools on the platform. It is accessible in Agent Studio at /studio/tools.
Browsing the Registry
The Tools page displays all registered tools with:
- Tool name and description -- What the tool does.
- MCP Endpoint -- The tool's server address (e.g.,
mcp://tools.internal/kb-search). - Runtime compatibility -- Which runtimes can use this tool (
procode,n8n, orboth). - Risk level --
low,medium,high, orcritical(color-coded badge). - Category --
read-only,write,external-comms,financial, ordestructive. - Usage count -- How many times the tool has been invoked.
- Granted agents -- Which agents currently have access to this tool.
Filtering Tools
You can filter the tool registry by:
- Risk level -- Show only tools of a specific risk level.
- Category -- Filter by tool category.
- Runtime -- Show tools compatible with a specific runtime.
- Search -- Search by tool name or description.
Tool Structure
Every MCP tool has the following attributes:
interface Tool {
id: string; // Unique tool identifier (e.g., 'tool-1')
name: string; // Display name (e.g., 'Knowledge Base Search')
description: string; // What the tool does
mcpEndpoint: string; // MCP server endpoint (e.g., 'mcp://tools.internal/kb-search')
runtime: 'procode' | 'n8n' | 'both'; // Compatible runtimes
riskLevel: 'low' | 'medium' | 'high' | 'critical';
category: 'read-only' | 'write' | 'external-comms' | 'financial' | 'destructive';
inputSchema: object; // JSON Schema defining expected input
outputSchema: object; // JSON Schema defining expected output
usageCount: number; // Total invocation count
grantedAgentIds: string[]; // Agents that currently have access
}
Input and Output Schemas
Tools define their interface using JSON Schema. The input schema specifies what parameters the agent must provide when invoking the tool, and the output schema describes the structure of the tool's response.
Example Input Schema (Knowledge Base Search):
{
"type": "object",
"properties": {
"query": { "type": "string" },
"maxResults": { "type": "number", "default": 10 },
"filters": {
"type": "object",
"properties": {
"category": { "type": "string" },
"dateRange": { "type": "string" }
}
}
},
"required": ["query"]
}
Example Output Schema (Knowledge Base Search):
{
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": { "type": "string" },
"content": { "type": "string" },
"score": { "type": "number" }
}
}
},
"totalCount": { "type": "number" }
}
}
Registering a New MCP Tool
Step-by-Step Registration
- Navigate to Studio > Tools (
/studio/tools). - Click Register Tool (or equivalent create button).
- Fill in the tool details:
| Field | Required | Description | Example |
|---|---|---|---|
| Name | Yes | Display name for the tool. | Jira Ticket Creator |
| Description | Yes | Clear description of what the tool does, its data access, and any side effects. | Creates Jira tickets with summary, description, priority, and assignee. Writes to the Jira project board. |
| MCP Endpoint | Yes | The endpoint where the tool's MCP server is running. | mcp://tools.internal/jira-create |
| Runtime | Yes | Which runtimes can use this tool. | both |
| Risk Level | Yes | The tool's risk classification. | medium |
| Category | Yes | The type of operation the tool performs. | write |
| Input Schema | Recommended | JSON Schema defining the tool's input parameters. | See example above. |
| Output Schema | Recommended | JSON Schema defining the tool's response structure. | See example above. |
- Click Save to register the tool.
Choosing the Right Risk Level
| Risk Level | Badge | Criteria | Examples |
|---|---|---|---|
| Low | Green | Read-only access. No side effects. No external communication. No sensitive data. | Knowledge base search, web scraper, calendar lookup. |
| Medium | Yellow | Writes to internal systems. Creates records. Sends internal notifications. | Create ticket, database query (write), Slack notification, GitHub PR creation. |
| High | Red | External communications. Accesses sensitive data. Modifies important records. | Send email, access financial records, modify user accounts. |
| Critical | Black | Destructive operations. Irreversible actions. Accesses highly sensitive data. | Delete records, financial transactions, production system modifications. |
Choosing the Right Category
| Category | Description | Typical Risk |
|---|---|---|
read-only | Only reads data. No writes, no side effects. | Low |
write | Creates or modifies records in internal systems. | Medium |
external-comms | Sends communications to external parties (email, SMS, chat). | High |
financial | Involves financial transactions, payments, or monetary data. | High--Critical |
destructive | Permanently deletes data or makes irreversible changes. | Critical |
Granting Tools to Agents
Tools are not automatically available to agents. Each agent must be explicitly granted access to the tools it needs. This is the Agent -> Tool dimension of access control (Dimension 2).
Granting from the Agent Designer
- Open the agent in the Agent Designer (
/studio/agents/[id]). - Navigate to the Tools tab.
- Browse or search the tool catalog.
- Check the tools you want to grant to this agent.
- For each granted tool, configure conditions:
| Condition | Field | Description | Example |
|---|---|---|---|
| Permissions | permissions | Granular access: read, write, execute. | ['read', 'execute'] |
| Rate Limit | maxCallsPerHour | Maximum invocations per hour for this tool. | 100 |
| HITL Approval | requireApproval | Require human approval for each invocation. | true |
| Time Window | timeWindow | Restrict tool usage to specific hours. | { start: '09:00', end: '17:00' } |
-
Set the Dynamic Discovery toggle:
false(default, recommended): The agent can only use tools explicitly listed in its grants.true: The agent can discover and request access to tools not in its grants. Use with caution.
-
Set Max Tool Calls Per Execution (circuit breaker): Limits the total number of tool calls an agent can make in a single execution. Default:
20.
Granting from the Tool Page
You can also grant tools from the tool's detail page:
- Navigate to Studio > Tools (
/studio/tools). - Click on a tool.
- View the Granted Agents section.
- Click Grant to Agent and select the target agent.
- Configure permissions and conditions.
Bulk Granting
For tools that should be available to many agents, use the bulk grant feature:
- Navigate to the tool's detail page.
- Click Bulk Grant.
- Select agents by tag or capability match.
- The tool is granted to all matching agents with default permissions.
Tool Grant Configuration Example
{
"toolGrants": {
"tools": [
{
"toolId": "tool-1",
"permissions": ["read", "execute"],
"conditions": {
"maxCallsPerHour": 100
}
},
{
"toolId": "tool-3",
"permissions": ["execute"],
"conditions": {
"requireApproval": true,
"timeWindow": { "start": "09:00", "end": "17:00" }
}
},
{
"toolId": "tool-4",
"permissions": ["read", "write", "execute"],
"conditions": {
"maxCallsPerHour": 500
}
}
],
"dynamicDiscovery": false,
"maxToolCallsPerExecution": 20
}
}
This configuration means:
- Tool 1 (Knowledge Base Search): Read and execute. Up to 100 calls per hour. No approval needed.
- Tool 3 (Send Email): Execute only. Each invocation requires human approval. Only available during business hours (09:00--17:00).
- Tool 4 (SQL Query): Full access (read, write, execute). Up to 500 calls per hour. No approval needed.
- The agent cannot discover tools outside this list.
- The agent is limited to 20 total tool calls per execution.
Tool Signing with Sigstore
All tools deployed in production are signed using Sigstore to ensure integrity and provenance.
What Sigstore Provides
- Integrity verification -- Ensures the tool has not been tampered with since it was signed.
- Provenance tracking -- Records who built and deployed the tool, and when.
- Transparency log -- All signatures are recorded in a public transparency log for auditability.
How It Works
- When a tool is deployed, its artifact (code, configuration, container image) is signed using Sigstore's keyless signing.
- The signature is stored alongside the tool in the registry.
- At runtime, the MCP Gateway verifies the tool's signature before routing requests to it.
- If verification fails, the tool invocation is blocked and an alert is raised.
For Tool Developers
You do not need to manually sign tools. The deployment pipeline handles signing automatically. You can verify a tool's signature status in the tool's detail page in the registry.
Tool Grant Enforcement at Runtime
How Tool Calls Are Checked
When an agent invokes a tool, the following checks occur at the MCP Gateway:
1. Agent calls mcp.tool.invoke(toolId, input)
2. MCP Gateway receives the request
3. Grant Check:
- Is this toolId in the agent's tool grants? If NO --> 403 Forbidden
- Does the agent have the required permission (read/write/execute)? If NO --> 403 Forbidden
4. Condition Checks (if conditions are configured):
- Rate Limit: Has the agent exceeded maxCallsPerHour? Check Redis counter.
If YES --> 429 Too Many Requests
- Time Window: Is the current time within the allowed window?
If NO --> 403 Forbidden (outside allowed hours)
- HITL Approval: Is requireApproval set to true?
If YES --> Pause execution, create approval request, wait for decision
5. If all checks pass --> Forward request to tool MCP server
6. Audit log entry created (whether allowed or denied)
What Happens When a Grant Check Fails
When a tool call is denied, the MCP Gateway returns an error to the agent:
- 403 Forbidden -- The tool is not granted to this agent, the agent lacks the required permission, or the time window restriction is violated. The tool is effectively invisible to the agent.
- 429 Too Many Requests -- The agent has exceeded the configured rate limit for this tool. The agent should wait before trying again.
The denial is recorded in the audit log and appears as a yellow span in the Trace Explorer.
Rate Limit Enforcement
Rate limits are tracked in Redis using sliding window counters. Each unique (agentId, toolId) pair has its own counter that resets hourly.
When an agent approaches its rate limit:
- The first 80% of calls proceed normally.
- At 80--100% of the limit, warning spans appear in the trace.
- At 100%, subsequent calls are rejected with
429until the window resets.
Monitoring Tool Usage
Trace Explorer
The Trace Explorer in Studio (/studio/traces) shows tool invocations as spans within execution traces.
For each tool call span, you can see:
- Tool name -- Which tool was invoked.
- Input -- What parameters were sent to the tool.
- Output -- What the tool returned.
- Duration -- How long the tool call took (in milliseconds).
- Status --
successorerror. - Grant check result -- Whether the grant check passed or failed (yellow highlight for denials).
Filtering Traces by Tool Usage
Use the Trace Explorer filters to find traces involving specific tools:
- Filter by agent ID to see all tool usage by a specific agent.
- Filter by status to find failed tool calls.
- Filter by minimum latency to find slow tool calls.
- Filter by minimum cost to find expensive operations.
Admin Security Center
The Admin Console > Security page (/admin/security) includes an Agent -> Tool Grants tab that provides a platform-wide view of:
- All tool grants across all agents.
- Tools with the most grants.
- Agents with the most tool access.
- Recent grant changes (who granted what, when).
- Tools with high-risk grants that lack HITL protection.
Built-in Mock Tools
The platform includes 10 pre-registered mock tools for development and testing. These tools return simulated data and are available in the Tool Registry when running in mock mode.
Tool Inventory
| ID | Name | Risk Level | Category | Runtime | Description |
|---|---|---|---|---|---|
tool-1 | Knowledge Base Search | Low | read-only | Both | Searches the knowledge base for articles, FAQs, and documentation. |
tool-2 | Create Ticket | Medium | write | Both | Creates support tickets with assignee, priority, and category. |
tool-3 | Send Email | High | external-comms | Both | Sends emails with subject, body, and optional attachments via SMTP. |
tool-4 | Execute SQL Query | Medium | write | Pro-Code | Executes parameterized SQL queries against the analytics database. |
tool-5 | Slack Notification | Medium | external-comms | Both | Sends Slack channel notifications with rich formatting. |
tool-6 | GitHub Create PR | Medium | write | Pro-Code | Creates GitHub pull requests with branch, title, and reviewers. |
tool-7 | OCR Document Parser | Low | read-only | n8n | Extracts text and structured data from scanned documents and images. |
tool-8 | Delete Records | Critical | destructive | Pro-Code | Permanently deletes database records. Requires confirmation token. |
tool-9 | Web Scraper | Low | read-only | n8n | Scrapes and extracts structured data from web pages. |
tool-10 | Calendar Booking | Low | write | Both | Books meetings and calendar events with attendees and agenda. |
Testing with Mock Tools
In mock mode, tool invocations return simulated success responses. You can use the tool test feature to verify input/output schemas:
- Navigate to the tool's detail page.
- Click Test Tool.
- Provide sample input parameters.
- View the simulated response (success, result, duration).
Building Custom MCP Tools
MCP Server Specification
A custom MCP tool requires an MCP-compliant server that implements the tool's interface. The server must:
- Accept invocations via the MCP protocol at the registered endpoint.
- Validate input against the tool's input schema.
- Execute the operation (database query, API call, etc.).
- Return output conforming to the tool's output schema.
- Handle errors gracefully with structured error responses.
Server Endpoint Format
MCP endpoints follow the format: mcp://<host>/<tool-path>
Examples:
mcp://tools.internal/kb-searchmcp://tools.internal/email-sendermcp://tools.external/weather-api
Input/Output Schema Design
Design your schemas to be:
- Strict: Use
requiredto mark mandatory parameters. - Documented: Add
descriptionto each property for agent understanding. - Typed: Use specific types (
string,number,boolean,array,object) rather than generic types. - Bounded: Use
enumfor constrained values,minimum/maximumfor numbers, andmaxLengthfor strings. - Defaulted: Provide sensible defaults where possible.
Example: Well-Designed Input Schema
{
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query to execute against the knowledge base.",
"minLength": 1,
"maxLength": 500
},
"maxResults": {
"type": "number",
"description": "Maximum number of results to return.",
"default": 10,
"minimum": 1,
"maximum": 100
},
"filters": {
"type": "object",
"description": "Optional filters to narrow search results.",
"properties": {
"category": {
"type": "string",
"description": "Document category to filter by.",
"enum": ["faq", "policy", "procedure", "technical"]
},
"dateRange": {
"type": "string",
"description": "Date range filter.",
"enum": ["last-week", "last-month", "last-quarter", "all-time"]
}
}
}
},
"required": ["query"]
}
Authentication Requirements
Tools that access external services may require authentication. The platform supports:
- API Key -- Stored in Vault and injected by the MCP Gateway at invocation time.
- OAuth 2.0 -- Token exchange handled by the MCP Gateway.
- Mutual TLS -- Using the agent's SPIFFE identity for service-to-service authentication.
Credentials are never exposed to the agent. The MCP Gateway injects authentication headers/tokens when forwarding requests to the tool server.
Testing with the Playground
Before deploying a tool to production:
- Register the tool in the Tool Registry.
- Grant it to a test agent.
- Open the Playground (
/studio/playground). - Select the test agent.
- Send messages that should trigger the tool.
- Review the execution trace to verify:
- The tool was invoked with correct parameters.
- The tool returned the expected output.
- The agent used the tool output appropriately in its response.
Common Tool Integration Patterns
Pattern 1: Read-Only Information Retrieval
Use case: Agent needs to search for and retrieve information.
{
"toolId": "tool-kb-search",
"permissions": ["read", "execute"],
"conditions": {
"maxCallsPerHour": 200
}
}
Characteristics:
- Low risk. No side effects.
- High rate limit (frequent searches are expected).
- No HITL required.
Pattern 2: Supervised Write Operations
Use case: Agent creates records in internal systems with human oversight.
{
"toolId": "tool-create-ticket",
"permissions": ["read", "write", "execute"],
"conditions": {
"requireApproval": true,
"maxCallsPerHour": 50
}
}
Characteristics:
- Medium risk. Creates records.
- HITL approval for each write operation.
- Moderate rate limit.
Pattern 3: Time-Restricted External Communications
Use case: Agent sends emails but only during business hours.
{
"toolId": "tool-send-email",
"permissions": ["execute"],
"conditions": {
"requireApproval": true,
"timeWindow": { "start": "09:00", "end": "17:00" },
"maxCallsPerHour": 10
}
}
Characteristics:
- High risk. External communication.
- HITL approval for every send.
- Business hours only (prevents automated out-of-hours emails).
- Low rate limit (emails should be infrequent).
Pattern 4: High-Throughput Data Processing
Use case: Agent processes data at scale with minimal human intervention.
{
"toolId": "tool-db-query",
"permissions": ["read", "write", "execute"],
"conditions": {
"maxCallsPerHour": 500
}
}
Characteristics:
- Medium risk. Database access.
- No HITL (high throughput requires automation).
- High rate limit.
- Rely on guardrails (sql-injection-check, data-leak-prevention) rather than per-call approval.
Pattern 5: Critical Operations with Full Safeguards
Use case: Agent performs destructive operations with maximum oversight.
{
"toolId": "tool-delete-records",
"permissions": ["execute"],
"conditions": {
"requireApproval": true,
"maxCallsPerHour": 5,
"timeWindow": { "start": "10:00", "end": "16:00" }
}
}
Characteristics:
- Critical risk. Irreversible deletion.
- HITL approval required for every invocation.
- Very low rate limit (5 per hour).
- Restricted to business hours (with buffer on both ends).
- The tool itself requires a confirmation token (defense in depth).
Troubleshooting Tool Issues
Tool Call Returns 403 Forbidden
Cause: The agent does not have a grant for this tool, or it lacks the required permission level.
Resolution:
- Check the agent's tool grants in the Agent Designer > Tools tab.
- Verify the tool ID matches what the agent is trying to invoke.
- Ensure the required permissions (
read,write,execute) are granted. - Check the Trace Explorer for the specific denial reason.
Tool Call Returns 429 Too Many Requests
Cause: The agent has exceeded the maxCallsPerHour rate limit for this tool.
Resolution:
- Check the current rate limit in the tool grant conditions.
- If the limit is too low, increase
maxCallsPerHourin the Tools tab. - If the agent is legitimately making too many calls, consider optimizing the agent's prompt to reduce unnecessary tool invocations.
Tool Call Blocked by Time Window
Cause: The tool has a timeWindow condition and the current time is outside the allowed window.
Resolution:
- Check the time window configuration in the tool grant.
- Verify the time zone being used (platform default or agent-specific).
- Adjust the time window if business hours need to be extended.
Tool Call Pending HITL Approval
Cause: The tool has requireApproval: true and the invocation is waiting for human approval.
Resolution:
- Check the Approvals page (
/portal/approvals) for pending requests. - Approve or reject the request.
- If approvals are taking too long, check the escalation chain configuration.
- Consider whether HITL is truly needed for this tool, or if the risk level allows automatic execution.
Tool Returns Unexpected Output
Cause: The tool server returned data that does not match the expected output schema.
Resolution:
- Check the tool's output schema in the Tool Registry.
- Review the actual tool response in the Trace Explorer.
- If the schema is wrong, update it in the Tool Registry.
- If the tool server is returning incorrect data, debug the tool server.
Tool Server Unreachable
Cause: The MCP endpoint is not responding.
Resolution:
- Verify the tool's MCP endpoint URL in the registry.
- Check that the tool server is running and accessible from the MCP Gateway.
- Review network connectivity and firewall rules.
- Check the tool server's logs for errors.
- If the tool server is down, the agent will receive a timeout error.
Agent Cannot Discover a Tool
Cause: The tool is not in the agent's grant list and dynamicDiscovery is false (the default).
Resolution:
- This is expected behavior. Tools must be explicitly granted.
- To grant the tool, go to the Agent Designer > Tools tab and add it.
- Only enable
dynamicDiscovery: trueif you specifically want the agent to find tools on its own (not recommended for production).
Related Documentation
- Builder Access Control Guide -- Full access control model including tool grants (Dimension 2)
- Registering Agents Guide -- How to create agents that use tools
- Getting Started Guide -- Initial setup and environment configuration
- Troubleshooting Guide -- Additional troubleshooting for common issues
- Architecture Reference -- Platform layer details (L5 MCP Gateway)
- Access Control Reference -- Technical access control specification