user-robotMCPs Guide

Model Context Protocol (MCP) connections let agents call external services while keeping credentials and transport details centralized. Use this guide when you need to create, manage, or validate MCP configurations across REST, the Python SDK, and the CLI.

circle-info

Compare REST, SDK, and CLI support in the AIP capability matrixarrow-up-right.

circle-info

aip mcps commands accept either the MCP ID or a unique name. If multiple connections share similar names, prefer the explicit ID in scripts to avoid updating the wrong record.

MCP Patterns

Define and attach MCPs directly to agents:

from glaip_sdk import Agent, MCP

weather_mcp = MCP(
    name="weather",
    transport="http",
    config={"url": "https://weather.example.com/mcp"},
    authentication={
        "type": "api-key",
        "key": "X-API-Key",
        "value": "secret-key",
    }
)

agent = Agent(
    name="weather-bot",
    instruction="You help users check the weather",
    mcps=[weather_mcp]
)

Conditional MCP inclusion:

You can reference MCPs by name string or using MCP.from_native():

Use this pattern for:

  • Attaching MCPs to specific agents

  • Conditional MCP inclusion

  • Simple integrations

MCP Registry Management (Secondary)

Use the SDK Client for managing the MCP registry and cross-environment governance. This is a secondary pattern; prefer defining MCPs directly and attaching them to Agent instances for day-to-day application code.

Use this pattern for:

  • Managing the MCP registry

  • Listing and searching MCPs

  • Testing MCP connections

  • MCP governance across environments


Create an MCP Configuration

When to use: Establish a new integration endpoint or clone settings from staging to production.

Using files with the CLI

  • Inline vs file inputs: Any JSON flag (e.g., --config, --auth) accepts either inline JSON or a file reference using @path/to/file.json. File inputs are parsed with the same validation as inline payloads.

  • Importing full definitions: Supply --import <file> to recreate an MCP from an export. The CLI loads every supported field from the file (name, transport, config, authentication, mcp_metadata, etc.).

  • Flag overrides: CLI flags provided alongside --import override the matching keys in the file. Leaving a flag out keeps the file’s value. When the file already contains required fields like name and transport, those flags become optional.

Example config file:

Example auth file:

Example import file:

Command examples:

Rotate Credentials or Update Configs

When to use: Refresh secrets before they expire or tweak transport parameters without downtime.

Validate Connections Before Saving

When to use: Confirm the connector responds and auth works before exposing it to agents.

Test connectivity without persisting a record:

Common errors and fixes

Symptom
Likely cause
Fix

401 Unauthorized when validating

API key lacks MCP permissions or connector secrets expired.

Issue a runner/creator key or rotate the provider secret under Rotate Credentials.

404 or connection refused during validation

Base URL incorrect or firewall blocking outbound traffic.

Confirm the URL, allowlist the host, or test from a network that can reach the provider.

Connector saves but tools list is empty

Provider exposes no MCP tools or scope is limited.

Run discovery with elevated scopes or confirm the provider exports MCP metadata.

Agents timeout when calling the MCP

Runtime overrides missing, or concurrency exceeds provider limits.

Use per-run overrides for busy periods and tune agent timeout settings.

Discover MCP Tools

When to use: Inspect which tool definitions become available once the connector is active.

Get tools from a saved MCP:

Get tools from a config file (without saving to DB):

Get just tool names for allowed_tools config:

Example config file (mcp-config.json):

Attach discovered tool IDs to agents just like native or custom uploads.

Restrict Agent Tool Access (Allow List)

When to use: Limit which MCP tools an agent can access instead of allowing all tools from the MCP.

circle-exclamation

Configure Tool Filtering at Agent Level

Configuration rules:

  • Omit allowed_tools or set to null or empty list [] — allows all MCP tools (default)

  • Set to ["tool1", "tool2"] — allows only listed tools

Combining with authentication:

Update Existing Agent Tool Access

Runtime Overrides During Agent Runs

When to use: Supply per-run credentials, tool restrictions, or endpoints that differ from the stored defaults.

Override authentication:

Override allowed tools:

Configuration layers (resolution order):

  1. Runtime config (highest priority) — per-execution overrides

  2. Agent config — stored in agent mcp_configs

  3. MCP config (lowest priority) — base MCP settings

circle-info

Runtime overrides are processed in-memory for the run and do not modify stored MCP or agent records. CLI support is under development; use the SDK or REST API for now.

MCP Maintenance

When to use: Audit or retire connectors after incidents, vendor changes, or environment migrations.

  • Soft delete via DELETE /mcps/{id}.

  • List MCPs with GET /mcps or aip mcps list.

  • Combine MCP tooling with the Tools guidearrow-up-right when you want to import remote tools into agent definitions.

Best Practices

When to use: Align your organisation on safe defaults that reduce downtime and credential leaks.

  1. Store secrets securely — use environment variables when invoking CLI or REST workflows; avoid committing secrets to JSON.

  2. Validate before saving — run aip mcps connect --from-file ... or /mcps/connect to catch network or auth issues early.

  3. Document tool discovery — record which MCP tool IDs power each agent so teammates can maintain the integration.

  4. Monitor timeouts — many services expose their own rate or timeout limits; set config.timeout accordingly and surface errors in run logs.

Last updated