Spice integrates with tools and services using the Model Context Protocol (MCP). MCP tools can be configured to run internally or connect to external servers over HTTP using the Streamable HTTP transport.
MCP helps extend the capabilities of the Spice runtime by enabling integration with external tools and services. This includes:
To configure MCP tools, define them in the tools section of your spicepod.yaml file. The from field specifies the transport mechanism, such as mcp:npx for stdio-based tools or an HTTP URL for Streamable HTTP-based tools.
The following example demonstrates how to configure an MCP tool using npx to run a Google Maps MCP server:
This example shows how to connect to an external MCP server over Streamable HTTP:
Streamable HTTP MCP tools support sending an Authorization: Bearer token via mcp_auth_token, or arbitrary HTTP headers via mcp_headers. Both parameters resolve secret references before the MCP client is constructed.
Sending a bearer token:
Sending a custom header (e.g., API key):
If both mcp_auth_token and a custom Authorization header in mcp_headers are set, mcp_auth_token wins and a warning is logged.
Once configured, MCP tools can be assigned to models via the tools parameter. For example:
Spice can also act as an MCP server, exposing its tools over Streamable HTTP. This enables other Spice instances or external systems to connect and use the tools.
By default the /v1/mcp endpoint only accepts requests with a Host header matching localhost, 127.0.0.1, or ::1 to prevent DNS rebinding attacks. To allow additional hosts, configure runtime.mcp.allowed_hosts:
Set allowed_hosts: ["*"] to disable host checking entirely.
fromThe from field specifies the transport mechanism for the MCP tool:
http://localhost:8090/v1/mcp).mcp:npx or mcp:docker. Additional arguments can be passed via params.mcp_args.paramsThe params field provides additional configuration for MCP tools.
For stdio-based tools, use mcp_args to specify command-line arguments:
For Streamable HTTP tools, the following auth parameters are supported:
mcp_auth_token — Sends Authorization: Bearer <token> on every request to the MCP server.mcp_headers — Sends additional HTTP headers using the same Header: Value comma- or semicolon-delimited format as the HTTP data connector's http_headers. Header values are marked sensitive.Both parameters support secret expansion. When mcp_auth_token is set, an Authorization header in mcp_headers is ignored and a warning is logged to avoid duplicate auth headers.
envFor stdio-based MCP tools, environment variables can be set using the env field.
descriptionThe description field provides a textual description of the tool. This description is passed to any language model that uses the tool.
For more details, see the MCP Tools Reference.