filesMCP Connector

gllm-inferencearrow-up-right | Tutorial: MCP Connector | API Referencearrow-up-right

Supported by: OpenAILMInvoker

What is MCP Connector?

MCP connector is a native tool that allows the language model to access managed third-party services through OpenAI's MCP connector infrastructure. Unlike MCP servers (which you host yourself), MCP connectors provide pre-built integrations with popular services like Google Drive, Gmail, and other enterprise tools.

When enabled, MCP connector calls are stored in the outputs attribute of the LMOutput object and can be accessed via the mcp_calls property.

Authentication Options

MCP connectors support three authentication methods:

  1. Static Access Token - A string token for simple authentication

  2. OAuth Credentials - An OAuthCredentials object for OAuth-based services

  3. Dynamic Token Function - An async function that returns fresh tokens

Creating MCP Connector Tools

MCP connector tools can be created in two ways:

import asyncio
from gllm_inference.lm_invoker import OpenAILMInvoker
from gllm_inference.model import OpenAILM
from gllm_inference.schema import NativeTool, OAuthCredentials

# Option 1: Using dictionary
mcp_connector_tool = {
    "type": "mcp_connector",
    "connector_id": "connector_googledrive",
    "name": "google_drive",
    "auth": "<google_oauth_token>",
}

# Option 2: Using NativeTool factory method (recommended)
mcp_connector_tool = NativeTool.mcp_connector(
    connector_id="connector_googledrive",
    name="google_drive",
    auth="<google_oauth_token>",
)

lm_invoker = OpenAILMInvoker(OpenAILM.GPT_5_NANO, tools=[mcp_connector_tool])

Authentication Examples

Static Token Authentication

OAuth Credentials Authentication

Dynamic Token Function

Complete Example: Google Drive Integration

See Also

Last updated

Was this helpful?