How to integrate Launch darkly MCP with OpenAI Agents SDK

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Launch darkly logo
OpenAI Agents SDK logo
divider

Introduction

This guide walks you through connecting Launch darkly to the OpenAI Agents SDK using the Composio tool router. By the end, you'll have a working Launch darkly agent that can list all environments for your project, retrieve all custom roles for audit, create a trigger workflow for a flag through natural language commands.

This guide will help you understand how to give your OpenAI Agents SDK agent real control over a Launch darkly account through Composio's Launch darkly MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Launch darkly with

TL;DR

Here's what you'll learn:
  • Get and set up your OpenAI and Composio API keys
  • Install the necessary dependencies
  • Initialize Composio and create a Tool Router session for Launch darkly
  • Configure an AI agent that can use Launch darkly as a tool
  • Run a live chat session where you can ask the agent to perform Launch darkly operations

What is OpenAI Agents SDK?

The OpenAI Agents SDK is a lightweight framework for building AI agents that can use tools and maintain conversation state. It provides a simple interface for creating agents with hosted MCP tool support.

Key features include:

  • Hosted MCP Tools: Connect to external services through hosted MCP endpoints
  • SQLite Sessions: Persist conversation history across interactions
  • Simple API: Clean interface with Agent, Runner, and tool configuration
  • Streaming Support: Real-time response streaming for interactive applications

What is the Launch darkly MCP server, and what's possible with it?

The Launch darkly MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Launch darkly account. It provides structured and secure access to your feature management platform, so your agent can perform actions like managing feature flag workflows, listing projects, retrieving environments, and reviewing teams or custom roles.

  • Automated flag trigger workflows: Set up, modify, or delete flag trigger workflows so your agent can help automate feature releases and rollbacks in specific environments.
  • Comprehensive project and environment listing: Instantly retrieve all projects and their environments to help your agent audit, enumerate, or manage deployment contexts.
  • Team and role audits: List all teams and custom roles, making it easy for your agent to review permissions, conduct audits, or suggest configuration changes.
  • Code reference repository discovery: Pull complete lists of code reference repositories tied to your projects for better traceability and DevOps integration.
  • Effortless environment and project management: Quickly access and enumerate environments and projects to streamline workflows and improve operational oversight.

Supported Tools & Triggers

