Skip to content

Integrate tools using an MCP server

The Model Context Protocol (MCP) provides a standardized interface for AI agents to interact with external systems, tools, and data sources. Using an MCP server to provide tools to your agents offers several advantages over direct tool deployments:

  • Centralized tool management: All tools are managed in one MCP server deployment
  • Standardized interface: Tools follow the MCP protocol standard, making them compatible across different agent frameworks
  • Dynamic tool registration: Tools can be added or modified without redeploying the agent
  • Better separation of concerns: Tools are deployed separately from agents, enabling independent scaling and updates

This guide explains how to integrate tools using an MCP server with your agentic workflows, as implemented in the DataRobot Agentic Application Template.

MCP vs. local tool integration

This documentation covers MCP server-based tool integration. For information about integrating tools using local tools (direct tool deployments), see Add tools to agents.

Overview

The Model Context Protocol (MCP) fundamentally changes how agents access tools. Instead of defining tool logic directly within the agent's code, you deploy a standalone "Tool Server." Your agent then connects to this server as a client, requesting available tools and executing them via a standardized protocol.

The DataRobot Agentic Application Template includes built-in support for MCP tools through the LangGraphAgent base class, which provides the mcp_tools property that automatically connects to your configured MCP server. Refer to the sections below for more information on how to use MCP tools in your agentic workflows.

MCP architecture

  • The agent (client): The reasoning engine (e.g., a LangGraph application) that plans tasks. It does not contain tool code; it only knows how to ask the MCP server what tools are available.
  • The MCP server: A web service hosting the logic for tools, resources, and prompts. It handles the actual execution of tasks (e.g., querying a database, calling an external API).
  • The protocol: A standard interface that allows the agent and MCP server to communicate securely, regardless of the underlying infrastructure.

Integration workflow

To integrate tools using this architecture, you will follow this high-level process:

  • Deploy the MCP server: Create and deploy an MCP server containing your tool logic (using the DataRobot MCP Template).
  • Connect the agent: Configure your agent application to point to the running MCP server's endpoint.
  • Execute: The agent automatically discovers tools at runtime. You do not need to redeploy the agent to add new tools; you only update the MCP server.

Prerequisites

Before integrating MCP tools, ensure you have:

For information on setting up and deploying an MCP server, refer to the MCP Template documentation.

MCP server deployment

The MCP server can be deployed either locally for development or to DataRobot for production use.

Local deployment

For local development, start the MCP server using the development command:

cd mcp_server
dr task run mcp_server:dev

The MCP server will start on the configured port (default: 9000) and be accessible at http://localhost:9000/mcp/.

Production deployment

To deploy the MCP server to DataRobot:

  1. Configure deployment settings: Update your Pulumi configuration or deployment settings
  2. Deploy the server: Use the deployment command:
dr task run deploy
  1. Get the deployment endpoint: After deployment, note the deployment ID and construct the MCP endpoint URL:
https://your-datarobot-endpoint.com/api/v2/deployments/{DEPLOYMENT_ID}/directAccess/mcp/
  1. Configure the agent: Update your agent's configuration to use the production MCP endpoint

For detailed deployment instructions, refer to the MCP Template README.

Configure MCP server connection

To connect your agent to an MCP server, you need to configure the MCP server endpoint and authentication in your agent's environment variables or configuration.

Local development

For local development, configure the MCP server connection in your .env file:

.env
# MCP Server Configuration
MCP_SERVER_PORT=9000

The MCP server uses one of two ports by default:

Make sure to use the correct port when configuring the agent.

Production configuration

For production deployments, configure the MCP server using environment variables. This process is handled automatically by the template.

MCP server authentication

If your MCP server requires authentication, ensure that DATAROBOT_API_TOKEN is set in your environment, as the MCP client will use it automatically for authenticated requests.

Use MCP tools in agents

The LangGraphAgent base class (used in the DataRobot Agentic Application Template) provides automatic MCP tool integration through the mcp_tools property.

LangGraph agents

For LangGraph agents, MCP tools are automatically available through the mcp_tools property:

agent/agentic_workflow/agent.py
from datarobot_genai.core.agents import make_system_prompt
from datarobot_genai.langgraph.agent import LangGraphAgent
from langgraph.prebuilt import create_react_agent
from typing import Any

class MyAgent(LangGraphAgent):
    """Agent that uses MCP tools for external integrations."""

    @property
    def agent_planner(self) -> Any:
        return create_react_agent(
            self.llm(preferred_model="datarobot/azure/gpt-5-mini-2025-08-07"),
            tools=self.mcp_tools,  # MCP tools are automatically available
            prompt=make_system_prompt(
                "You are a content planner. Use available tools to gather information and plan content."
            ),
            name="Planner Agent",
        )

The mcp_tools property automatically:

  • Connects to the configured MCP server
  • Discovers available tools
  • Converts MCP tools to LangChain-compatible tools
  • Handles authentication if required

Combine MCP tools with local tools

You can combine MCP tools with local tools by merging the tool lists:

