How to integrate Clickup MCP with Vercel AI SDK

Framework Integration Gradient
Clickup Logo
Vercel AI SDK Logo
divider

Introduction

This guide walks you through connecting Clickup to Vercel AI SDK using the Composio tool router. By the end, you'll have a working Clickup agent that can add 'urgent' tag to today's tasks, create a time entry for design work, share project folder with new guest user, link related tasks for next sprint through natural language commands.

This guide will help you understand how to give your Vercel AI SDK agent real control over a Clickup account through Composio's Clickup 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:
  • How to set up and configure a Vercel AI SDK agent with Clickup integration
  • Using Composio's Tool Router to dynamically load and access Clickup tools
  • Creating an MCP client connection using HTTP transport
  • Building an interactive CLI chat interface with conversation history management
  • Handling tool calls and results within the Vercel AI SDK framework

What is Vercel AI SDK?

The Vercel AI SDK is a TypeScript library for building AI-powered applications. It provides tools for creating agents that can use external services and maintain conversation state.

Key features include:

  • streamText: Core function for streaming responses with real-time tool support
  • MCP Client: Built-in support for Model Context Protocol
  • Step Counting: Control multi-step tool execution
  • OpenAI Provider: Native integration with OpenAI models

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

The Clickup MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your ClickUp account. It provides structured and secure access to your projects, tasks, and team collaboration features, so your agent can manage tasks, add dependencies, assign guests, tag work, and streamline workflows on your behalf.

  • Automated task management: Easily have your agent create new time entries, add tasks to multiple lists, or link related tasks to keep your projects organized and up to date.
  • Dependency tracking and updates: Instruct your agent to set up 'waiting on' or 'blocking' dependencies between tasks, ensuring everything flows smoothly and work bottlenecks are visible and managed automatically.
  • Seamless guest access: Let your agent add guests to folders, lists, or individual tasks with specific permissions, helping external collaborators get the right level of access instantly.
  • Tagging and time entry management: Direct your agent to add or update tags on time entries, or manage tags for specific tasks, enabling better tracking and reporting for your team's efforts.
  • Task and list organization: Have your agent quickly add existing tasks to additional lists or update key task attributes, so you can adapt to new priorities without manual effort.

Supported Tools & Triggers

Tools
Add dependencyAdds a 'waiting on' or 'blocking' dependency to a task, requiring either `depends on` (task becomes waiting on) or `dependency of` (task becomes blocking), but not both; `team id` is required if `custom task ids` is true.
Add guest to folderAdds a guest to a folder with specified permissions; requires a clickup enterprise plan.
Add guest to listShares a clickup list with an existing guest user, granting them specified permissions; requires the workspace to be on the clickup enterprise plan.
Add guest to taskAssigns a guest to a task with specified permissions; requires clickup enterprise plan, and `team id` if `custom task ids` is true.
Add tags from time entriesAssociates a list of specified tags with one or more time entries within a given team (workspace).
Add tag to taskAdds an existing tag to a specified task; team id is required if custom task ids is true.
Add task linkLinks two existing and accessible clickup tasks, identified by `task id` (source) and `links to` (target).
Add task to listAdds an existing task to an additional clickup list; the "tasks in multiple lists" clickapp must be enabled in the workspace for this.
Change tag names from time entriesUpdates the name, background color, and/or foreground color for an existing time entry tag, identified by its current `name` and `team id`.
Create a time entryCreates a new time entry for a specified team.
Create chat view commentPosts a new comment to a specified clickup chat view; the 'view id' must correspond to an existing and accessible chat view.
Create checklistCreates a new checklist with a specified name within an existing task, which can be identified by its standard id or a custom task id (if `custom task ids` is true, `team id` is also required).
Create checklist itemCreates a new checklist item within a specified, existing checklist, optionally setting the item's name and assigning it to a user.
Create folderCreates a new clickup folder within the specified space, which must exist and be accessible.
Create folderless listCreates a new folderless list (a list not part of any folder) directly within a specified clickup space.
Create folder viewCreates a new, highly customizable view within a specific clickup folder using its `folder id`.
Create goalCreates a new goal in a clickup team (workspace).
Create key resultCreates a new key result (target) for a specified goal in clickup to define and track measurable objectives towards achieving that goal.
Create listCreates a new list in clickup within a specified, existing folder.
Create list commentAdds a new comment with specific text to an existing and accessible clickup list, assigns it to a user, and sets notification preferences for all list members.
Create list viewCreates a new, customizable view (e.
Create spaceCreates a new space in a clickup team, with customizable name, privacy, color, and feature settings.
Create space tagCreates a new tag (name, foreground color, background color) in an existing clickup space.
Create space viewCreates a customizable view (e.
Create a taskCreates a new clickup task in a specific list, optionally as a subtask if a `parent` task id (which cannot be a subtask itself and must be in the same list) is provided.
Create task attachmentUploads a file as an attachment to a specified clickup task, requiring `multipart/form-data` for file upload.
Create task commentAdds a comment to a clickup task; `team id` is required if `custom task ids` is true.
Create task from templateCreates a new task in a specified clickup list from a task template, using the provided name for the new task.
Create teamCreates a new team (user group) with specified members in a workspace; member ids must be for existing users, and be aware that adding view-only guests as paid members may incur extra charges.
Create webhookCreates a clickup webhook for a team (workspace) to notify a public url on specified events (at least one, or '*' for all), optionally scoped to a space, folder, list, or task; the endpoint must accept requests from dynamic ips.
Create workspace Everything level viewCreates a new, customizable view (e.
Delete a time entryDeletes an existing time entry, specified by `timer id`, from a workspace identified by `team id`.
Delete checklistPermanently deletes an existing checklist identified by its `checklist id`.
Delete checklist itemPermanently deletes an existing item, identified by `checklist item id`, from an existing checklist, identified by `checklist id`.
Delete commentDeletes an existing comment from a task using its `comment id`.
Delete dependencyRemoves two dependency links for `task id`: one where `task id` is blocked by `depends on`, and another where `dependency of` is blocked by `task id`; `team id` is required if `custom task ids` is true.
Delete folderPermanently and irreversibly deletes a specified folder and all its contents (lists, tasks) if the folder id exists.
Delete goalPermanently removes an existing goal, identified by its `goal id`, from the workspace.
Delete key resultDeletes an existing key result, also referred to as a target within a goal, identified by its `key result id`.
Delete listPermanently deletes an existing list and all its contents; this action is destructive and irreversible via the api.
Delete spacePermanently deletes a specified space in clickup; this action is irreversible as the space cannot be recovered via the api.
Delete space tagDeletes a tag from a space, identified by `tag name` in path; precise matching of tag details in the request body (`tag name 1`, `tag tag fg`, `tag tag bg`) is generally required for successful deletion.
Delete taskPermanently deletes a task, using its standard id or a custom task id (requires `custom task ids=true` and `team id`).
Delete task linkDeletes an existing link, effectively a dependency or relationship, between two clickup tasks; set `custom task ids=true` and provide `team id` if using custom task ids.
Delete teamPermanently deletes an existing team (user group) from the workspace using its `group id`.
Delete time trackedDeletes a time-tracked interval from a task; use this legacy endpoint for older time tracking systems.
Delete viewPermanently and irreversibly deletes an existing view in clickup, identified by its `view id`.
Delete webhookPermanently removes an existing webhook, specified by its id, thereby ceasing all its event monitoring and notifications.
Edit checklistUpdates an existing checklist's name or position, identified by its `checklist id`.
Edit checklist itemUpdates an existing checklist item, allowing modification of its name, assignee, resolution status, or parent item for nesting.
Edit guest on workspaceModifies the details and permissions of an existing guest user within a specific workspace.
Edit key resultUpdates an existing key result's progress or note in clickup, where the key result measures progress towards a goal.
Edit space tagUpdates an existing tag's name and colors in a clickup space; requires current tag name for identification, and new values for tag name, foreground color, and background color, all of which are mandatory for the update.
Edit time trackedEdits a legacy time-tracked interval for a task (identified by `task id` and `interval id`) to update its start/end times and duration; `team id` is required if `custom task ids` is true.
Edit user on workspaceUpdates a user's username, admin status, or custom role in a workspace; requires the workspace to be on an enterprise plan.
Get accessible custom fieldsRetrieves all accessible custom field definitions for a specified clickup list using its `list id`.
Get access tokenExchanges a clickup oauth 2.
Get all tags from time entriesRetrieves all unique tags applied to time entries within a specified clickup team (workspace).
Get authorized teams workspacesRetrieves a list of workspaces (teams) the authenticated user can access.
Get authorized userRetrieves the details of the currently authenticated clickup user.
Get bulk tasks time in statusRetrieves the time spent in each status for multiple tasks; requires the 'total time in status' clickapp to be enabled in the workspace.
Get chat view commentsRetrieves comments from a specified chat view in clickup, supporting pagination via `start` and `start id` to fetch comments older than the default 25 most recent.
Get custom rolesRetrieves all custom roles, which allow granular permission configurations, for a specified workspace (team).
Get custom task typesRetrieves all custom task types available within a specified workspace (team id).
Get filtered team tasksRetrieves a paginated list of tasks (up to 100 per page) from a specified team (workspace id in `team id`) based on various filter criteria, respecting user access permissions.
Get folderRetrieves detailed information about a specific folder in clickup.
Get folderless listsRetrieves all lists within a specified space that are not located in any folder.
Get foldersRetrieves folders within a specified clickup space, ensuring `space id` is valid, with an option to filter by archived status.
Get folder viewsRetrieves all configured views (like list, board, calendar) for a specified, existing folder in clickup.
Get goalRetrieves detailed information for an existing clickup goal, specified by its unique `goal id`.
Get goalsRetrieves goals for a specified clickup workspace (team); the `team id` must be valid and accessible.
Get guestCall this to retrieve detailed information for a specific guest within a team (workspace), ensuring the `guest id` is valid for the given `team id`; this action requires the clickup enterprise plan.
Get listRetrieves detailed information for an existing list in clickup, identified by its unique `list id`.
Get list commentsRetrieves comments for a specific clickup list, supporting pagination using `start` (timestamp) and `start id` (comment id) to fetch earlier comments; omits them for the latest 25.
Get list membersRetrieves all members of a specific, existing clickup list by its id.
Get listsRetrieves all lists within a specified, existing clickup folder, optionally filtering by archived status.
Get list viewsRetrieves all task and page views for a specified and accessible clickup list.
Get running time entryRetrieves the currently active time entry for a user in a workspace; a negative 'duration' in its data indicates it's running, and the response may be empty if no entry is active.
Get singular time entryFetches a specific time entry by its id for a given team; a negative duration in the response indicates an active timer.
Get spaceRetrieves detailed information for an existing space in a clickup workspace, identified by its unique space id.
Get spacesRetrieves spaces for a team id; member information for private spaces is returned only if the authenticated user is a member.
Get space tagsRetrieves all tags for tasks within a specified clickup space, requiring a valid `space id`.
Get space viewsRetrieves all task and page views for a specified space id in clickup.
Get taskRetrieves comprehensive details for a clickup task by its id, supporting standard or custom task ids (requires `team id` for custom ids).
Get task commentsRetrieves up to 25 comments for a specified task, supporting pagination using `start` and `start id` to fetch older comments.
Get task membersRetrieves users with explicit access (directly assigned or shared) to a specific existing task, excluding users with inherited permissions.
Get tasksRetrieves tasks from a specified clickup list; only tasks whose home is the given list id are returned.
Get task s time in statusRetrieves the duration a task has spent in each status, provided the 'total time in status' clickapp is enabled for the workspace.
Get task templatesRetrieves task templates for a specified workspace (team id), supporting pagination.
Get teamsRetrieves user groups (teams) from a clickup workspace, typically requiring `team id` (workspace id), with an option to filter by `group ids`.
Get time entries within a date rangeRetrieves time entries for a specified team (workspace id) within a date range (defaults to the last 30 days for the authenticated user if dates are omitted); active timers are indicated by negative durations in the response.
Get time entry historyRetrieves the modification history for an existing time entry within a specific clickup team (workspace).
Get tracked timeRetrieves tracked time for a task using a legacy endpoint; prefer newer time tracking api endpoints for managing time entries.
Get userRetrieves detailed information for a specific user within a clickup workspace (team), available only for workspaces on the clickup enterprise plan.
Get viewFetches details for a specific clickup view, identified by its `view id`, which must exist.
Get view tasksRetrieves all tasks visible in a specified clickup view, respecting its applied filters, sorting, and grouping.
Get webhooksFetches webhooks for a team (workspace), returning only those created by the authenticated user via api, for a `team id` they can access.
Get workspace everything level viewsRetrieves all task and page views at the 'everything level' (a comprehensive overview of all tasks across all spaces) for a specified clickup workspace.
Get workspace planRetrieves the details of the current subscription plan for a specified clickup workspace.
Get workspace seatsRetrieves seat utilization (used, total, available for members/guests) for a clickup workspace (team) id, which must be for an existing workspace.
Invite guest to workspaceInvites a guest by email to a clickup workspace (team) on an enterprise plan, setting initial permissions and optionally a custom role; further access configuration for specific items may require separate actions.
Invite user to workspaceInvites a user via email to a clickup workspace (team), optionally granting admin rights or a custom role; requires an enterprise plan for the workspace.
Remove custom field valueRemoves an existing value from a custom field on a specific task; this does not delete the custom field definition or its predefined options.
Remove guest from folderRevokes a guest's access to a specific clickup folder, optionally unsharing items explicitly shared with them within it; requires an enterprise plan.
Remove guest from listRevokes a guest's access to a specific list, provided the guest currently has access to this list and the workspace is on the clickup enterprise plan.
Remove guest from taskRevokes a guest's access to a specific task; only available for workspaces on the clickup enterprise plan.
Remove guest from workspacePermanently removes a guest from a specified workspace, revoking all their access; this destructive operation requires the workspace to be on the clickup enterprise plan.
Remove tag from taskRemoves a tag from a specified task by disassociating it (does not delete the tag from workspace), succeeding even if the tag is not on the task.
Remove tags from time entriesRemoves tags from specified time entries in a team, without deleting the tags from the workspace.
Remove task from listRemoves a task from an extra list (not its home list); the 'tasks in multiple lists' clickapp must be enabled.
Remove user from workspaceDeactivates a user from a specified clickup workspace, revoking their access (user can be reactivated later); requires the workspace to be on an enterprise plan.
Set custom field valueSets or updates a custom field's value for a task; the new value (with type-dependent structure, e.
Shared hierarchyRetrieves the hierarchy of tasks, lists, and folders shared with the authenticated user within an existing clickup team (workspace), identified by its `team id`.
Start a time entryStarts a new time entry (timer) in the specified team (workspace), optionally associating it with a task, adding a description, setting billable status, or applying tags (tags feature requires business plan or higher).
Stop a time entryStops the authenticated user's currently active time entry in the specified team (workspace), which requires an existing time entry to be running.
Track timeRecords a time entry for a task using clickup's legacy time tracking system; newer endpoints are generally recommended.
Update a time entryUpdates an existing clickup time entry; provide `start` and `end` times together, and include `team id` as a query param (request field `team id 1`) if `custom task ids` is true.
Update commentUpdates an existing task comment's text, assignee (who must be a valid workspace member), or resolution status, requiring a valid existing comment id.
Update folderUpdates the name of an existing folder in clickup.
Update goalUpdates attributes of an existing clickup goal, identified by its `goal id`.
Update listUpdates attributes of an existing clickup list, such as its name, content, due date, priority, assignee, or color status, identified by its `list id`.
Update spaceUpdates an existing clickup space, allowing modification of its name, color, privacy, and feature settings (clickapps).
Update taskUpdates attributes of an existing task; `team id` is required if `custom task ids` is true, use a single space (" ") for `description` to clear it, and provide at least one modifiable field.
Update teamUpdates an existing clickup user group (team) using its `group id`; note that adding a view-only guest as a paid member may incur charges.
Update viewUpdates an existing clickup view's settings such as name, type, grouping, or filters; ensure `parent id` and `parent type` define a valid hierarchy, and that specified field names (e.
Update webhookUpdates the endpoint url, monitored events, and status of an existing webhook, identified by its `webhook id`.

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 you begin, make sure you have:
  • Node.js and npm installed
  • A Composio account with API key
  • An OpenAI API key

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 required dependencies

bash
npm install @ai-sdk/openai @ai-sdk/mcp @composio/core ai dotenv

First, install the necessary packages for your project.

What you're installing:

  • @ai-sdk/openai: Vercel AI SDK's OpenAI provider
  • @ai-sdk/mcp: MCP client for Vercel AI SDK
  • @composio/core: Composio SDK for tool integration
  • ai: Core Vercel AI SDK
  • dotenv: Environment variable management

Set up environment variables

bash
OPENAI_API_KEY=your_openai_api_key_here
COMPOSIO_API_KEY=your_composio_api_key_here
COMPOSIO_USER_ID=your_user_id_here

Create a .env file in your project root.

What's needed:

  • OPENAI_API_KEY: Your OpenAI API key for GPT model access
  • COMPOSIO_API_KEY: Your Composio API key for tool access
  • COMPOSIO_USER_ID: A unique identifier for the user session

Import required modules and validate environment

typescript
import "dotenv/config";
import { openai } from "@ai-sdk/openai";
import { Composio } from "@composio/core";
import * as readline from "readline";
import { streamText, type ModelMessage, stepCountIs } from "ai";
import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";

const composioAPIKey = process.env.COMPOSIO_API_KEY;
const composioUserID = process.env.COMPOSIO_USER_ID;

if (!process.env.OPENAI_API_KEY) throw new Error("OPENAI_API_KEY is not set");
if (!composioAPIKey) throw new Error("COMPOSIO_API_KEY is not set");
if (!composioUserID) throw new Error("COMPOSIO_USER_ID is not set");

const composio = new Composio({
  apiKey: composioAPIKey,
});
What's happening:
  • We're importing all necessary libraries including Vercel AI SDK's OpenAI provider and Composio
  • The dotenv/config import automatically loads environment variables
  • The MCP client import enables connection to Composio's tool server

Create Tool Router session and initialize MCP client

typescript
async function main() {
  // Create a tool router session for the user
  const { session } = await composio.create(composioUserID!, {
    toolkits: ["clickup"],
  });

  const mcpUrl = session.mcp.url;
What's happening:
  • We're creating a Tool Router session that gives your agent access to Clickup tools
  • The create method takes the user ID and specifies which toolkits should be available
  • The returned mcp object contains the URL and authentication headers needed to connect to the MCP server
  • This session provides access to all Clickup-related tools through the MCP protocol

Connect to MCP server and retrieve tools

typescript
const mcpClient = await createMCPClient({
  transport: {
    type: "http",
    url: mcpUrl,
    headers: session.mcp.headers, // Authentication headers for the Composio MCP server
  },
});

const tools = await mcpClient.tools();
What's happening:
  • We're creating an MCP client that connects to our Composio Tool Router session via HTTP
  • The mcp.url provides the endpoint, and mcp.headers contains authentication credentials
  • The type: "http" is important - Composio requires HTTP transport
  • tools() retrieves all available Clickup tools that the agent can use

Initialize conversation and CLI interface

typescript
let messages: ModelMessage[] = [];

console.log("Chat started! Type 'exit' or 'quit' to end the conversation.\n");
console.log(
  "Ask any questions related to clickup, like summarize my last 5 emails, send an email, etc... :)))\n",
);

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  prompt: "> ",
});

rl.prompt();
What's happening:
  • We initialize an empty messages array to maintain conversation history
  • A readline interface is created to accept user input from the command line
  • Instructions are displayed to guide the user on how to interact with the agent

Handle user input and stream responses with real-time tool feedback

typescript
rl.on("line", async (userInput: string) => {
  const trimmedInput = userInput.trim();

  if (["exit", "quit", "bye"].includes(trimmedInput.toLowerCase())) {
    console.log("\nGoodbye!");
    rl.close();
    process.exit(0);
  }

  if (!trimmedInput) {
    rl.prompt();
    return;
  }

  messages.push({ role: "user", content: trimmedInput });
  console.log("\nAgent is thinking...\n");

  try {
    const stream = streamText({
      model: openai("gpt-5"),
      messages,
      tools,
      toolChoice: "auto",
      stopWhen: stepCountIs(10),
      onStepFinish: (step) => {
        for (const toolCall of step.toolCalls) {
          console.log(`[Using tool: ${toolCall.toolName}]`);
          }
          if (step.toolCalls.length > 0) {
            console.log(""); // Add space after tool calls
          }
        },
      });

      for await (const chunk of stream.textStream) {
        process.stdout.write(chunk);
      }

      console.log("\n\n---\n");

      // Get final result for message history
      const response = await stream.response;
      if (response?.messages?.length) {
        messages.push(...response.messages);
      }
    } catch (error) {
      console.error("\nAn error occurred while talking to the agent:");
      console.error(error);
      console.log(
        "\nYou can try again or restart the app if it keeps happening.\n",
      );
    } finally {
      rl.prompt();
    }
  });

  rl.on("close", async () => {
    await mcpClient.close();
    console.log("\nđź‘‹ Session ended.");
    process.exit(0);
  });
}

main().catch((err) => {
  console.error("Fatal error:", err);
  process.exit(1);
});
What's happening:
  • We use streamText instead of generateText to stream responses in real-time
  • toolChoice: "auto" allows the model to decide when to use Clickup tools
  • stopWhen: stepCountIs(10) allows up to 10 steps for complex multi-tool operations
  • onStepFinish callback displays which tools are being used in real-time
  • We iterate through the text stream to create a typewriter effect as the agent responds
  • The complete response is added to conversation history to maintain context
  • Errors are caught and displayed with helpful retry suggestions

Complete Code

Here's the complete code to get you started with Clickup and Vercel AI SDK:

typescript
import "dotenv/config";
import { openai } from "@ai-sdk/openai";
import { Composio } from "@composio/core";
import * as readline from "readline";
import { streamText, type ModelMessage, stepCountIs } from "ai";
import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";

const composioAPIKey = process.env.COMPOSIO_API_KEY;
const composioUserID = process.env.COMPOSIO_USER_ID;

if (!process.env.OPENAI_API_KEY) throw new Error("OPENAI_API_KEY is not set");
if (!composioAPIKey) throw new Error("COMPOSIO_API_KEY is not set");
if (!composioUserID) throw new Error("COMPOSIO_USER_ID is not set");

const composio = new Composio({
  apiKey: composioAPIKey,
});

async function main() {
  // Create a tool router session for the user
  const { session } = await composio.create(composioUserID!, {
    toolkits: ["clickup"],
  });

  const mcpUrl = session.mcp.url;

  const mcpClient = await createMCPClient({
    transport: {
      type: "http",
      url: mcpUrl,
      headers: session.mcp.headers, // Authentication headers for the Composio MCP server
    },
  });

  const tools = await mcpClient.tools();

  let messages: ModelMessage[] = [];

  console.log("Chat started! Type 'exit' or 'quit' to end the conversation.\n");
  console.log(
    "Ask any questions related to clickup, like summarize my last 5 emails, send an email, etc... :)))\n",
  );

  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    prompt: "> ",
  });

  rl.prompt();

  rl.on("line", async (userInput: string) => {
    const trimmedInput = userInput.trim();

    if (["exit", "quit", "bye"].includes(trimmedInput.toLowerCase())) {
      console.log("\nGoodbye!");
      rl.close();
      process.exit(0);
    }

    if (!trimmedInput) {
      rl.prompt();
      return;
    }

    messages.push({ role: "user", content: trimmedInput });
    console.log("\nAgent is thinking...\n");

    try {
      const stream = streamText({
        model: openai("gpt-5"),
        messages,
        tools,
        toolChoice: "auto",
        stopWhen: stepCountIs(10),
        onStepFinish: (step) => {
          for (const toolCall of step.toolCalls) {
            console.log(`[Using tool: ${toolCall.toolName}]`);
          }
          if (step.toolCalls.length > 0) {
            console.log(""); // Add space after tool calls
          }
        },
      });

      for await (const chunk of stream.textStream) {
        process.stdout.write(chunk);
      }

      console.log("\n\n---\n");

      // Get final result for message history
      const response = await stream.response;
      if (response?.messages?.length) {
        messages.push(...response.messages);
      }
    } catch (error) {
      console.error("\nAn error occurred while talking to the agent:");
      console.error(error);
      console.log(
        "\nYou can try again or restart the app if it keeps happening.\n",
      );
    } finally {
      rl.prompt();
    }
  });

  rl.on("close", async () => {
    await mcpClient.close();
    console.log("\nđź‘‹ Session ended.");
    process.exit(0);
  });
}

main().catch((err) => {
  console.error("Fatal error:", err);
  process.exit(1);
});

Conclusion

You've successfully built a Clickup agent using the Vercel AI SDK with streaming capabilities! This implementation provides a powerful foundation for building AI applications with natural language interfaces and real-time feedback.

Key features of this implementation:

  • Real-time streaming responses for a better user experience with typewriter effect
  • Live tool execution feedback showing which tools are being used as the agent works
  • Dynamic tool loading through Composio's Tool Router with secure authentication
  • Multi-step tool execution with configurable step limits (up to 10 steps)
  • Comprehensive error handling for robust agent execution
  • Conversation history maintenance for context-aware responses

You can extend this further by adding custom error handling, implementing specific business logic, or integrating additional Composio toolkits to create multi-app workflows.

How to build Clickup MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Clickup MCP?

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

Can I use Tool Router MCP with Vercel AI SDK?

Yes, you can. Vercel AI 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 Clickup tools.

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

Yes, absolutely. You can configure which Clickup 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 Clickup 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.