MCP quickstart

Create your first MCP server

Model Context Protocol (MCP) is an open-source standard for connecting AI applications to external tools. All the 500+ tools available in Composio are also available as MCP servers.

Composio lets you create MCP servers that handle authentication (OAuth, API keys), generate unique URLs for each user, and control which tools are exposed. You can combine multiple toolkits in a single server.

Composio MCP servers only support Streamable HTTP transport.

Install the SDK

First, install the Composio SDK for your preferred language:

$pip install composio

Create an MCP server

1

Initialize Composio

1from composio import Composio
2
3# Initialize Composio
4composio = Composio(api_key="YOUR_API_KEY")
2

Create server configuration

Before you begin: Create an auth configuration for your toolkit.

Create an MCP server with your auth config. You can also set list of specific tools to enable across all toolkits

1# Create MCP server with multiple toolkits
2server = composio.mcp.create(
3name="mcp-config-73840", # Pick a unique name for your MCP server
4toolkits=[
5 {
6 "toolkit": "gmail",
7 "auth_config": "ac_xyz123" # Your Gmail auth config ID
8 },
9 {
10 "toolkit": "googlecalendar",
11 "auth_config": "ac_abc456" # Your Google Calendar auth config ID
12 }
13],
14allowed_tools=["GMAIL_FETCH_EMAILS", "GMAIL_SEND_EMAIL", "GOOGLECALENDAR_EVENTS_LIST"]
15)
16
17print(f"Server created: {server.id}")

Alternative: You can also create and manage MCP configs directly from the Composio dashboard → MCP Configs.

3

Generate user URLs

Before generating URLs: Users must authenticate with the toolkits configured in your MCP server. See hosted authentication for how to connect user accounts.

Get server URLs for your users to connect:

1# Generate server instance for user
2instance = composio.mcp.generate(user_id="user-73840", mcp_config_id=server.id) # Use the user ID for which you created the connected account
3
4print(f"MCP Server URL: {instance['url']}")

If users haven’t authenticated, the MCP server will still generate a URL but tools requiring authentication won’t work until the user connects their accounts.

4

Use with AI providers

Use the MCP server URL with your AI provider:

1from openai import OpenAI
2
3# Initialize OpenAI client
4client = OpenAI(api_key="your-openai-api-key")
5
6# Use the MCP server URL you generated
7mcp_server_url = "https://backend.composio.dev/v3/mcp/YOUR_SERVER_ID?include_composio_helper_actions=true&user_id=YOUR_USER_ID"
8
9# Use MCP with OpenAI Responses API
10response = client.responses.create(
11model="gpt-5",
12tools=[
13 {
14 "type": "mcp",
15 "server_label": "composio-server",
16 "server_description": "Composio MCP server for Gmail and Calendar integrations",
17 "server_url": mcp_server_url,
18 "require_approval": "never",
19 },
20],
21input="What meetings do I have tomorrow? Also check if I have any urgent emails",
22)
23
24print("OpenAI MCP Response:", response.output_text)

Next steps

Need help? Join our Discord or raise an issue on GitHub.