Skip to main content
Beta: This feature is in beta. The API schema may change as we iterate on the design.
MCP (Model Context Protocol) is an open standard that enables AI agents to interact with external tools and services. By passing MCP server configurations in your converse requests, you can extend the agent’s capabilities with custom tools. MCP servers are configured per-request. The agent will discover available tools from each server and use them as needed to complete the user’s request.

Basic Usage

import os
from datagrid_ai import Datagrid

client = Datagrid(api_key=os.environ.get("DATAGRID_API_KEY"))

response = client.converse(
    prompt="Tell me about my projects",
    config={
        "mcp_servers": [
            {
                "type": "inline_mcp",
                "server_label": "project-api",
                "server_url": "https://mcp.mycompany.com",
                "server_description": "Project management API",
                "authorization": "Bearer your-api-token"
            }
        ]
    }
)

print(response.content[0].text)

Configuration Options

FieldTypeRequiredDescription
typestringYesMust be "inline_mcp" for server configs passed in the request
server_labelstringYesUnique identifier for the server (max 64 characters). Used for tool namespacing.
server_urlstringYesHTTPS URL of the MCP server endpoint
server_descriptionstringNoDescription of what the server provides (max 500 characters)
authorizationstringNoValue sent in the Authorization header when calling the MCP server (e.g., "Bearer token")

Multiple Servers

You can connect multiple MCP servers in a single request. Each server’s tools will be available to the agent:
response = client.converse(
    prompt="Get the weather forecast and add it to my calendar",
    config={
        "mcp_servers": [
            {
                "type": "inline_mcp",
                "server_label": "weather",
                "server_url": "https://mcp.example.com/weather",
                "authorization": "Bearer weather-token"
            },
            {
                "type": "inline_mcp",
                "server_label": "calendar",
                "server_url": "https://mcp.example.com/calendar",
                "authorization": "Bearer calendar-token"
            }
        ]
    }
)

How It Works

  1. Tool Discovery: When a request includes MCP servers, Datagrid calls tools/list on each server to discover available tools
  2. Tool Registration: The discovered tools are registered with the agent for the duration of the request
  3. Tool Execution: When the agent uses a tool, Datagrid calls tools/call on the appropriate MCP server
  4. Credential Isolation: Each server’s authorization token is kept separate and only sent to that specific server

Security

  • HTTPS Required: All MCP server URLs must use HTTPS
  • SSRF Protection: Requests to private IP addresses, localhost, and internal domains are blocked
  • Credential Isolation: Authorization tokens are isolated per-server and never shared between servers
  • Ephemeral: Server configurations are not persisted - they only exist for the duration of the request

Building MCP Servers

To create an MCP server, implement the Model Context Protocol specification. Your server must handle two JSON-RPC methods:
  • tools/list - Returns available tools and their JSON Schema definitions
  • tools/call - Executes a tool and returns the result
For implementation guides and examples, see the MCP documentation.