Skip to content

datarobot-community/datarobot-mcp-template

DataRobot Logo

FastMCP Server Template for DataRobot

Homepage · Documentation · MCP Protocol · Support

License FastMCP Python

This repository provides a production-ready template for building FastMCP servers with DataRobot integration. Once configured, the template results in a complete framework for creating MCP Servers to be used by agents for calling tools, prompts, and resources. It can then be deployed as a DataRobot Custom Model Application, enabling seamless integration with AI assistants like Cursor, Claude Desktop, and other MCP-compatible clients.

The template includes pre-built tools for common DataRobot operations, a structured approach for adding custom tools, automated deployment infrastructure, and production-ready features like OpenTelemetry tracing and dynamic tool registration.


FastMCP template navigation

Prerequisites

If you are using DataRobot codespaces, this is already complete for you. If not, install the following tools:

  • Python (3.11+ required for infrastructure and backend development)
  • Taskfile.dev (task runner)
  • uv (Python package manager)
  • Pulumi (infrastructure as code)

DataRobot codespaces setup

If you are developing within a DataRobot codespace, in order to test from the codespace the development ports need to be exposed. You can check this in the "Exposed Ports" section of your "Session Environment" tab (pictured below). You should have the ports 5173 (frontend), 8080 (application server) and 8842 (agent server) exposed. This should have been automatically enabled if you created this application template from the gallery, otherwise (e.g., if cloned) configure these ports manually. There will be a link next to the port to a URL where the service can be accessed when running locally in the codespace.

Screenshot of Codespaces Session Environment.

Example Installation Commands

For the latest and most accurate installation instructions for your platform, visit:

We provide the instructions below to save you a context flip, but your system may not meet the common expectations from these shortcut scripts:

macOS:

brew install python
brew install go-task/tap/go-task
brew install uv
brew install pulumi/tap/pulumi

Linux (Debian/Ubuntu/DataRobot codespaces):

# Python
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-venv
# Taskfile.dev
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
# uv
curl -Ls https://astral.sh/uv/install.sh | sh
# Pulumi
curl -fsSL https://get.pulumi.com | sh

Windows (PowerShell):

# Python
winget install --id=Python.Python.3.12 -e
# Taskfile.dev
winget install --id=Task.Task -e
# uv
winget install --id=astral-sh.uv  -e
# Pulumi
winget install pulumi
winget upgrade pulumi
# Windows Developer Tools
winget install Microsoft.VisualStudio.2022.BuildTools --force --override "--wait --passive --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.22621"

# For Windows 10/11, toggle Developer Mode to "On" under System > For developer to enable symbolic link
# Additionally, we use symlinks in the repo. Set
git config --global core.symlink true
# Alternatively, you can do it for just this repo by omitting the --global and running this in the repo.

Optional

  • Docker: For containerized deployment
  • AWS Credentials: If using AWS-related features (S3 predictions or memory.)
  • Node.js: Required for Claude Desktop MCP client setup

Getting started

Clone the repository

git clone https://github.com/datarobot/recipe-fastmcp-template.git
cd recipe-fastmcp-template

Install dependencies

Note: This installs dependencies for both the MCP application and infrastructure components.

task install

Configure environment variables

Create a .env file in the dr_mcp/ directory:

cd dr_mcp
vim .env # or your preferred editor

Copy and paste the following into the .env file:

# Required
DATAROBOT_API_TOKEN=[YOUR_DATAROBOT_API_KEY]
DATAROBOT_ENDPOINT=[YOUR_DATAROBOT_ENDPOINT]

# Optional - Server configuration
# MCP_SERVER_NAME=datarobot-mcp-server
# MCP_SERVER_PORT=8080
# MCP_SERVER_LOG_LEVEL=WARNING
# APP_LOG_LEVEL=INFO

# Optional - Dynamic tool registration
# MCP_SERVER_REGISTER_DYNAMIC_TOOLS_ON_STARTUP=false