Tools
Add Member to TeamsTool to add a LaunchDarkly member to one or more teams.
Apply Approval RequestTool to apply an approved approval request in LaunchDarkly.
Apply Approval Request for FlagTool to apply an approved approval request for a feature flag in LaunchDarkly.
Copy Feature FlagTool to copy a feature flag's configuration from one environment to another within the same project.
Create AnnouncementTool to create a public announcement in LaunchDarkly.
Create Approval RequestTool to create an approval request in LaunchDarkly.
Create Approval Request for FlagTool to create an approval request for a feature flag in LaunchDarkly.
Create Approval Request ReviewTool to review an approval request by approving, declining, or commenting on changes.
Create Approval Request Review for FlagTool to review an approval request for a feature flag by approving, declining, or commenting on the changes.
Create Big Segment ExportTool to create an export for a big segment in LaunchDarkly.
Create Big Segment Store IntegrationTool to create a persistent store integration for big segments in LaunchDarkly.
Create Custom RoleTool to create a new custom role in LaunchDarkly.
Create Data Export DestinationTool to create a new Data Export destination for exporting LaunchDarkly event data to external services.
Create EnvironmentTool to create a new environment within a LaunchDarkly project.
Create ExperimentTool to create a new experiment in LaunchDarkly.
Create Extinction EventsTool to create new extinction events for feature flags in LaunchDarkly.
Create Feature FlagTool to create a new feature flag in LaunchDarkly.
Create Flag Scheduled ChangesTool to create a scheduled changes workflow for a feature flag in LaunchDarkly.
Create Flag Copy Config Approval RequestTool to create an approval request for copying a feature flag's configuration from one environment to another.
Create Flag Import ConfigurationTool to create a new flag import configuration for importing feature flags from external feature management systems like Split or Unleash.
Create Flag LinkTool to create a new flag link in LaunchDarkly.
Create HoldoutTool to create a new holdout in LaunchDarkly for experiment control groups.
Create Integration ConfigurationTool to create a new integration configuration in LaunchDarkly.
Create Experiment IterationTool to create a new iteration for an experiment in LaunchDarkly.
Create LayerTool to create a new layer in a LaunchDarkly project.
Create MembersTool to invite one or more new members to join a LaunchDarkly account.
Create MetricTool to create a new metric in LaunchDarkly.
Create Metric GroupTool to create a new metric group in LaunchDarkly.
Create Migration Safety IssuesTool to check migration safety issues for a feature flag patch.
Create OAuth 2.0 ClientTool to create (register) a LaunchDarkly OAuth 2.
Create ProjectTool to create a new project with the given key and name.
Create Relay Proxy Auto ConfigurationTool to create a new Relay Proxy configuration in LaunchDarkly.
Create Release for FlagTool to create a release by adding a flag to a release pipeline in LaunchDarkly.
Create Release PipelineTool to create a release pipeline in LaunchDarkly.
Create Release PolicyTool to create a new release policy for a specified project.
Create RepositoryTool to create a code reference repository with the specified name.
Create SegmentTool to create a new segment in LaunchDarkly.
Create Audit Log SubscriptionTool to create a new audit log subscription for forwarding LaunchDarkly audit events to external services.
Create TeamTool to create a new team in LaunchDarkly.
Create Flag Trigger WorkflowCreates a flag trigger workflow in LaunchDarkly.
Create WebhookTool to create a new webhook in LaunchDarkly.
Create WorkflowTool to create a workflow in LaunchDarkly for automating flag changes.
Create Workflow TemplateTool to create a workflow template in LaunchDarkly.
Delete AnnouncementTool to permanently delete an announcement from LaunchDarkly.
Delete Approval RequestTool to delete an approval request in LaunchDarkly.
Delete Approval Request for FlagPermanently deletes an approval request for a feature flag in LaunchDarkly.
Delete Big Segment Store IntegrationTool to permanently delete a persistent store integration for big segments.
Delete Branches from Code Reference RepositoryAsynchronously deletes multiple branches from a LaunchDarkly code reference repository.
Delete Custom RolePermanently deletes a custom role from LaunchDarkly.
Delete Data Export DestinationPermanently deletes a Data Export destination from LaunchDarkly.
Delete EnvironmentTool to permanently delete an environment from a LaunchDarkly project.
Delete Feature FlagTool to permanently delete a feature flag from LaunchDarkly.
Delete Flag Scheduled ChangesTool to delete scheduled changes workflow for a feature flag in LaunchDarkly.
Delete Flag Import ConfigurationTool to delete a flag import configuration by ID.
Delete Flag LinkPermanently deletes a flag link from LaunchDarkly.
Delete Integration ConfigurationPermanently deletes an integration configuration from LaunchDarkly.
Delete Account MemberTool to permanently delete an account member from LaunchDarkly.
Delete MetricTool to permanently delete a metric from LaunchDarkly.
Delete Metric GroupTool to permanently delete a metric group from LaunchDarkly.
Delete OAuth 2.0 ClientPermanently deletes an OAuth 2.
Delete ProjectTool to permanently delete a project from LaunchDarkly.
Delete Relay Proxy Auto ConfigurationTool to delete a Relay Proxy auto configuration by ID.
Delete Release by Flag KeyTool to delete a release from a feature flag.
Delete Release PipelineTool to permanently delete a release pipeline from LaunchDarkly.
Delete Release PolicyTool to permanently delete a release policy from a LaunchDarkly project.
Delete RepositoryTool to delete a code reference repository with the specified name.
Delete SegmentPermanently deletes a segment from LaunchDarkly.
Delete Audit Log SubscriptionTool to permanently delete an audit log subscription in LaunchDarkly.
Delete TeamPermanently deletes a team from LaunchDarkly organization.
Delete Access TokenTool to permanently delete an access token from LaunchDarkly.
Delete Flag Trigger WorkflowPermanently deletes a flag trigger workflow from LaunchDarkly.
Delete WebhookTool to delete a webhook from LaunchDarkly.
Delete WorkflowPermanently deletes a workflow from LaunchDarkly.
Delete Workflow TemplatePermanently deletes a workflow template from LaunchDarkly.
Evaluate Context InstanceTool to evaluate flags for a context instance to determine expected flag variations.
Generate Trust Policy for Data ExportTool to generate an AWS trust policy for Data Export destinations.
Get All HoldoutsTool to retrieve all holdouts for a specific project and environment.
Get All Integration ConfigurationsTool to retrieve all integration configurations for a specific integration key.
Get All Release PipelinesTool to retrieve all release pipelines for a project.
Get All WebhooksTool to retrieve all webhooks configured in the LaunchDarkly account.
Get Announcements PublicTool to retrieve public announcements from LaunchDarkly.
Get ApplicationsTool to retrieve a list of applications in LaunchDarkly.
Get Application VersionsTool to retrieve all versions for a specific application in LaunchDarkly.
Get Approval for FlagTool to get a single approval request for a feature flag in LaunchDarkly.
Get Approval RequestTool to get a specific approval request by ID from LaunchDarkly.
Get Approval RequestsTool to retrieve all approval requests from LaunchDarkly.
Get Approval Request SettingsTool to retrieve approval request settings for a project.
Get Approvals for FlagTool to retrieve all approval requests for a specific feature flag in an environment.
Get Audit Log EntriesTool to get a list of all audit log entries.
Get Audit Log EntryTool to retrieve a single audit log entry by ID.
Get Big Segment ExportTool to retrieve a specific big segment export by its ID.
Get Big Segment ImportTool to retrieve the status and details of a big segment import by its ID.
Get Big Segment Store IntegrationTool to retrieve a specific persistent store integration for big segments by its ID.
Get Big Segment Store IntegrationsTool to retrieve all persistent store integrations for big segments.
Get BranchTool to retrieve branch information from a LaunchDarkly code reference repository.
Get Caller IdentityTool to retrieve basic information about the identity used to authenticate API calls.
Get Context Attribute NamesTool to retrieve context attribute names for a project and environment.
Get Context Attribute ValuesTool to retrieve unique values for a specific context attribute within a project environment.
Get Context InstancesTool to get context instances for a specific context ID within a project and environment.
Get Context Kinds By Project KeyTool to retrieve all context kinds for a given project.
Get ContextsTool to retrieve context instances from a LaunchDarkly environment by kind and key.
Get Contexts Clientside UsageTool to get a detailed time series of context key usages observed by LaunchDarkly in your account, including non-primary context kinds.
Get Contexts Serverside UsageTool to get detailed time series of context key usages observed by LaunchDarkly in your account, including non-primary context kinds.
Get Contexts Total UsageTool to get a detailed time series of the number of context key usages observed by LaunchDarkly in your account, including non-primary context kinds.
Get Context Instance Segments Membership By EnvironmentTool to get segment membership details for a given context instance with attributes.
Get Custom RoleTool to retrieve a single custom role by key or ID.
Get Custom RolesTool to retrieve a list of all custom roles.
Get Custom WorkflowTool to retrieve details of a specific custom workflow by ID.
Get Data Export Events UsageTool to retrieve a time series array showing the number of data export events from your account.
Get Dependent FlagsTool to list dependent feature flags for a specific flag.
Get Dependent Flags By EnvironmentTool to list dependent flags across all environments for a specified flag.
Get Data Export DestinationTool to retrieve a specific Data Export destination by ID.
Get Data Export DestinationsTool to retrieve all Data Export destinations configured across all projects and environments.
Get EnvironmentTool to retrieve a specific environment by project key and environment key.
Get EnvironmentsTool to retrieve a list of all environments within a project.
Get Evaluations UsageTool to get time-series arrays of flag evaluation counts, broken down by variation.
Get Events UsageTool to get time-series arrays of flag evaluation events.
Get ExperimentTool to retrieve a specific experiment by project key, environment key, and experiment key.
Get Experimentation Events UsageTool to retrieve a time series array showing the number of experimentation events from your account.
Get Experimentation Keys UsageTool to get a time series showing the number of experimentation keys from your account.
Get Experimentation SettingsTool to retrieve experimentation settings for a project.
Get ExperimentsTool to retrieve experiments from a project and environment.
Get Expiring Context TargetsTool to retrieve context targets scheduled for removal from a feature flag.
Get Expiring Targets For SegmentTool to retrieve context targets scheduled for removal from a segment.
Get ExtinctionsTool to get a list of all extinctions.
Get Feature FlagTool to retrieve a specific feature flag by project key and flag key.
Get Feature FlagsTool to retrieve a list of all feature flags in a project.
Get Feature Flag Scheduled ChangeTool to retrieve a specific scheduled change for a feature flag.
Get Feature Flag StatusTool to retrieve the status of a feature flag.
Get Feature Flag Status Across EnvironmentsTool to retrieve the status of a feature flag across all environments in a project.
Get Feature Flag StatusesTool to retrieve status information for all feature flags in a project environment.
Get Flag Scheduled ChangesTool to retrieve scheduled changes for a feature flag.
Get Flag Defaults by ProjectTool to retrieve flag defaults for a specific project.
Get Flag FollowersTool to retrieve followers of a flag in a project and environment.
Get Flag Import ConfigurationTool to retrieve a single flag import configuration by project key, integration key, and integration ID.
Get Flag Import ConfigurationsTool to list all flag import configurations.
Get Flag LinksTool to retrieve all flag links for a specific feature flag.
Get Followers By Project and EnvironmentTool to retrieve followers of all flags in a given project and environment.
Get HoldoutTool to retrieve a specific holdout experiment by project key, environment key, and holdout key.
Get Integration ConfigurationTool to retrieve a specific integration configuration by ID.
Get Integration Delivery Configuration by EnvironmentTool to get delivery configurations by environment for feature store integrations.
Get IPsTool to retrieve the list of IP ranges used by the LaunchDarkly service.
Get LayersTool to retrieve layers for a project.
Get MAU Clientside UsageTool to get a time series of context key usages observed by LaunchDarkly client-side SDKs for the primary context kind.
Get MAU Total UsageTool to get a time series of the number of context key usages observed by LaunchDarkly in your account, for the primary context kind only.
Get MAU UsageTool to get a time-series array of monthly active users (MAU) seen by LaunchDarkly from your account.
Get MAU Usage By CategoryTool to get time-series arrays of monthly active users (MAU) by category (browser, mobile, or backend).
Get Account MemberTool to retrieve detailed information about a specific LaunchDarkly account member.
Get MembersTool to retrieve a list of account members.
Get MetricTool to retrieve a specific metric by project key and metric key.
Get Metric GroupTool to retrieve a specific metric group by project key and metric group key.
Get OAuth 2.0 Client by IDTool to retrieve a registered OAuth 2.
Get OAuth 2.0 ClientsTool to retrieve all OAuth 2.
Get Observability Errors UsageTool to get time-series arrays of the number of observability errors.
Get Observability Logs UsageTool to retrieve time-series arrays of observability logs usage data.
Get Observability Sessions UsageTool to get time-series arrays of the number of observability sessions.
Get Observability Traces UsageTool to retrieve time-series arrays of observability traces usage data.
Get OpenAPI SpecTool to retrieve the latest OpenAPI specification for LaunchDarkly's API in JSON format.
Get ProjectTool to retrieve a specific project by project key.
Get Relay Proxy ConfigTool to retrieve a single Relay Proxy auto configuration by ID.
Get Relay Proxy ConfigsTool to retrieve all Relay Proxy configurations in the LaunchDarkly account.
Get Release by Flag KeyTool to retrieve the currently active release for a feature flag.
Get Release Pipeline by KeyTool to retrieve a release pipeline by its key.
Get Release PoliciesTool to retrieve a list of release policies for a specified project.
Get Release PolicyTool to retrieve a single release policy by its key for a specified project.
Get All Release Progressions for Release PipelineTool to retrieve details on the progression of all releases, across all flags, for a release pipeline.
Get RepositoryTool to get a single code reference repository by name.
Get RootTool to retrieve the LaunchDarkly API root resource.
Get Root Code Reference StatisticTool to get links to code reference repositories for each project.
Get SegmentTool to retrieve a specific segment by segment key.
Get Segment Membership For ContextTool to get big segment membership status for a specific context.
Get SegmentsTool to retrieve a list of all segments in a project and environment.
Get Service Connections UsageTool to get a time series array showing the number of service connection minutes from your account.
Get Code References StatisticsTool to retrieve code references statistics for feature flags.
Get Stream UsageTool to get time-series data of streaming connections to LaunchDarkly.
Get Stream Usage By SDK VersionTool to get time-series data of streaming connections to LaunchDarkly, separated by SDK type and version.
Get Stream Usage SDK VersionsTool to get a list of SDK version objects from LaunchDarkly.
Get Audit Log Subscription by IDTool to retrieve a specific audit log subscription by ID.
Get Audit Log Subscriptions by IntegrationTool to retrieve all audit log subscriptions for a given integration.
Get TagsTool to retrieve a list of tags from LaunchDarkly.
Get TeamTool to fetch a specific team by key.
Get Team MaintainersTool to retrieve the list of maintainers for a specific LaunchDarkly team.
Get Team RolesTool to fetch the custom roles that have been assigned to a team.
Get Access TokenTool to retrieve detailed information about a specific LaunchDarkly access token by its ID.
Get TokensTool to fetch a list of all access tokens.
Get Flag Trigger by IDTool to retrieve details of a specific flag trigger by ID.
Get Flag Trigger WorkflowsTool to retrieve all flag triggers for a specific feature flag in an environment.
Get VersionsTool to retrieve LaunchDarkly API version information.
Get WebhookTool to retrieve a specific webhook by ID.
Get WorkflowsTool to retrieve workflows for a specific feature flag in an environment.
Get Workflow TemplatesTool to retrieve workflow templates belonging to an account.
List Branches in Code Reference RepositoryTool to list branches in a LaunchDarkly code reference repository.
List Code Reference RepositoriesLists all code reference repositories configured in LaunchDarkly.
List Integration Delivery ConfigurationsTool to list all integration delivery configurations.
List Metric GroupsTool to retrieve a list of all metric groups in a project.
List MetricsTool to retrieve a list of all metrics in a project.
List ProjectsTool to retrieve a list of all projects.
List TeamsFetches one page of teams from LaunchDarkly.
Patch Approval Request SettingsTool to perform a partial update to approval request settings for a project.
Patch Big Segment Store IntegrationTool to update a persistent store integration for big segments using JSON Patch operations.
Patch Custom RoleTool to update a custom role's settings using JSON Patch operations.
Update Data Export DestinationTool to update a Data Export destination using JSON Patch operations.
Patch EnvironmentTool to update an environment's settings using JSON Patch operations.
Patch ExperimentTool to update an experiment using semantic patch format.
Patch Expiring TargetsTool to update expiring context targets on a feature flag.
Patch Feature FlagTool to update a feature flag's settings using JSON Patch operations.
Patch Flag Config Approval RequestTool to perform a partial update to a flag config approval request using semantic patch format.
Patch Flag Scheduled ChangeTool to update a scheduled change workflow for a feature flag.
Patch Flag Defaults By ProjectTool to update flag defaults for a project using JSON Patch operations.
Patch Flag Import ConfigurationTool to update a flag import configuration using JSON Patch operations.
Patch HoldoutTool to update a LaunchDarkly holdout using semantic patch operations.
Patch Account MemberTool to modify an account member's information using JSON Patch operations.
Patch MembersTool to perform partial updates to multiple LaunchDarkly account members using semantic patch format.
Patch MetricTool to update a metric's settings using JSON Patch operations.
Patch Metric GroupTool to update a metric group's settings using JSON Patch operations.
Patch OAuth 2.0 ClientTool to update an existing OAuth 2.
Update ProjectTool to update a LaunchDarkly project using JSON Patch operations (RFC 6902).
Update Relay Proxy ConfigTool to update a Relay Proxy auto configuration using JSON Patch operations (RFC 6902).
Patch RepositoryTool to update a code reference repository's settings using JSON Patch operations.
Patch SegmentTool to update a segment's settings using JSON Patch operations.
Patch TeamTool to perform partial updates to a LaunchDarkly team using semantic patch format.
Patch TeamsTool to perform partial updates to multiple LaunchDarkly teams using semantic patch format.
Patch Access TokenTool to update an access token's settings using JSON Patch operations.
Update Flag TriggerTool to update a flag trigger using semantic patch operations.
Update WebhookTool to update a LaunchDarkly webhook using JSON Patch operations (RFC 6902).
Create or Update Flag Defaults by ProjectTool to create or update flag defaults for a specific project.
Reset Environment Mobile KeyTool to reset the mobile SDK key for a specific environment.
Reset Environment SDK KeyTool to reset the SDK key for a specific environment.
Reset Relay Proxy Configuration KeyTool to reset the Relay Proxy configuration key.
Reset Access TokenTool to reset a LaunchDarkly access token, generating a new token value.
Search Audit Log EntriesSearch audit log entries in LaunchDarkly.
Search Context InstancesTool to search for context instances within a project and environment.
Search ContextsTool to search for contexts in a LaunchDarkly environment with flexible filtering and sorting.
Trigger Flag Import JobTool to trigger a single flag import run for an existing flag import configuration.
Update AnnouncementTool to update an existing announcement in LaunchDarkly using JSON Patch operations.
Update Big Segment Context TargetsTool to update context targets included or excluded in a big segment.
Update Context Flag SettingTool to enable or disable a feature flag for a specific context based on its context kind and key.
Create or Update Context KindTool to create or update a context kind in a LaunchDarkly project.
Update Experimentation SettingsTool to update experimentation settings for a project.
Update Flag LinkTool to update an existing flag link in LaunchDarkly using JSON Patch operations.
Update Integration ConfigurationTool to update an existing integration configuration in LaunchDarkly using JSON Patch operations.
Update LayerTool to update a layer using semantic patch instructions.
Update Phase StatusTool to update the execution status of a phase in a feature flag release.
Update Release PipelineTool to update an existing release pipeline in LaunchDarkly.
Update Release Policies OrderTool to update the order of existing release policies for a project.
Update Release PolicyTool to update an existing release policy for a specified project.
Update Audit Log SubscriptionTool to update an audit log subscription configuration using JSON Patch operations.
Upsert Branch in Code Reference RepositoryTool to upsert (create or update) a branch in a LaunchDarkly code reference repository.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

