Skip to main content
Model Context Protocol (MCP) is an open standard for connecting AI applications to external data sources and tools. Tyler has first-class support for MCP through declarative configuration based on the MCP 2025-11-25 stable framing: Streamable HTTP for remote servers, stdio for local servers, and SSE only for legacy compatibility. 💻 Code Examples

Basic MCP

Get started with MCP servers

Advanced MCP

Multiple servers with filtering

Quick Start

Python API

CLI (tyler-chat)

Add this to your tyler-chat-config.yaml:
Then run:

How It Works

  1. Agent Creation: Agent(mcp={...}) validates config schema immediately (fail fast!)
  2. Connection: await agent.connect_mcp() connects to servers and discovers tools
  3. Tool Registration: Discovered tools are namespaced (servername_toolname) and merged with built-in tools
  4. Usage: Tools are available in agent.run() like any other tool
  5. Cleanup: await agent.cleanup() disconnects MCP servers

Configuration Reference

Server Configuration

Each MCP server requires:

Transport Types

Streamable HTTP - For HTTP-based MCP servers (Mintlify, hosted servers):
stdio - For local process MCP servers:
SSE (Server-Sent Events) - Legacy HTTP transport for backward compatibility:

Advanced Usage

Multiple Servers

Connect to multiple MCP servers simultaneously:

Tool Filtering

Control which tools are registered:

Custom Namespace

Override the default namespace prefix:

Environment Variables

Use environment variables for secrets (recommended!):
Set the environment variable:

Graceful Degradation

Control failure behavior per server:

Resource Management

When to Use cleanup()

Use try/finally and call await agent.cleanup() whenever an agent connects to MCP servers. Cleanup disconnects SDK sessions and removes dynamically registered MCP tools from the agent so reconnects do not duplicate definitions. Long-running applications:
Testing or batch processing:
Streamable HTTP uses asyncio task groups and remote sessions that especially need explicit cleanup. Using the same pattern for stdio and legacy sse keeps scripts and tests predictable.

Security Best Practices

Never hardcode API keys or secrets in config files! Always use environment variable substitution (${VAR}).
DO:
DON’T:
Harden MCP usage:
  • Trust only reviewed MCP servers; local stdio servers run with the same privileges as the Tyler process.
  • Treat MCP tool descriptions, annotations, icons, and _meta as advisory/untrusted unless the server is trusted.
  • Prefer include_tools and exclude_tools so agents only see the tools they need.
  • Avoid always-on large MCP server catalogs; connect narrow server sets per agent or workflow.
  • Keep secrets in environment variables and use ${VAR} substitution in config.

Troubleshooting

Connection refused

Error: Failed to connect to MCP server 'xyz': Connection refused Solutions:
  1. Verify the server URL is correct
  2. Check if the MCP server is running
  3. For stdio servers, verify the command path is correct
  4. Check firewall settings

Invalid config schema

Error: Server 'xyz' with transport 'sse' requires 'url' field Solution: Ensure required fields are present for the transport type:
  • streamablehttp/SSE: url required
  • stdio: command required

Tools not discovered

Error: MCP connects but no tools available Solutions:
  1. Verify the MCP server is functioning (check server logs)
  2. Check if tools are being filtered out (remove include_tools/exclude_tools)
  3. Try connecting to the server manually to verify it exposes tools

Environment variable not substituted

Error: Connection fails with literal ${VAR} in URL Solution: Ensure the environment variable is set before running:
Under the Hood: Tyler uses the official MCP SDK’s ClientSessionGroup to manage connections to MCP servers. The declarative config approach is recommended for all users. See the API Reference for details.

Next Steps

MCP Specification

Read the full MCP specification

MCP Servers

Browse available MCP servers

Adding Tools

Build custom tools for agents

Tyler CLI

Use MCP with tyler-chat CLI