agent/agentic_workflow/agent.py
from datarobot_genai.core.agents import make_system_prompt
from datarobot_genai.langgraph.agent import LangGraphAgent
from langgraph.prebuilt import create_react_agent
from langchain_core.tools import Tool
from typing import Any

class DateTimeTool(Tool):
    """Local datetime tool."""
    name = "datetime_tool"
    description = "Returns the current date and time."

    def run(self, query: str = "") -> str:
        from datetime import datetime
        return datetime.now().strftime("%Y-%m-%d %H:%M:%S")

class MyAgent(LangGraphAgent):
    """Agent that uses both MCP tools and local tools."""

    @property
    def agent_planner(self) -> Any:
        # Combine MCP tools with local tools
        local_tools = [DateTimeTool()]
        all_tools = list(self.mcp_tools) + local_tools

        return create_react_agent(
            self.llm(preferred_model="datarobot/azure/gpt-5-mini-2025-08-07"),
            tools=all_tools,
            prompt=make_system_prompt(
                "You are a content planner. Use available tools to gather information and plan content."
            ),
            name="Planner Agent",
        )

Create custom MCP tools

To add custom tools to your MCP server, use the DataRobot MCP Template. The template provides a structured approach for creating tools, resources, and prompts.

Tool structure

Custom MCP tools are defined using the @dr_mcp_tool decorator:

dr_mcp/app/recipe/tools/my_custom_tool.py
from app.base.core.mcp_instance import dr_mcp_tool
from app.base.core.common import get_sdk_client

@dr_mcp_tool(tags={"custom", "recipe", "your-domain"})
async def my_custom_tool(input_param: str, optional_param: int = 10) -> str:
    """
    Brief description of what your tool does.

    This description helps LLMs understand when and how to use your tool.
    Be specific about the tool's purpose and behavior.

    Args:
        input_param: Description of the required parameter
        optional_param: Description of the optional parameter

    Returns:
        Description of what the tool returns
    """
    # Use the DataRobot SDK client for API operations
    client = get_sdk_client()

    # Your custom logic here
    result = f"Processed {input_param} with {optional_param}"

    return result

Tool best practices

When creating MCP tools, follow these best practices:

  • Clear descriptions: Provide detailed docstrings—LLMs use these to understand tool capabilities
  • Type hints: Always use type hints for parameters and return values
  • Error handling: Implement proper error handling and return meaningful error messages
  • Async functions: Tools should be async functions for better performance
  • Tags: Use descriptive tags to categorize tools (helps with tool filtering)
  • SDK client: Use get_sdk_client() for DataRobot API access

For more information on creating custom MCP tools, see the MCP Template custom tools documentation.

Troubleshooting

Agent can't connect to MCP server

Symptoms: Agent errors mention MCP connection failures or tools not available.

Solutions:

  1. Verify MCP server is running:
# For local development
curl http://localhost:9000/mcp/

# For production
curl https://your-endpoint.com/api/v2/deployments/{DEPLOYMENT_ID}/directAccess/mcp/
  1. Check environment variables:
  2. Verify MCP_SERVER_PORT matches the server configuration (for local development)
  3. Check that DATAROBOT_API_TOKEN is set (for authenticated connections)

  4. Verify network connectivity:

  5. Ensure the agent can reach the MCP server endpoint
  6. Check firewall settings if deploying across networks
  7. Verify SSL certificates for HTTPS endpoints

Tools not appearing

Symptoms: MCP server is connected but tools are not available to the agent.

Solutions:

  1. Check tool registration: Verify that tools are properly registered in the MCP server
  2. Review tool metadata: Ensure tool descriptions and schemas are correctly defined
  3. Check server logs: Review MCP server logs for tool registration errors
  4. Verify agent configuration: Confirm that mcp_tools property is being used correctly

Authentication issues

Symptoms: MCP server requests fail with authentication errors.

Solutions:

  1. Verify API token: Ensure DATAROBOT_API_TOKEN is set and valid
  2. Check token permissions: Verify the token has necessary permissions for MCP server access
  3. Review server configuration: Check that the MCP server is configured to accept the authentication method used

Comparison: MCP vs. ToolClient

Feature MCP Server ToolClient (Direct Deployment)
Tool management Centralized in one server Each tool deployed separately
Protocol MCP standard protocol DataRobot custom protocol
Tool discovery Automatic via MCP Manual configuration per tool
Dynamic updates Tools can be added/modified without agent redeployment Requires agent redeployment for new tools
Framework compatibility Works with any MCP-compatible framework DataRobot-specific
Deployment complexity Single MCP server deployment Multiple tool deployments
Scaling Scale MCP server independently Scale each tool independently

Choose MCP server integration when:

  • You want centralized tool management
  • You need dynamic tool registration
  • You're using multiple agents that share tools
  • You want standard protocol compliance

Choose ToolClient integration when:

  • You need fine-grained control over individual tool deployments
  • Tools have very different scaling requirements
  • You prefer DataRobot-specific tool management features

Additional resources