Before starting, make sure you have:
  • Composio API Key and OpenAI API Key
  • Primary know-how of OpenAI Agents SDK
  • A live Launch darkly project
  • Some knowledge of Python or Typescript

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key

Install dependencies

pip install composio_openai_agents openai-agents python-dotenv

Install the Composio SDK and the OpenAI Agents SDK.

Set up environment variables

bash
OPENAI_API_KEY=sk-...your-api-key
COMPOSIO_API_KEY=your-api-key
USER_ID=composio_user@gmail.com

Create a .env file and add your OpenAI and Composio API keys.

Import dependencies

import asyncio
import os
from dotenv import load_dotenv

from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner, HostedMCPTool, SQLiteSession
What's happening:
  • You're importing all necessary libraries.
  • The Composio and OpenAIAgentsProvider classes are imported to connect your OpenAI agent to Composio tools like Launch darkly.

Set up the Composio instance

load_dotenv()

api_key = os.getenv("COMPOSIO_API_KEY")
user_id = os.getenv("USER_ID")

if not api_key:
    raise RuntimeError("COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key")

# Initialize Composio
composio = Composio(api_key=api_key, provider=OpenAIAgentsProvider())
What's happening:
  • load_dotenv() loads your .env file so OPENAI_API_KEY and COMPOSIO_API_KEY are available as environment variables.
  • Creating a Composio instance using the API Key and OpenAIAgentsProvider class.

