Skip to content
Talk to an Engineer Dashboard
Build this faster with AI coding agents. Build with AI →

Give your agent tool access via MCP

Create a per-user MCP server with whitelisted, pre-authenticated tools — then hand your agent a single URL.

This quickstart builds an MCP server that fetches your latest email and creates a reminder calendar event, then connects to it using LangChain OpenAI. Model Context Protocol (MCP) is an open-source standard that connects AI systems to external tools and data sources.

With Scalekit, you can build MCP servers that manage authentication, create personalized access URLs for users, and define which tools are accessible. You can also bundle several toolkits together within a single server.

Before you start, make sure you have:

  • Scalekit API credentials — Go to Dashboard → Settings and copy your client_id and client_secret
  • OpenAI API key — Get from OpenAI Platform
  • Gmail and Google Calendar connections configured in Scalekit:
    • Gmail: Dashboard → Connections (Agent Auth) → Create Connection → Gmail → set Connection Name = MY_GMAIL → Save
    • Google Calendar: Dashboard → Connections (Agent Auth) → Create Connection → Google Calendar → set Connection Name = MY_CALENDAR → Save
  1. Install dependencies:

    pip install scalekit-sdk-python langgraph>=0.6.5 langchain-mcp-adapters>=0.1.9 python-dotenv>=1.0.1 openai>=1.53.0 requests>=2.32.3

    Add these imports to your main.py:

    import os
    import asyncio
    from dotenv import load_dotenv
    import scalekit.client
    from scalekit.actions.models.mcp_config import McpConfigConnectionToolMapping
    from scalekit.actions.types import (GetMcpInstanceAuthStateResponse)
    from langgraph.prebuilt import create_react_agent
    from langchain_mcp_adapters.client import MultiServerMCPClient

    Set your OpenAI API key:

    export OPENAI_API_KEY=xxxxxx

    Initialize the Scalekit client:

    scalekit_client = scalekit.client.ScalekitClient(
    client_id=os.getenv("SCALEKIT_CLIENT_ID"),
    client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),
    env_url=os.getenv("SCALEKIT_ENV_URL"),
    )
    my_mcp = scalekit_client.actions.mcp

  2. Create an MCP server and authenticate the user

    Section titled “Create an MCP server and authenticate the user”

    Create an MCP config:

    cfg_response = my_mcp.create_config(
    name="reminder-manager",
    description="Summarizes latest email and creates a reminder event",
    connection_tool_mappings=[
    McpConfigConnectionToolMapping(
    connection_name="MY_GMAIL",
    tools=[
    "gmail_fetch_mails",
    ],
    ),
    McpConfigConnectionToolMapping(
    connection_name="MY_CALENDAR",
    tools=[
    "googlecalendar_create_event",
    ],
    ),
    ],
    )

    Create an MCP server instance for a specific user john-doe using this config:

    inst_response = my_mcp.ensure_instance(
    config_name=config_name,
    user_identifier="john-doe",
    )
    print("Instance url:", inst_response.instance.url)

    Generate authorization links for john-doe:

    auth_state_response = my_mcp.get_instance_auth_state(
    instance_id=instance_response.instance.id,
    include_auth_links=True,
    )
    for conn in getattr(auth_state_response, "connections", []):
    print("Connection Name:", conn.connection_name, " Provider: ", conn.provider, " Auth Link: ", conn.authentication_link, "Auth Status: ", conn.connected_account_status)

  3. client = MultiServerMCPClient(
    {
    "reminder_demo": {
    "transport": "streamable_http",
    "url": mcp_url
    },
    }
    )
    tools = await client.get_tools()
    agent = create_react_agent("openai:gpt-4.1", tools)
    openai_response = await agent.ainvoke({"messages": "get 1 latest email and create a calendar reminder event in next 15 mins for a duration of 15 mins."})
    print(openai_response)

    You have successfully created your MCP server. Full code is available on GitHub.