Basic Configuration
MCP servers are configured in yourendpoints.yml file.
name: A unique identifier for the MCP serverurl: The URL where the MCP server is runningtype: The server type (currently supportshttpandhttps)
Multiple MCP Servers
You can configure multiple MCP servers to connect to different services:Authentication
MCP servers support multiple authentication methods for connecting to external services:- API Key: Static key attached as
Authorization: Bearer <token> - OAuth 2.0 (Client Credentials): Automatic token retrieval with client ID/secret
- Pre-issued Token: Direct token usage until expiry
- API Key
- API Key (Custom Header)
- OAuth 2.0
- Pre-issued Token
$ syntax is required for the following sensitive parameters:
api_keytokenclient_secret
client_id, using the $ syntax is optional —
you can either reference an environment variable using the $ syntax or provide the value directly in the configuration.
Advanced Configuration
Custom Headers
You can specify custom headers for API key authentication:OAuth 2.0 Scopes
For OAuth 2.0 authentication, you can optionally pass in scope, audience, and timeout:Complete Example
Here’s a comprehensive example showing multiple MCP servers with different authentication methods:Call-time credential hooks (pre_call_hook)
Call-time credential hooks resolve per-conversation secrets only when an outbound MCP tool call is about to be made. Rasa invokes your hook, merges the returned metadata into MCP _meta, and never writes secret values to slots, the tracker, Kafka, or the Inspector.
Use pre_call_hook when credentials are:
- Per user or per conversation (keyed by
sender_id) - Stored encrypted in your own vault or secret manager
- Required on every tool call to a specific MCP server
- Direct MCP tool calls in Flows —
callsteps that referencemcp_serverin a flow (see Calling an MCP Tool) - ReAct external MCP tools — tools from MCP servers listed in the sub agent’s
connectionssection
pre_call_hook on individual flow steps or per sub-agent connection entries — configure the hook in each MCP server entry in endpoints.yml.
endpoints.yml
meta_map and pre_call_hook are set, static meta_map is merged first; hook metadata wins on key collision.
Hook contract
Addpre_call_hook as a dotted import path to a module-level sync or async function. Use async def when the hook performs I/O (for example fetching from a secret store). Import types from rasa.shared.agents.outbound_call_hook:
hook(context) and passes a frozen, read-only MCPOutboundCallContext:
The hook must return an
OutboundCallResult with a metadata dict. OutboundCallResult has a single metadata field; Rasa merges it onto the wire. For convenience, a plain dict is accepted and normalized to OutboundCallResult(metadata=...). Never put secrets in flow mapping.input or tool argument mappings.
custom/call_time_credentials.py
pattern_internal_error. For ReAct MCP tools, Rasa returns an error tool result without calling the remote endpoint. Rasa logs metadata key names at debug level, never values.
For ReAct custom Python tools (not MCP servers), override build_custom_tool_call_metadata() on your MCPOpenAgent or MCPTaskAgent subclass instead. See Call-time credentials for custom tools.
Passing metadata to tools (meta_map)
Remote MCP tool calls can include a protocol-level _meta object (when supported by your MCP client SDK) so the server receives context that does not appear in the tool arguments the LLM fills. In Rasa, this is configured per server with optional meta_map in endpoints.yml:
static: Fixed string key-value pairs always merged into_meta(for example API version or environment labels). Use for non-secret context.from_slots: A list of{ slot, param }entries. For each entry, the current value of the named slot (from the tracker / agent input) is sent as_meta[param]. Preferpre_call_hookinstead of slots when the value is a secret.
meta_map and pre_call_hook are set, static meta_map is merged first; hook metadata wins on key collision.
meta_map is omitted or has no from_slots entries, Rasa still sends any static entries. Slot values are read from the same agent input used for the ReAct turn; ensure the slot is set before the tool runs if you map it in from_slots.
Older MCP Python SDK releases that do not support a meta parameter on call_tool are still supported: Rasa detects this and falls back to calling without metadata so tools keep working; once the SDK supports meta, metadata is sent automatically.
For tools implemented in Python inside your ReAct sub-agent (not via an MCP server), use custom tool executors and override build_custom_tool_call_metadata() to attach call-time credentials to AgentToolContext.metadata. See Call-time credentials for custom tools.
Reading metadata on the MCP server
On the wire, Rasa sends the resolvedmeta_map object as JSON-RPC params._meta on each tools/call request. Keys are exactly the param names defined in from from_slots and the those specified under static (for example user_id, user_role, api_version, source in the sample above).
With the official MCP Python SDK, that payload is available as CallToolRequest.params.meta (the field is serialized as _meta). If you build the server with FastMCP, inject Context and read the same values from the request metadata object (unknown keys are allowed on meta alongside standard fields like progressToken):
Server API and a custom tools/call handler, read the same fields from the incoming CallToolRequest (for example req.params.meta) before invoking your tool implementation.
Privacy and observability: Rasa does not attach this metadata to LLM tracing fields. At debug log level, only the keys of the resolved metadata are logged, not values.
Validation
Rasa validates MCP server configurations to ensure:- Server type is either
httporhttps - Name and URL are not empty
- Sensitive parameters (API keys, tokens, secrets) are properly referenced using environment variables
- OAuth configuration includes all required fields
- If
meta_map.from_slotsis set, every referencedslotexists in the domain (training /rasa trainvalidation) - If
pre_call_hookis set, the import path resolves to a callable (training /rasa trainvalidation)