Create a Tool Router session

# Create a Launch darkly Tool Router session
session = composio.create(
    user_id=user_id,
    toolkits=["launch_darkly"]
)

mcp_url = session.mcp.url

What is happening:

  • You give the Tool Router the user id and the toolkits you want available. Here, it is only launch_darkly.
  • The router checks the user's Launch darkly connection and prepares the MCP endpoint.
  • The returned session.mcp.url is the MCP URL that your agent will use to access Launch darkly.
  • This approach keeps things lightweight and lets the agent request Launch darkly tools only when needed during the conversation.

Configure the agent

# Configure agent with MCP tool
agent = Agent(
    name="Assistant",
    model="gpt-5",
    instructions=(
        "You are a helpful assistant that can access Launch darkly. "
        "Help users perform Launch darkly operations through natural language."
    ),
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "tool_router",
                "server_url": mcp_url,
                "headers": {"x-api-key": api_key},
                "require_approval": "never",
            }
        )
    ],
)
What's happening:
  • We're creating an Agent instance with a name, model (gpt-5), and clear instructions about its purpose.
  • The agent's instructions tell it that it can access Launch darkly and help with queries, inserts, updates, authentication, and fetching database information.
  • The tools array includes a HostedMCPTool that connects to the MCP server URL we created earlier.
  • The headers dict includes the Composio API key for secure authentication with the MCP server.
  • require_approval: 'never' means the agent can execute Launch darkly operations without asking for permission each time, making interactions smoother.

