Skip to main content

MCP Server Tool

The MCP Server tool enables agents to connect to remote Model Context Protocol (MCP) servers, extending their capabilities with external services, tools, and data sources through a standardized protocol.
MCP Server Tool Configuration
This tool has Preview status, meaning it’s nearly ready for production with potential minor adjustments based on user feedback.

Overview

The Model Context Protocol (MCP) is an open standard that enables seamless integration between AI agents and external tools. The MCP Server tool allows your PLai agents to:

Standardized Integration

Connect to any MCP-compliant server using a unified protocol

Extended Capabilities

Access specialized tools and services beyond built-in functionality

Secure Authentication

Support for OAuth 2.0 and token-based authentication methods

Scalable Architecture

Distributed tool architecture for enterprise deployments

What is MCP?

The Model Context Protocol provides:
  • Standardized Communication: Consistent API for tool interactions
  • Resource Management: Organized access to external resources
  • Tool Discovery: Automatic discovery of available capabilities
  • Security: Built-in authentication and authorization
  • Extensibility: Easy addition of new tools and services

Configuration Parameters

server_url
input
required
The URL of the MCP server
Example: https://api.example.com/mcp
Format: Must be a valid HTTPS URL
Note: HTTP URLs are not supported for security reasons
auth_type
select
required
Authentication method to use with the MCP server
Options:
  • oauth - OAuth 2.0 authentication flow
  • token - Simple token-based authentication

OAuth Authentication Parameters

access_token
password
OAuth access token for authentication
Example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
Condition: Only required when auth_type is set to oauth
Security: Stored securely and never logged
token_expiry
input
Token expiry timestamp or ‘never’ for long-lived tokens
Example: 2024-12-31T23:59:59Z or never
Default: never
Condition: Only shown when auth_type is set to oauth
Format: ISO 8601 timestamp or literal never

Token Authentication Parameters

api_token
password
API token for authentication
Example: mcp_token_abc123xyz789
Condition: Only required when auth_type is set to token
Security: Stored securely and never logged
header_name
input
HTTP header name for the token
Example: X-API-Token, Authorization, X-MCP-Token
Default: X-API-Token
Condition: Only shown when auth_type is set to token
token_prefix
input
Token prefix for the authorization header
Example: Bearer, Token, MCP
Default: Bearer
Condition: Only shown when auth_type is set to token
Result: Header will be formatted as {prefix} {token}

Setup Instructions

1

Prepare MCP Server

Ensure you have access to an MCP-compliant server with proper credentials
2

Navigate to Tools

Go to the Tools section in your project dashboard
3

Create MCP Server Tool

Click Create Tool and select MCP Server
4

Configure Server URL

Enter the HTTPS URL of your MCP server
5

Select Authentication Method

Choose between OAuth 2.0 or token-based authentication
6

Configure Authentication

Provide the required authentication credentials based on your selected method
7

Test Connection

Use the test button to verify connectivity and authentication
8

Add to Agent

Assign this tool to your agents in agent settings

Authentication Methods

OAuth 2.0 Authentication

OAuth provides secure, token-based authentication with automatic refresh capabilities:
{
  "server_url": "https://api.example.com/mcp",
  "auth_type": "oauth",
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_expiry": "2024-12-31T23:59:59Z"
}

Token Authentication

Simple token-based authentication for straightforward API access:
{
  "server_url": "https://api.example.com/mcp",
  "auth_type": "token",
  "api_token": "mcp_token_abc123xyz789",
  "header_name": "X-API-Token",
  "token_prefix": "Bearer"
}

MCP Server Examples

Database Query Server

Connect to a database through an MCP server:
{
  "server_url": "https://db-mcp.company.com/mcp",
  "auth_type": "oauth",
  "access_token": "{{oauth_token}}",
  "token_expiry": "2024-12-31T23:59:59Z"
}
Capabilities:
  • Execute SQL queries
  • Retrieve table schemas
  • Perform data analysis
  • Generate reports

File Processing Server