# Optional - MCP target_type configuration
# USE_MCP_TARGET_TYPE=true  # Set to false for older environments that don't support MCP

# Optional - AWS credentials (for batch predictions and memory)
# AWS_ACCESS_KEY_ID=your_aws_access_key
# AWS_SECRET_ACCESS_KEY=your_aws_secret_key
# AWS_PREDICTIONS_S3_BUCKET=your_s3_bucket

Add API credentials

Open the DataRobot UI to locate and copy your DataRobot API key and endpoint to your environment variables in .env.

Note: For full details, see the DataRobot API keys documentation.

  1. Log in to your DataRobot account.
  2. Click the user icon in the top right of the UI and select API keys and tools.

  1. Copy your DataRobot API endpoint and paste it into the .env file in place of [YOUR_DATAROBOT_ENDPOINT].

  1. Copy your DataRobot API key and paste it into the .env file in place of [YOUR_DATAROBOT_API_KEY].

Run locally

Start the server locally using the task dev command:

task dev

The server will start on http://localhost:8080 with the MCP endpoint at http://localhost:8080/mcp/. Once the FastMCP logo appears, the server is running properly.

Note: When finished, press Ctrl+C to stop the server.

From here, you can perform some optional interactive testing on the local server using the steps in the next section. If you would like to skip straight to deploying a server, proceed to Deployment.

Test your tools interactively (optional)

Once the server is running, you can immediately test your tools with an AI agent using the interactive testing mode:

task mcp:test-interactive

This command will:

  • Start the MCP server (if not already running locally)
  • Start a local AI agent connected to your MCP server
  • Provide an interactive chat interface to test your tools
  • Show real-time debug output of MCP server operations
  • Allow you to test tool implementations end-to-end prior to deployment

The interactive mode displays detailed logs showing:

  • Tool registration and discovery
  • Request processing and responses
  • Error handling and debugging information
  • Agent decision-making process

Interactive Testing Mode showing AI agent connected to MCP server with debug output

Note: The interactive testing requires an internet connection for the LLM, but all tool execution happens locally through your MCP server.

Error handling and debugging

When developing tools, you'll encounter errors that need quick resolution. The MCP server provides detailed error information to help you iterate rapidly. The test-interactive command displays all of these in one place for you to see as you are testing the tools:

  • Server logs show real-time error details, including stack traces
  • Tool execution errors are captured and displayed with context
  • Validation errors highlight parameter issues immediately
  • Connection errors provide clear diagnostic information

MCP server error display showing formatted error messages and stack traces

Common debugging steps:

  1. Check server logs for detailed error messages
  2. Verify tool parameters match expected types
  3. Ensure DataRobot API credentials are valid
  4. Test individual tool functions in isolation
  5. Use the interactive mode to reproduce errors with real agent calls

Deployment

Now that the local test passed, you can deploy the server to DataRobot.

What gets deployed

After deployment is successful, it creates the following resources:

  • Execution Environment: Docker-based Python 3.12 environment (or uses existing)
  • Custom Model: MCP server packaged as an unstructured custom model
  • Registered Model: Versioned model registration
  • Prediction Environment: DataRobot Serverless platform
  • Deployment: Active deployment with direct access endpoints

Pulumi login

Pulumi requires a location to store the state of the application template. The easiest option is to run:

pulumi login --local

We recommend using a shared backend like Pulumi Cloud, Ceph, Minio, S3, or Azure Blob Storage. See Managing Pulumi State and Backends for more details. For production CI/CD information see our comprehensive CI/CD Guide for Application Templates

Deploy to DataRobot

  1. Copy the .env file from the dr_mcp directory to the root directory:
cd .. # Previous steps left off in the dr_mcp directory
cp dr_mcp/.env .env
  1. Deploy to DataRobot using Pulumi:

Note: During this process, you will be prompted to provide a new stack name and your Pulumi access token. If prompted to perform an update, select "yes". Deployment can take several minutes to complete.

