MCP Integration
This guide shows you how to integrate Model Context Protocol (MCP) servers with Solace Agent Mesh, giving your agents access to powerful external tools and data sources.Understanding MCP
MCP (Model Context Protocol) is an open protocol that:- Provides a standardized way for AI applications to access tools and data
- Connects LLMs with external systems like filesystems, databases, and APIs
- Offers a growing ecosystem of pre-built servers (Slack, GitHub, Google Drive, etc.)
- Supports both local (stdio) and remote (HTTP/SSE) connections
MCP Integration Patterns
Solace Agent Mesh supports two ways to use MCP:- MCP Tools in Agents: Add MCP server tools directly to agents
- MCP Gateway: Expose SAM agents as MCP tools to external clients
Adding MCP Tools to Agents
log:
stdout_log_level: INFO
log_file_level: DEBUG
log_file: filesystem_agent.log
!include shared_config.yaml
apps:
- name: filesystem_agent_app
app_base_path: .
app_module: solace_agent_mesh.agent.sac.app
broker:
<<: *broker_connection
app_config:
namespace: ${NAMESPACE}
supports_streaming: true
agent_name: "FileSystemAgent"
display_name: "File System Manager"
model: *planning_model
instruction: |
You can interact with the local filesystem.
Use the available tools to:
- List directory contents
- Read file contents
- Create and edit files
- Move and delete files
Always confirm actions before making destructive changes.
tools:
# MCP filesystem server
- tool_type: mcp
connection_params:
type: stdio
command: "npx"
args:
- "-y"
- "@modelcontextprotocol/server-filesystem"
- "/tmp/samv2" # Directory to expose
timeout: 300
# Built-in artifact management
- tool_type: builtin-group
group_name: "artifact_management"
session_service:
type: "memory"
default_behavior: "PERSISTENT"
artifact_service:
type: "filesystem"
base_path: "/tmp/samv2"
artifact_scope: "namespace"
artifact_handling_mode: "reference"
enable_embed_resolution: true
enable_artifact_content_instruction: true
agent_card:
description: "Manages local filesystem operations"
defaultInputModes: ["text"]
defaultOutputModes: ["text", "file"]
skills:
- id: "filesystem_ops"
name: "Filesystem Operations"
description: "Read, write, and manage files and directories"
examples:
- "List files in the data directory"
- "Read the contents of config.json"
- "Create a new file called report.txt"
tags: ["filesystem", "files"]
agent_card_publishing: { interval_seconds: 10 }
agent_discovery: { enabled: true }
inter_agent_communication:
allow_list: ["*"]
request_timeout_seconds: 60
Common MCP Servers
Filesystem Server
Access local files and directories:Playwright Server
Web browsing and automation:GitHub Server
GitHub API access:Slack Server
Slack API access:Remote MCP Servers (SSE)
Connect to remote MCP servers over HTTP with Server-Sent Events:web_agent.yaml
Complete Example: Web Research Agent
Here’s a complete agent that combines multiple MCP servers for web research:web_research_agent.yaml
Using Specific MCP Tools
If you only want specific tools from an MCP server:MCP Gateway: Expose SAM Agents via MCP
You can also expose your SAM agents as MCP tools to external MCP clients:log:
stdout_log_level: INFO
log_file_level: DEBUG
log_file: mcp_gateway.log
!include shared_config.yaml
apps:
- name: mcp_gateway_app
app_base_path: .
app_module: solace_agent_mesh.gateway.generic.app
broker:
<<: *broker_connection
app_config:
namespace: ${NAMESPACE}
gateway_adapter: sam_mcp_server_gateway_adapter.McpAdapter
adapter_config:
# MCP server identity
mcp_server_name: "SAM MCP Gateway"
mcp_server_description: "Access to Solace Agent Mesh agents via MCP"
# Transport: "http" or "stdio"
transport: http
host: "localhost"
port: 8090
# Authentication
default_user_identity: "mcp_user"
# Streaming
stream_responses: true
task_timeout_seconds: 300
# File handling
inline_image_max_bytes: 5242880 # 5MB
inline_text_max_bytes: 1048576 # 1MB
enable_artifact_resources: true
# Tool filtering (optional)
include_tools: [] # Empty = include all
exclude_tools:
- ".*_debug" # Exclude debug tools
artifact_service:
type: "filesystem"
base_path: "/tmp/samv2"
artifact_scope: "namespace"
default_user_identity: "mcp_user"
system_purpose: |
Provide access to SAM agents via MCP protocol.
response_format: |
Responses should be clear and include all relevant artifacts.
Advanced MCP Configuration
Environment Variables
Pass environment variables to MCP servers:Custom Timeouts
Adjust timeouts for slow MCP servers:Docker-based MCP Servers
Run MCP servers in Docker containers:Troubleshooting
Debug MCP Connections
Enable detailed logging:Best Practices
MCP Resources
Official MCP Servers
- Filesystem: Local file access
- Playwright: Web browsing and automation
- GitHub: GitHub API integration
- GitLab: GitLab API integration
- Slack: Slack API integration
- Google Drive: Google Drive access
- PostgreSQL: Database queries
- Fetch: HTTP requests
Community MCP Servers
Explore the MCP ecosystem:Building Custom MCP Servers
Create your own MCP servers:Next Steps
- Creating Custom Agents - Build agents with MCP tools
- Creating Custom Tools - Complement MCP with Python tools
- Building Gateways - Create MCP-enabled gateways
- Workflow Development - Orchestrate MCP-enabled agents
Real-World Examples
Check out production MCP integrations:examples/agents/a2a_mcp_example.yaml- Multiple MCP servers in one agentexamples/agents/remote-mcp/- Remote MCP server examplesexamples/gateways/mcp_gateway_example.yaml- MCP gateway configuration