Process documents and files through MCP:
{
  "server_url": "https://files-mcp.company.com/mcp",
  "auth_type": "token",
  "api_token": "{{file_processor_token}}",
  "header_name": "Authorization",
  "token_prefix": "Bearer"
}
Capabilities:
  • PDF text extraction
  • Image analysis
  • Document conversion
  • Metadata extraction

Business Logic Server

Access custom business logic and calculations:
{
  "server_url": "https://business-logic.company.com/mcp",
  "auth_type": "token",
  "api_token": "{{business_token}}",
  "header_name": "X-Business-Token",
  "token_prefix": "BL"
}
Capabilities:
  • Pricing calculations
  • Compliance checks
  • Workflow automation
  • Custom validations

MCP Protocol Features

Resource Management

MCP servers can provide various types of resources:

Tool Discovery

MCP servers automatically expose available tools:
  1. Connection Establishment: Agent connects to MCP server
  2. Capability Discovery: Server provides list of available tools
  3. Tool Registration: Tools are registered with the agent
  4. Dynamic Invocation: Agent can call tools as needed

Error Handling

MCP protocol includes comprehensive error handling:
  • Connection Errors: Network and connectivity issues
  • Authentication Errors: Invalid credentials or expired tokens
  • Authorization Errors: Insufficient permissions
  • Tool Errors: Issues with specific tool execution
  • Protocol Errors: MCP-specific communication problems

Best Practices

Security

Token Security: Never expose MCP tokens in logs or debug output. Always use secure storage for credentials.
  • HTTPS Only: Always use HTTPS for MCP server connections
  • Token Rotation: Regularly rotate authentication tokens
  • Least Privilege: Grant minimum necessary permissions
  • Audit Logging: Monitor MCP server access and usage
  • Network Security: Use VPNs or private networks when possible

Performance

Connection Pooling: MCP connections are pooled for better performance. Multiple agents can share the same MCP server connection.
  • Caching: Cache MCP responses when appropriate
  • Connection Management: Reuse connections for multiple requests
  • Timeout Configuration: Set appropriate timeouts for MCP calls
  • Load Balancing: Distribute requests across multiple MCP servers
  • Monitoring: Track MCP server performance and availability

Development

  • Testing: Use mock MCP servers for development and testing
  • Documentation: Document custom MCP server capabilities
  • Versioning: Version MCP server APIs for backward compatibility
  • Monitoring: Implement health checks for MCP servers
  • Logging: Log MCP interactions for debugging and analysis

Troubleshooting

Common Issues

Symptoms: Unable to connect to MCP serverSolutions:
  • Verify server URL is correct and accessible
  • Check network connectivity and firewall rules
  • Confirm MCP server is running and healthy
  • Test connection from PLai infrastructure
Symptoms: 401 or 403 errors during connectionSolutions:
  • Verify authentication credentials are correct
  • Check token expiry dates
  • Confirm authentication method matches server expectations
  • Review server-side authentication logs
Symptoms: Specific tools not appearing or failingSolutions:
  • Check MCP server tool registration
  • Verify tool permissions and access rights
  • Review server-side tool implementation
  • Test tool functionality directly on server
Symptoms: Long response times from MCP serverSolutions:
  • Check server performance and resource usage
  • Review network latency between PLai and server
  • Implement caching strategies
  • Optimize tool implementations on server side

Debug Mode

Enable detailed logging for troubleshooting:
{
  "debug": true,
  "log_level": "debug",
  "trace_requests": true
}

MCP Server Development

Creating Custom MCP Servers

If you need custom functionality, you can develop your own MCP server:
const { MCPServer } = require('@modelcontextprotocol/server');

const server = new MCPServer({
  name: 'custom-mcp-server',
  version: '1.0.0'
});

// Register tools
server.registerTool('calculator', {
  description: 'Perform mathematical calculations',
  parameters: {
    expression: { type: 'string', required: true }
  }
}, async (params) => {
  // Tool implementation
  return eval(params.expression);
});

server.start(3000);

MCP Server Requirements

  • Protocol Compliance: Must implement MCP specification
  • HTTPS Support: Secure communication required
  • Authentication: Support OAuth or token-based auth
  • Error Handling: Proper error responses and codes
  • Documentation: Tool and resource documentation

Next Steps