/ examples / gateways / mcp_gateway_example.yaml
mcp_gateway_example.yaml
  1  # MCP Gateway Example Configuration
  2  # This gateway exposes SAM agents as MCP (Model Context Protocol) tools.
  3  #
  4  # This allows any MCP-compatible client (like Claude Desktop, IDEs, etc.) to interact
  5  # with SAM agents through the standardized MCP interface.
  6  #
  7  # Features:
  8  # - Dynamic tool registration from agent registry
  9  # - HTTP or stdio transport support
 10  # - Streaming responses to MCP clients
 11  # - Timeout protection
 12  #
 13  # Required Environment Variables:
 14  # - NAMESPACE: The A2A topic namespace (e.g., "myorg/dev")
 15  # - SOLACE_BROKER_URL: URL of the Solace broker (e.g., "ws://localhost:8008")
 16  # - SOLACE_BROKER_USERNAME: Username for the Solace broker
 17  # - SOLACE_BROKER_PASSWORD: Password for the Solace broker
 18  # - SOLACE_BROKER_VPN: VPN name for the Solace broker
 19  #
 20  # Dependencies:
 21  # First install the sam-mcp-server-gateway-adapter plugin
 22  # > sam plugin install sam-mcp-server-gateway-adapter
 23  #
 24  # Usage:
 25  #   sam run examples/gateways/mcp_gateway_example.yaml
 26  #
 27  # Then connect an MCP client to: http://localhost:8000/mcp
 28  
 29  log:
 30    stdout_log_level: INFO
 31    log_file_level: DEBUG
 32    log_file: mcp_gateway.log
 33  
 34  # Shared SAM config
 35  !include ../shared_config.yaml
 36  
 37  apps:
 38    - name: mcp_gateway_app
 39      app_base_path: .
 40      app_module: solace_agent_mesh.gateway.generic.app
 41  
 42      broker:
 43        <<: *broker_connection
 44  
 45      app_config:
 46        # --- Required ---
 47        namespace: ${NAMESPACE}
 48  
 49        # --- Generic Adapter Framework Config ---
 50        gateway_adapter: sam_mcp_server_gateway_adapter.McpAdapter
 51  
 52        # --- MCP Adapter Config ---
 53        adapter_config:
 54          # MCP server identity
 55          mcp_server_name: "SAM MCP Gateway"
 56          mcp_server_description: "Access to Solace Agent Mesh agents via MCP"
 57  
 58          # Session and execution behavior:
 59          # - Each MCP client connection creates a persistent SAM session (based on client_id)
 60          # - All tool calls from the same connection share this session
 61          # - Tool calls use RUN_BASED execution (no persistent chat history between calls)
 62          # - Artifacts created in any tool call persist in the session and are accessible
 63          #   in subsequent tool calls via MCP resources
 64          # - Resources are never auto-cleaned (live for connection lifetime or until restart)
 65  
 66          # Transport configuration
 67          # Options: "http" or "stdio"
 68          # - http: Web-accessible MCP server for remote clients
 69          # - stdio: Local MCP server for desktop clients (like Claude Desktop)
 70          transport: http
 71  
 72          # HTTP transport settings (only used if transport = "http")
 73          host: "localhost"  # Listen on all interfaces
 74          port: 8090       # MCP server port
 75  
 76          # Authentication
 77          # Default user identity for MCP requests
 78          # In production, you might want to implement token-based auth
 79          default_user_identity: "sam_dev_user"
 80  
 81          # Streaming configuration
 82          # Enable real-time streaming of agent responses back to MCP client
 83          stream_responses: true
 84  
 85          # Timeout configuration
 86          # How long to wait for agent task completion before timing out (in seconds)
 87          task_timeout_seconds: 300  # 5 minutes default
 88  
 89          # File handling configuration
 90          # These settings control when files are returned inline vs as resource links
 91          inline_image_max_bytes: 5242880      # 5MB - images larger than this become resource links
 92          inline_audio_max_bytes: 10485760     # 10MB - audio files larger than this become resource links
 93          inline_text_max_bytes: 1048576       # 1MB - text files larger than this become resource links
 94          inline_binary_max_bytes: 524288      # 512KB - binary files larger than this become resource links
 95  
 96          # Artifact resource configuration
 97          # Enable exposing artifacts as MCP resources for separate download
 98          enable_artifact_resources: true
 99          resource_uri_prefix: "artifact"      # URI format: artifact://session_id/filename
100  
101          # Tool filtering configuration
102          # Control which agent tools are exposed through the MCP server
103          # Filters check against agent name, skill name, AND final tool name
104          # Supports both regex patterns and exact string matches (auto-detected)
105          #
106          # Priority order (highest to lowest):
107          #   1. Exclude exact match - if any exclude pattern matches exactly, reject
108          #   2. Include exact match - if any include pattern matches exactly, accept
109          #   3. Exclude regex match - if any exclude pattern matches as regex, reject
110          #   4. Include regex match - if any include pattern matches as regex, accept
111          #   5. Default - if include_tools is empty, accept all; otherwise reject
112          #
113          # Examples:
114          #   include_tools:
115          #     - ".*"                 # Include all tools that exclude filters allows
116          #     - "data_.*"           # Regex: include tools starting with "data_"
117          #     - "fetch_user_info"   # Exact: include this specific tool
118          #   exclude_tools:
119          #     - ".*_debug"          # Regex: exclude tools ending with "_debug"
120          #     - "TestAgent"         # Exact: exclude all tools from agent "TestAgent"
121          #     - "test_tool"         # Exact: exclude this specific tool
122          #
123          include_tools: []  # Empty = include all tools (default)
124          exclude_tools: []  # Empty = no exclusions (default)
125  
126        # --- Artifact Service ---
127        artifact_service:
128          type: "filesystem"
129          base_path: "/tmp/samv2"
130          artifact_scope: "namespace"
131  
132        # --- Optional with Defaults ---
133        default_user_identity: "sam_dev_user"
134  
135        # --- System Purpose ---
136        system_purpose: >
137          The system is an AI Chatbot with agentic capabilities.
138          It will use the agents available to provide information,
139          reasoning and general assistance for the users in this system.
140          **Always return useful artifacts and files that you create to the user.**
141          Provide a status update before each tool call.
142          Your external name is Agent Mesh.
143  
144        response_format: >
145          Responses should be clear, concise, and professionally toned.
146          Format responses to the user in Markdown using appropriate formatting.
147          Note that the user is not able to access the internal artifacts of the system. You
148          must return them, so if you create any files or artifacts, provide them to the user
149          via the artifact_return embed.
150  
151  # Notes on usage:
152  # ---------------
153  # 1. Agents are automatically discovered from the agent registry
154  # 2. Each agent skill becomes an MCP tool named: {agent_name}_{skill_name}
155  # 3. All tools accept a single "message" parameter (string)
156  # 4. Responses are streamed back in real-time
157  # 5. Connect MCP clients to: http://localhost:8000/mcp (for HTTP transport)
158  #
159  # Example MCP client usage (with MCP inspector CLI):
160  #   npx @modelcontextprotocol/inspector
161  # Select Streamable HTTP for the transport type and enter the following for the url: http://localhost:8090/mcp
162  #
163  # Example connecting from Claude Desktop:
164  # Add to Claude Desktop config (~/.config/claude/config.json):
165  # {
166  #   "mcpServers": {
167  #     "sam": {
168  #       "url": "http://localhost:8090/mcp",
169  #       "transport": "http"
170  #     }
171  #   }
172  # }