Start chat loop and handle conversation

print("\nComposio Tool Router session created.")

chat_session = SQLiteSession("conversation_openai_toolrouter")

print("\nChat started. Type your requests below.")
print("Commands: 'exit', 'quit', or 'q' to end\n")

async def main():
    try:
        result = await Runner.run(
            agent,
            "What can you help me with?",
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")
    except Exception as e:
        print(f"Error: {e}\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "q"}:
            print("Goodbye!")
            break

        result = await Runner.run(
            agent,
            user_input,
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")

asyncio.run(main())
What's happening:
  • The program prints a session URL that you visit to authorize Launch darkly.
  • After authorization, the chat begins.
  • Each message you type is processed by the agent using Runner.run().
  • The responses are printed to the console, and conversations are saved locally using SQLite.
  • Typing exit, quit, or q cleanly ends the chat.

Complete Code

Here's the complete code to get you started with Launch darkly and OpenAI Agents SDK:

import asyncio
import os
from dotenv import load_dotenv

from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner, HostedMCPTool, SQLiteSession

load_dotenv()

api_key = os.getenv("COMPOSIO_API_KEY")
user_id = os.getenv("USER_ID")

if not api_key:
    raise RuntimeError("COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key")

# Initialize Composio
composio = Composio(api_key=api_key, provider=OpenAIAgentsProvider())

# Create Tool Router session
session = composio.create(
    user_id=user_id,
    toolkits=["launch_darkly"]
)
mcp_url = session.mcp.url

# Configure agent with MCP tool
agent = Agent(
    name="Assistant",
    model="gpt-5",
    instructions=(
        "You are a helpful assistant that can access Launch darkly. "
        "Help users perform Launch darkly operations through natural language."
    ),
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "tool_router",
                "server_url": mcp_url,
                "headers": {"x-api-key": api_key},
                "require_approval": "never",
            }
        )
    ],
)