# Optional: Use existing execution environment
# export DATAROBOT_DEFAULT_MCP_EXECUTION_ENVIRONMENT=your_ee_id

task deploy

When the deployment is complete, the process displays the MCP server details:

Check deployment status

To check the overall deployment status:

task infra:info

Destroy the deployment

When you are finished with the MCP server, you can destroy the deployment:

task destroy

Connect to the deployed MCP server

Use the MCP_SERVER_MCP_ENDPOINT URL (shown in the outputs section in the screenshot above) to connect your MCP clients to the deployed server.

Next steps

Advanced options

MCP Target Type Configuration

The template supports both MCP and Unstructured target types for DataRobot Custom Models. By default, it uses the MCP target type, but you can configure it for older environments that don't support MCP.

Environment Variable Configuration

Set the USE_MCP_TARGET_TYPE environment variable to control the target type:

# For older environments that don't support MCP
USE_MCP_TARGET_TYPE=false task deploy

Runtime Parameters

Customize deployment parameters by modifying the following files:

infra/infra/dr_mcp_user_params.py

Add your custom runtime parameters in the infrastructure:

MCP_RECIPE_RUNTIME_PARAMETERS = [
    pulumi_datarobot.CustomModelRuntimeParameterValueArgs(
        key="recipe_name",
        type="string",
        value=os.getenv("RECIPE_NAME", "default-recipe"),
    ),
    # Add your custom runtime parameters here
]

dr_mcp/user-metadata.yaml

Add your custom runtime parameters to the schema:

runtimeParameterDefinitions:
  - fieldName: user_name
    type: string
  # Add your custom runtime parameters here

dr_mcp/app/core/user_config.py

Update the parameter handling:

class UserAppConfig(BaseSettings):
    """User-specific application configuration."""

    # Example of adding user-specific configuration
    user_name: str = Field(
        default="default-user",
        validation_alias=AliasChoices(
            RUNTIME_PARAM_ENV_VAR_NAME_PREFIX + "USER_NAME",
            "USER_NAME",
        ),
        description="Name of the user account in use.",
    )

These parameters will be available as environment variables in the deployed server and can be accessed through the get_user_config() function.

Debugging

Check logs

Server logs (local development):

  • Logs print to console where you ran task dev
  • Control verbosity with MCP_SERVER_LOG_LEVEL and APP_LOG_LEVEL

MCP Client logs:

  • Cursor: View "MCP Logs" in the Output panel (View → Output → MCP Logs)
  • Claude Desktop: Check ~/Library/Logs/Claude/mcp*.log
  • VSCode: Check the Output panel for MCP-related logs

Common issues

Server won't start - "Address already in use"

Another process is using port 8080. Either kill that process or change the port:

cd dr_mcp
export MCP_SERVER_PORT=8081
task dev
Client can't connect - "Connection refused"
  1. Verify server is running: curl http://localhost:8080/health
  2. Check firewall settings
  3. Verify the URL in your client config matches the server
Tools not showing up in client
  1. Check server logs for tool registration errors
  2. Verify your tools have proper docstrings and type hints
  3. Restart the MCP client after server changes

Get help

If you encounter issues or have questions:

Contributing

We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines.

Quick contribution guide

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes following our code standards
  4. Run tests: cd dr_mcp && task test
  5. Run linters: cd dr_mcp && task lint
  6. Commit with proper license headers
  7. Push and create a pull request

Code standards

  • All source and test files must include the Apache 2.0 license header
  • Imports must be at the top of files (never inside functions)
  • Follow RESTful principles for API endpoints
  • Make minimal, focused changes - only modify files necessary for your feature
  • Use type hints and comprehensive docstrings
  • Write tests for new functionality

Additional resources

License

This project is licensed under the Apache License 2.0 - see LICENSE for details.

Copyright 2025 DataRobot, Inc.


Built with ❤️ by DataRobot

About

DataRobot MCP template for building Model Context Protocol servers with deep DataRobot integration.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks