How to integrate Open sea MCP with CrewAI

Framework Integration Gradient
Open sea Logo
CrewAI Logo
divider

Introduction

This guide walks you through connecting Open sea to CrewAI using the Composio tool router. By the end, you'll have a working Open sea agent that can list my nft for sale on opensea, show all active listings in bored ape collection, create an offer for a specific cryptopunk, fetch my opensea profile details through natural language commands.

This guide will help you understand how to give your CrewAI agent real control over a Open sea account through Composio's Open sea MCP server.

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

TL;DR

Here's what you'll learn:
  • Get a Composio API key and configure your Open sea connection
  • Set up CrewAI with an MCP enabled agent
  • Create a Tool Router session or standalone MCP server for Open sea
  • Build a conversational loop where your agent can execute Open sea operations

What is CrewAI?

CrewAI is a powerful framework for building multi-agent AI systems. It provides primitives for defining agents with specific roles, creating tasks, and orchestrating workflows through crews.

Key features include:

  • Agent Roles: Define specialized agents with specific goals and backstories
  • Task Management: Create tasks with clear descriptions and expected outputs
  • Crew Orchestration: Combine agents and tasks into collaborative workflows
  • MCP Integration: Connect to external tools through Model Context Protocol

What is the Open sea MCP server, and what's possible with it?

The Open sea MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your OpenSea account. It provides structured and secure access to your NFT marketplace activity, so your agent can perform actions like listing NFTs for sale, creating and fulfilling offers, checking account details, and managing your marketplace orders on your behalf.

  • NFT listing automation: Quickly list any ERC721 or ERC1155 NFT for sale on OpenSea, specifying price and collection details—all handled by your agent.
  • Offer creation and management: Instruct your agent to create criteria-based or single-item offers to purchase specific NFTs or those matching certain traits within a collection.
  • Order and listing fulfillment: Let your agent retrieve all necessary information and signatures to fulfill existing listings or offers, making transactions seamless and secure.
  • Marketplace activity insights: Have the agent pull your profile details, fetch all active listings or offers for a given collection, and provide you with up-to-date marketplace snapshots.
  • Order cancellation and management: Direct your agent to cancel open orders, listings, or offers off-chain, helping you stay in control of your marketplace participation with ease.

Supported Tools & Triggers

Tools
Build criteria offerBuild a portion of a criteria offer including the merkle tree needed to post an offer.
Cancel orderOffchain cancel a single order, offer or listing, by its order hash when protected by the signedzone.
Create criteria offerCreate a criteria offer to purchase any nft in a collection or which matches the specified trait.
Create item offerCreate an offer to purchase a single nft (erc721 or erc1155).
Create listingList a single nft (erc721 or erc1155) for sale on the opensea marketplace.
Fulfill listingRetrieve all the information, including signatures, needed to fulfill a listing directly onchain.
Fulfill offerRetrieve all the information, including signatures, needed to fulfill an offer directly onchain.
Get accountGet an opensea account profile including details such as bio, social media usernames, and profile image.
Get all listings by collectionGet all active, valid listings for a single collection.
Get all offers by collectionGet all active, valid offers for the specified collection.
Get best listing by nftGet the best listing for an nft.
Get best listings by collectionGet the cheapest priced active, valid listings on a single collection.
Get best offer by nftGet the best offers for an nft.
Get collectionGet a single collection including details such as fees, traits, and links.
Get collectionsGet a list of opensea collections with optional filtering and pagination.
Get collection statsGet stats for a single collection on opensea.
Get contractGet a smart contract for a given chain and address.
Get eventsGet a list of events from opensea based on various filters like timestamps and event types.
Get listingsGet the complete set of active, valid listings.
Get nftGet metadata, traits, ownership information, and rarity for a single nft.
Get orderGet a single order, offer or listing, by its order hash.
Get payment tokenGet a smart contract for a given chain and address.
Get traitsGet the traits in a collection.
Refresh nft metadataRefresh metadata for a single nft.

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

What is Tool Router?

Composio's Tool Router 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 Tool Router

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

How the Tool Router works

The Tool Router 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:
  • Python 3.9 or higher
  • A Composio account and API key
  • A Open sea connection authorized in Composio
  • An OpenAI API key for the CrewAI LLM
  • Basic familiarity with Python

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
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.

Install dependencies

bash
pip install composio crewai crewai-tools python-dotenv
What's happening:
  • composio connects your agent to Open sea via MCP
  • crewai provides Agent, Task, Crew, and LLM primitives
  • crewai-tools includes MCP helpers
  • python-dotenv loads environment variables from .env

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates with Composio
  • USER_ID scopes the session to your account
  • OPENAI_API_KEY lets CrewAI use your chosen OpenAI model

Import dependencies

python
from crewai import Agent, Task, Crew, LLM
from crewai_tools import MCPServerAdapter  # optional import if you plan to adapt tools
from composio import Composio
from dotenv import load_dotenv
import os
from crewai.mcp import MCPServerHTTP

load_dotenv()
What's happening:
  • CrewAI classes define agents and tasks, and run the workflow
  • MCPServerHTTP connects the agent to an MCP endpoint
  • Composio will give you a short lived Open sea MCP URL

Create a Composio Tool Router session for Open sea

python
composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
session = composio.create(
    user_id=os.getenv("USER_ID"),
    toolkits=["open_sea"],
)
url = session.mcp.url
What's happening:
  • You create a Open sea only session through Composio
  • Composio returns an MCP HTTP URL that exposes Open sea tools

Configure the LLM

python
llm = LLM(
    model="gpt-5-mini",
    api_key=os.getenv("OPENAI_API_KEY"),
)
What's happening:
  • CrewAI will call this LLM for planning and responses
  • You can swap in a different model if needed

Attach the MCP server and create the agent

python
toolkit_agent = Agent(
    role="Open sea Assistant",
    goal="Help users interact with Open sea through natural language commands",
    backstory=(
        "You are an expert assistant with access to Open sea tools. "
        "You can perform various Open sea operations on behalf of the user."
    ),
    mcps=[
        MCPServerHTTP(
            url=url,
            streamable=True,
            cache_tools_list=True,
            headers={"x-api-key": os.getenv("COMPOSIO_API_KEY")},
        ),
    ],
    llm=llm,
    verbose=True,
    max_iter=10,
)
What's happening:
  • MCPServerHTTP connects the agent to the Open sea MCP endpoint
  • cache_tools_list saves a tools catalog for faster subsequent runs
  • verbose helps you see what the agent is doing

Add a REPL loop with Task and Crew

python
print("Chat started! Type 'exit' or 'quit' to end.\n")
print("Try asking the agent to perform Open sea operations.\n")

conversation_context = ""

while True:
    user_input = input("You: ").strip()

    if user_input.lower() in ["exit", "quit", "bye"]:
        print("\nGoodbye!")
        break

    if not user_input:
        continue

    conversation_context += f"\nUser: {user_input}\n"
    print("\nAgent is thinking...\n")

    task = Task(
        description=(
            f"Based on the conversation history:\n{conversation_context}\n\n"
            f"Current user request: {user_input}\n\n"
            f"Please help the user with their Open sea related request."
        ),
        expected_output="A helpful response addressing the user's request",
        agent=toolkit_agent,
    )

    crew = Crew(
        agents=[toolkit_agent],
        tasks=[task],
        verbose=False,
    )

    result = crew.kickoff()
    response = str(result)

    conversation_context += f"Agent: {response}\n"
    print(f"Agent: {response}\n")
What's happening:
  • You build a simple chat loop and keep a running context
  • Each user turn becomes a Task handled by the same agent
  • Crew executes the task and returns a response

Run the application

python
if __name__ == "__main__":
    main()
What's happening:
  • Standard Python entry point so you can run python crewai_open_sea_agent.py

Complete Code

Here's the complete code to get you started with Open sea and CrewAI:

python
# file: crewai_open_sea_agent.py
from crewai import Agent, Task, Crew, LLM
from crewai_tools import MCPServerAdapter  # optional
from composio import Composio
from dotenv import load_dotenv
import os
from crewai.mcp import MCPServerHTTP

load_dotenv()

def main():
    # Initialize Composio and create a Open sea session
    composio = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
    session = composio.create(
        user_id=os.getenv("USER_ID"),
        toolkits=["open_sea"],
    )
    url = session.mcp.url

    # Configure LLM
    llm = LLM(
        model="gpt-5-mini",
        api_key=os.getenv("OPENAI_API_KEY"),
    )

    # Create Open sea assistant agent
    toolkit_agent = Agent(
        role="Open sea Assistant",
        goal="Help users interact with Open sea through natural language commands",
        backstory=(
            "You are an expert assistant with access to Open sea tools. "
            "You can perform various Open sea operations on behalf of the user."
        ),
        mcps=[
            MCPServerHTTP(
                url=url,
                streamable=True,
                cache_tools_list=True,
                headers={"x-api-key": os.getenv("COMPOSIO_API_KEY")},
            ),
        ],
        llm=llm,
        verbose=True,
        max_iter=10,
    )

    print("Chat started! Type 'exit' or 'quit' to end the conversation.\n")
    print("Try asking the agent to perform Open sea operations.\n")

    conversation_context = ""

    while True:
        user_input = input("You: ").strip()

        if user_input.lower() in ["exit", "quit", "bye"]:
            print("\nGoodbye!")
            break

        if not user_input:
            continue

        conversation_context += f"\nUser: {user_input}\n"
        print("\nAgent is thinking...\n")

        task = Task(
            description=(
                f"Based on the conversation history:\n{conversation_context}\n\n"
                f"Current user request: {user_input}\n\n"
                f"Please help the user with their Open sea related request."
            ),
            expected_output="A helpful response addressing the user's request",
            agent=toolkit_agent,
        )

        crew = Crew(
            agents=[toolkit_agent],
            tasks=[task],
            verbose=False,
        )

        result = crew.kickoff()
        response = str(result)

        conversation_context += f"Agent: {response}\n"
        print(f"Agent: {response}\n")

if __name__ == "__main__":
    main()

Conclusion

You now have a CrewAI agent connected to Open sea through Composio's Tool Router. The agent can perform Open sea operations through natural language commands. Next steps:
  • Add role-specific instructions to customize agent behavior
  • Plug in more toolkits for multi-app workflows
  • Chain tasks for complex multi-step operations

How to build Open sea MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Open sea MCP?

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

Can I use Tool Router MCP with CrewAI?

Yes, you can. CrewAI 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 Open sea tools.

Can I manage the permissions and scopes for Open sea while using Tool Router?

Yes, absolutely. You can configure which Open sea 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 Open sea data and credentials are handled as safely as possible.

Used by agents from

Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
ASU
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.