print("\nComposio Tool Router session created.")

chat_session = SQLiteSession("conversation_openai_toolrouter")

print("\nChat started. Type your requests below.")
print("Commands: 'exit', 'quit', or 'q' to end\n")

async def main():
    try:
        result = await Runner.run(
            agent,
            "What can you help me with?",
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")
    except Exception as e:
        print(f"Error: {e}\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "q"}:
            print("Goodbye!")
            break

        result = await Runner.run(
            agent,
            user_input,
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")

asyncio.run(main())

Conclusion

This was a starter code for integrating Launch darkly MCP with OpenAI Agents SDK to build a functional AI agent that can interact with Launch darkly.

Key features:

  • Hosted MCP tool integration through Composio's Tool Router
  • SQLite session persistence for conversation history
  • Simple async chat loop for interactive testing
You can extend this by adding more toolkits, implementing custom business logic, or building a web interface around the agent.

How to build Launch darkly MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Launch darkly MCP?

With a standalone Launch darkly MCP server, the agents and LLMs can only access a fixed set of Launch darkly tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Launch darkly and many other apps based on the task at hand, all through a single MCP endpoint.

Can I use Tool Router MCP with OpenAI Agents SDK?

Yes, you can. OpenAI Agents SDK fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Launch darkly tools.

Can I manage the permissions and scopes for Launch darkly while using Tool Router?

Yes, absolutely. You can configure which Launch darkly scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Launch darkly data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.