Connic
Connic Composer SDK

MCP Integration

Connect your agents to external MCP servers to extend their capabilities with additional tools.

Last updated

What is MCP?

Extend your agents with external tools via the Model Context Protocol

MCP servers expose tools that your agents can use alongside local tools. Configure them in your agent YAML and Connic connects to the servers and makes their tools available at runtime. All MCP tool calls are traced and visible in run details.

How MCP Works in Connic

Add mcp_servers to your agent YAML. At runtime, Connic connects to each server, discovers available tools, and exposes them to your LLM agent. The agent can call MCP tools just like local tools. Connic handles the communication.

Basic Usage

agents/docs-assistant.yaml
version: "1.0"

name: docs-assistant
type: llm
model: gemini/gemini-2.5-pro
description: "An assistant with access to library documentation via MCP"
system_prompt: |
  You are a helpful coding assistant with access to up-to-date 
  library documentation through MCP tools.

# Connect to an MCP server
mcp_servers:
  - name: context7
    url: https://mcp.context7.com/mcp

Configuration Reference

FieldTypeStatusDescription
namestringRequiredIdentifier for the MCP server. Used in logs and traces.
urlstringRequiredThe URL of the MCP server endpoint. Supports ${VAR} syntax for environment variables.
toolsstring[]OptionalList of specific tools to use from this server. If omitted, all tools are available.
headersobjectOptionalHTTP headers to send with requests. Use for authentication. Supports ${VAR} environment values and ${context.*} per-run context values.
discoverablebooleanOptionalWhen true, tools from this server are indexed for on-demand discovery instead of being loaded into the LLM context upfront. See Discoverable MCP Servers below.Default: false
bridgestringOptionalOptional Connic Bridge ID. When set, the MCP server's URL is tunneled through that bridge so private/on-prem MCP servers can be reached without exposing them publicly. Supports ${VAR} substitution. See Private MCP Servers via Bridge below.

Authentication

agents/agent.yaml
mcp_servers:
  - name: github
    url: https://mcp.example.com/github
    headers:
      Authorization: "Bearer ${GITHUB_TOKEN}"
      X-User-Id: "${context.user_id}"

Use ${VAR_NAME} syntax for secrets. Configure variables in Settings → Variables.

Tool Filtering

agents/agent.yaml
mcp_servers:
  - name: filesystem
    url: https://mcp.example.com/filesystem
    # Only allow specific tools
    tools:
      - read_file
      - list_directory

Restrict which tools are available. Useful for limiting agents to read-only operations or preventing use of dangerous tools.

Multiple Servers

agents/agent.yaml
mcp_servers:
  - name: docs
    url: https://mcp.context7.com/mcp
    
  - name: search
    url: https://mcp.example.com/search
    headers:
      X-API-Key: "${SEARCH_API_KEY}"
    
  - name: database
    url: https://mcp.internal.company.com/db
    headers:
      Authorization: "Bearer ${DB_TOKEN}"
    tools:
      - query
      - list_tables

Connect to multiple MCP servers at once. Each server's tools become available to the agent.

Private MCP Servers via Bridge

When your MCP server runs inside a private network (VPC, on-prem, behind a corporate firewall) and is not reachable from the public internet, set the bridge field to a Connic Bridge ID. The agent runtime will tunnel the MCP connection through that bridge instead of calling the URL directly.

agents/agent.yaml
mcp_servers:
  - name: internal-mcp
    url: http://mcp.internal:8080/mcp
    bridge: ${INTERNAL_BRIDGE_ID}

The url is the address the bridge sees from inside your network. Typically a hostname that only resolves there (for example mcp.internal:8080). The bridge ID is copied from Project Settings > Bridge. Both the URL and the bridge ID support ${VAR} substitution, so you can keep them out of YAML and store them as variables.

The MCP server's host:port must be in the bridge agent's ALLOWED_HOSTS, the same allow-list used for connectors and custom-tool tunnels.

Discoverable MCP Servers

Some MCP servers expose a large number of tools. Loading all of them into the LLM context increases token usage and can reduce accuracy. Setting discoverable: true keeps the server's tools out of the LLM context and instead indexes them for on-demand search.

When an MCP server is marked as discoverable, the framework indexes its tools and lets the agent find and call them on demand with a natural-language query. Only the tools that match the query are loaded, keeping the LLM context lean.

agents/research-agent.yaml
version: "1.0"

name: research-agent
type: llm
model: gemini/gemini-2.5-pro
description: "Agent with a large MCP toolset available on demand"
system_prompt: |
  You have access to many research tools. When you need one,
  search for it by describing what you need.

mcp_servers:
  - name: research-hub
    url: https://mcp.example.com/research
    discoverable: true   # all tools indexed for search, not loaded upfront
    headers:
      Authorization: "Bearer ${RESEARCH_TOKEN}"
Combining with regular tools

You can use discoverable: true on some MCP servers while keeping others loaded normally. You can also combine discoverable MCP servers with discoverable local tools on the same agent. All discoverable tools (local and MCP) share the same discovery index.

Error Handling

Connection Failures: If an MCP server is unavailable at startup, the agent continues running without that server's tools.

Tool Failures: Errors are captured in traces and returned to the LLM for handling.

Retry Options: Use the agent's standardretry_options to automatically retry failed runs.

Security

Never hardcode API keys or tokens in YAML files. Always use environment variables with the ${VAR_NAME} syntax.

Limitations