Scalekit lets you configure MCP endpoints that manage authentication, create personalized access URLs for users, and define which AgentKit tools are accessible. You can also bundle several toolkits (e.g., Gmail + Google Calendar) within a single endpoint.
Model Context Protocol (MCP) is an open-source standard that enables AI systems to interface with external tools and data sources. Where the integrating-agentkit skill uses the SDK directly, this workflow configures AgentKit to expose tools over the MCP protocol so any compliant client — LangChain, Claude Desktop, MCP Inspector — can consume them.
Note: AgentKit MCP servers only support Streamable HTTP transport.
Guardrails
- MUST use Streamable HTTP transport — stdio and SSE are not supported by AgentKit MCP servers.
- MUST use the dashboard Connection Name verbatim as the
connection_namein code — they must match exactly. - MUST NOT expose connector tools without per-user authenticated MCP URLs; each user authorizes their own connected account.
What you'll build
- A Scalekit MCP server that fetches the user's latest email and creates a reminder calendar event
- A LangGraph agent that connects to this server via
langchain-mcp-adaptersand invokes the tools
Prerequisites
User actions (print the checklist and wait for confirmation — do not attempt to automate the dashboard UI):
- Scalekit credentials: user copies
SCALEKIT_CLIENT_ID,SCALEKIT_CLIENT_SECRET,SCALEKIT_ENVIRONMENT_URLfrom app.scalekit.com → Settings into.env - OpenAI API key: user sets
OPENAI_API_KEY - Google Calendar connector (required for this example; Gmail does not need dashboard setup): user creates it at Scalekit Dashboard → AgentKit → Connections → + Create Connection → Google Calendar → Connection Name =
MY_CALENDAR→ Save
Connection Name set in the dashboard is exactly what you pass as
connection_namein code. Non-Gmail connectors fail until the user finishes dashboard setup.
After the user confirms prerequisites, continue with code steps below.
Step 1 — Set up your environment
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 main.py:
import os
import asyncio
from dotenv import load_dotenv
from scalekit import ScalekitClient
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 the OpenAI key in your environment:
export OPENAI_API_KEY=xxxxxx
Initialize the Scalekit client:
load_dotenv()
sk_client = ScalekitClient(
client_id=os.getenv("SCALEKIT_CLIENT_ID"),
client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),
env_url=os.getenv("SCALEKIT_ENVIRONMENT_URL"),
)
my_mcp = sk_client.actions.mcp
Step 2 — Create an MCP config and server instance
Define the MCP config with connection_tool_mappings — each entry maps a connector to the tools it exposes:
cfg_response = my_mcp.create_config(
name="reminder-manager",
description="Summarizes latest email and creates a reminder event",
connection_tool_mappings=[
# Gmail works directly — no dashboard setup required
McpConfigConnectionToolMapping(
connection_name="gmail",
tools=[
"gmail_fetch_mails",
],
),
# Google Calendar must be created in dashboard first
McpConfigConnectionToolMapping(
connection_name="MY_CALENDAR",
tools=[
"googlecalendar_create_event",
],
),
],
)
config_name = cfg_response.config.name
Create a server instance for a specific user. Replace user_identifier with the app's real user id (each user gets their own instance URL):
inst_response = my_mcp.ensure_instance(
config_name=config_name,
user_identifier="<your-app-user-id>", # e.g. the logged-in user id — not a shared placeholder
)
mcp_url = inst_response.instance.url
print("Instance URL:", mcp_url)
Step 3 — Authenticate the user
Retrieve auth state and print any OAuth links the user needs to visit:
auth_state_response = my_mcp.get_instance_auth_state(
instance_id=inst_response.instance.id,
include_auth_links=True,
)
for conn in getattr(auth_state_response, "connections", []):
print(
"Connection:", conn.connection_name,
" Provider:", conn.provider,
" Auth Link:", conn.authentication_link,
" Status:", conn.connected_account_status,
)
Note (user action): Tell the user to open every printed auth link in a browser and complete OAuth before you proceed to Step 4 — the agent cannot complete the browser OAuth flow itself.
Step 4 — Connect and invoke via MCP
Use MultiServerMCPClient with streamable_http transport, load the tools, and run the agent:
async def main():
client = MultiServerMCPClient(
{
"reminder_demo": {
"transport": "streamable_http",
"url": mcp_url,
},
}
)
tools = await client.get_tools()
# Model id is provider-prefixed for LangGraph; use a real OpenAI chat model.
agent = create_react_agent("openai:gpt-4o", tools)
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(response)
asyncio.run(main())
Note — MCP client compatibility: You can test this MCP server with popular clients like MCP Inspector, Claude Desktop, and other spec-compliant implementations. Note that ChatGPT's beta connector feature may not work properly as it's still in beta and doesn't fully adhere to the MCP specification yet.
Full working example: github.com/scalekit-inc/python-connect-demos/tree/main/mcp
Deep reference
- AgentKit overview: docs.scalekit.com/agentkit/overview
- Connections: docs.scalekit.com/agentkit/connections
- Connected accounts: docs.scalekit.com/agentkit/connected-accounts
- Tool discovery: docs.scalekit.com/agentkit/tool-discovery
When to switch skills
- Use
integrating-agentkitfor direct SDK integration without MCP. - Use
discovering-connector-toolswhen the user needs the current tool catalog or schema. - Use the Scalekit MCP server (
https://mcp.scalekit.com) to validate a tool call interactively.