Model Context Protocol (MCP)
The Model Context Protocol (MCP) helps integrate external tools and services into the Spice runtime. MCP tools can be run internally or connected over HTTP using the Streamable HTTP transport.

Overview​
MCP enables Spice to:
- Run stdio-based MCP servers internally.
- Connect to external MCP servers over Streamable HTTP.
This flexibility helps extend the capabilities of language models by providing access to external tools and services.
Configuring MCP Tools​
To configure MCP tools, define them in the tools section of your spicepod.yaml file. The from field specifies the transport mechanism (e.g., mcp:npx for stdio or an HTTP URL for Streamable HTTP).
Example: Adding an MCP Tool​
tools:
- name: google_maps
from: mcp:npx
params:
mcp_args: -y @modelcontextprotocol/server-google-maps
Example: Connecting to an External MCP Server​
tools:
- name: external_mcp_server
from: mcp:http://example.com/v1/mcp
Using MCP Tools with Models​
Once configured, MCP tools can be assigned to models via the tools parameter.
models:
- name: model_with_mcp
from: openai:gpt-4o
params:
tools: google_maps
Spice as an MCP Server​
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.
Example: Connecting to another Spice instance via MCP​
tools:
- name: spice_instance
from: mcp:http://localhost:8090/v1/mcp
Additional Configuration Options​
from​
The from field specifies the transport mechanism for the MCP tool:
- Streamable HTTP: Use an HTTP URL pointing to the MCP endpoint (e.g.,
http://localhost:8090/v1/mcp). - Stdio: Use commands like
mcp:npxormcp:docker. Additional arguments can be passed viaparams.mcp_args.
params​
The params field provides additional configuration for MCP tools. For stdio-based tools, use mcp_args to specify command-line arguments.
tools:
- name: custom_tool
from: mcp:npx
params:
mcp_args: -y @custom/tool
env​
For stdio-based MCP tools, environment variables can be set using the env field.
tools:
- name: tool_with_env
from: mcp:docker
env:
API_KEY: your_api_key
For more details, see the MCP Tools Reference.
