Using MCP Integrations
Model Context Protocol (MCP) integrations allow your AIML application to interact with external services, APIs, or custom logic hosted elsewhere. MCP tools can be integrated directly into your LLM elements, enabling AI models to access external capabilities.
Defining MCP Tools
MCP tools are defined inline within the tools
prop of an <llm>
element. Each tool specifies its transport type and connection details:
Transport Types
AIML supports two transport types for MCP connections:
- SSE (Server-Sent Events): For real-time streaming connections
- Streamable HTTP: For standard HTTP-based MCP servers
Tool Definition Structure
Examples
Example 1: Weather Service with SSE Transport
Example 2: Database Query Service with Streamable HTTP
Example 3: Multiple MCP Tools
You can combine multiple MCP tools in a single LLM element:
Common Patterns
1. Weather Service Integration
Example of integrating a weather MCP service:
2. Combining MCP with Traditional Function Tools
Mix MCP tools with local function tools for hybrid capabilities:
Advanced Usage
Dynamic Tool Configuration
You can dynamically configure MCP tools based on runtime conditions:
Error Handling
MCP connections may fail or timeout. The runtime automatically handles connection errors and will log them to the console. Tools that fail to connect will not be available to the LLM.
Limitations
- Headers must be static (dynamic headers based on runtime state are not yet supported)