How to integrate Wrike MCP with Vercel AI SDK v6

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Wrike logo
Vercel AI SDK logo
divider

Introduction

This guide walks you through connecting Wrike to Vercel AI SDK v6 using the Composio tool router. By the end, you'll have a working Wrike agent that can create a new task in marketing folder, add multiple users to project group, invite a teammate to the workspace through natural language commands.

This guide will help you understand how to give your Vercel AI SDK agent real control over a Wrike account through Composio's Wrike MCP server.

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

Also integrate Wrike with

TL;DR

Here's what you'll learn:
  • How to set up and configure a Vercel AI SDK agent with Wrike integration
  • Using Composio's Tool Router to dynamically load and access Wrike 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 via @ai-sdk/mcp
  • Step Counting: Control multi-step tool execution with stopWhen: stepCountIs()
  • OpenAI Provider: Native integration with OpenAI models

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

The Wrike MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Wrike account. It provides structured and secure access to your project spaces, so your agent can perform actions like creating tasks, managing folders, handling group memberships, sending workspace invitations, and automating project workflows on your behalf.

  • Automated task creation and management: Let your agent quickly create new tasks in specific folders, assign details, and keep your projects moving forward without manual input.
  • Dynamic folder and project organization: Have your agent generate new folders or subfolders to structure work, or clean up by deleting old folders and their contents when projects wrap up.
  • Efficient user and group management: Easily add, remove, or modify group memberships and create new user groups to keep team permissions organized and up-to-date.
  • Seamless workspace invitations: Direct your agent to invite teammates or collaborators to your Wrike workspace via email, including customizing invitation details for better onboarding.
  • Custom field and data cleanup: Empower your agent to delete custom fields, tasks, or groups when they're no longer needed, helping you maintain a clean and efficient workspace.

Supported Tools & Triggers

Tools
Bulk modify group membersAdds or removes members for multiple Wrike groups in a single request; all specified user IDs must correspond to existing Wrike users.
Copy folderCopies a Wrike folder synchronously to a specified parent location with customizable options.
Copy folder asyncDuplicate a folder asynchronously in Wrike, creating a copy in a specified parent location.
Create account webhooksCreates a webhook for the current account to receive notifications about changes.
Create equipment assetTool to create equipment/asset in Wrike.
Create custom fieldTool to create a new custom field in Wrike.
Create a folderCreates a new Wrike subfolder within the specified `folderId`, optionally as a project if `customItemTypeId` is given; the folder is auto-shared with its creator.
Create folder bookingTool to create a booking in a Wrike folder.
Create approval in folderTool to create a new approval in a Wrike folder.
Create folder commentCreates a new comment on a specified Wrike folder.
Create timelog lock period for folderCreates a timelog lock period for a specific folder.
Create a webhook on folderTool to create a webhook for a Wrike folder or project.
Create a groupCreates a new user group in Wrike with a specified title, optionally setting members, parent group, avatar, and custom metadata.
Create invitationInvites a user to a Wrike workspace by email, optionally with name, specifying EITHER `userTypeId` OR a combination of `role`/`external`; custom email subject/message available for paid accounts.
Create space timelog lock periodTool to create a timelog lock period for a space to prevent time entries from being edited.
Create space webhookTool to create a webhook on a Wrike space for receiving notifications about changes to tasks, folders, and projects.
Create task in folderCreates a new task in a specified Wrike folder; if setting priority with `priorityBefore` or `priorityAfter`, the referenced task must be in the same folder or project.
Create task attachmentTool to upload a file attachment to a Wrike task.
Create task commentTool to create a new comment on a Wrike task.
Create task approvalTool to create an approval on a specific task in Wrike.
Create task dependencyTool to create a new dependency relationship between Wrike tasks.
Create task timelogTool to create a timelog entry for a specific task in Wrike.
Create timesheetTool to create a timesheet for a user for a specified time period.
Create workflowsTool to create a new custom workflow in Wrike.
Delete approvalCancels/deletes an approval by its identifier.
Delete assetPermanently deletes a Wrike asset/equipment by assetId.
Delete attachmentTool to permanently delete a Wrike attachment by its ID.
Delete bookingPermanently removes a resource booking allocation by its ID; use when deallocating resources from projects or tasks.
Delete commentPermanently deletes a Wrike comment by its ID; this action is irreversible and the comment must exist.
Delete custom field by idPermanently deletes a custom field by its ID; this action is irreversible and requires a valid, existing custom field ID.
Delete dependenciesPermanently removes a task dependency relationship by its ID; use when unlinking predecessor/successor task relationships.
Delete folderPermanently deletes the folder specified by `folderId` and all its contents (e.
Delete timelog lock period for folderDeletes a timelog lock period for a specific folder.
Delete group by idPermanently deletes a group by its `groupId`; this action is irreversible and does not affect user accounts that were members of the group.
Delete invitationPermanently deletes an existing invitation, specified by its unique `invitationId`; this action cannot be undone.
Delete job rolePermanently deletes a job role by its identifier; deleted job roles are removed from all tasks and users and cannot be restored.
Delete spacePermanently deletes a Wrike space and all its contents by spaceId; this action is irreversible and should be used with caution.
Delete spaces timelog lock periodTool to unlock (delete) a timelog lock period for a specific space in Wrike.
Delete taskPermanently deletes a Wrike task and all its associated data by its ID; this action is irreversible and the task must exist.
Delete timelogPermanently deletes a Wrike timelog entry by its ID; use when removing an incorrect or obsolete time log entry.
Delete webhookTool to permanently delete a webhook by webhook_id.
Fetch all tasksFetches tasks from a Wrike account, allowing filtering by status, due date, and subfolder inclusion, with customizable response fields and pagination.
Get account informationRetrieves detailed Wrike account information, where the response content is influenced by selected fields, account subscription, and user permissions.
Get all custom fieldsRetrieves all custom field definitions (including ID, name, type, and settings) from the Wrike account; this returns the definitions themselves, not their specific values on Wrike items, and is useful for obtaining custom field IDs.
Get all webhooksTool to retrieve a list of all webhooks created using the same API token.
Get approvalsTool to retrieve all approvals accessible to the authenticated user.
Get approvals by IDsTool to retrieve specific Wrike approvals by their IDs (up to 100).
Get async job statusTool to retrieve status and details for an asynchronous job in Wrike.
Get attachments by IDsTool to retrieve multiple Wrike attachments by their IDs (up to 100).
Download attachmentTool to download a Wrike attachment file.
Get attachment previewTool to download a preview version of a Wrike attachment.
Get attachment URLTool to get a public access URL for a Wrike attachment.
Get bookingsRetrieves one or more Wrike bookings by their IDs.
Get colorsTool to query the list of available colors in Wrike.
Get commentsTool to retrieve all comments accessible to the authorized user.
Get comments by IDsTool to retrieve multiple Wrike comments by their IDs.
Get contact hourly ratesTool to retrieve hourly budget rates for up to 100 Wrike contacts.
Get contactsRetrieves a list of Wrike contacts (e.
Get contacts historyTool to access field modification history for Wrike contacts.
Get contact timelogsTool to retrieve all timelog records created by a specific contact in Wrike.
Get custom item typesTool to retrieve all custom item types from Wrike.
Get dependencies by IDsTool to retrieve one or more Wrike dependencies by their IDs (up to 100).
Get folder bookingsTool to query bookings for a specific folder in Wrike.
Get foldersRetrieves folders and/or projects from Wrike, with filters; when using `nextPageToken`, all other filter parameters must match the initial request.
Get folder approvalsTool to retrieve all approvals from a specific Wrike folder.
Get folder attachmentsTool to retrieve all attachments from a specific Wrike folder.
Get folders by IDsTool to retrieve multiple Wrike folders by their IDs.
Get folder commentsTool to retrieve comments from a specific Wrike folder.
Get folders historyTool to access field modification history for Wrike folders.
Get folder hourly ratesTool to retrieve hourly budget rates for a specific Wrike folder.
Get folder rollupsTool to query rollup settings for items in a folder.
Get folder tasksQuery tasks within a specific folder.
Get folder timelog lock periodsTool to query timelog lock periods for a specific folder.
Get folders timelogsTool to retrieve all timelog records for a specific folder.
Convert legacy v2 IDs to v4Tool to convert legacy Wrike API v2 IDs to current v4 format.
Get specific contact informationRetrieves detailed information for a specific Wrike contact using their unique `contactId`, optionally including `metadata` and `customFields` if specified in the `fields` parameter.
Get job roles by IDsTool to retrieve details for one or more Wrike job roles by job role IDs.
Get placeholder hourly ratesTool to retrieve hourly budget rates for one or more Wrike placeholders.
Get placeholders by IDsTool to retrieve details for one or more Wrike placeholders by their IDs.
Get space by IDTool to retrieve details for a single Wrike space by spaceId.
Get space custom item typesTool to retrieve all custom item types scoped to a specific Wrike space.
Get space foldersTool to retrieve the folder tree for a specific Wrike space.
Get space custom fieldsTool to retrieve all custom fields defined for a specific Wrike space.
Get spaces tasksTool to query tasks within a specific Wrike space.
Get space workflowsTool to query workflows for a specific Wrike space.
Get space timelog lock periodsTool to query timelog lock periods for a specific space.
Get specific userRetrieves detailed information about a specific user in Wrike using their unique user ID.
Get task by idRetrieves read-only detailed information for a specific Wrike task by its unique ID, optionally allowing specification of fields to include in the response.
Get task dependenciesRetrieves all dependency relationships for a specific task.
Get task approvalsRetrieves all approval records for a specific task.
Get task attachmentsTool to retrieve all attachments from a specific Wrike task.
Get task commentsTool to retrieve all comments from a specific Wrike task.
Get tasks historyQuery task field modification history for up to 100 tasks.
Get task rollupsTool to query rollup settings for a specific task.
Get task timelog lock periodsTool to query timelog lock periods for a specific task.
Get task timelogsRetrieves all timelog records for a specific task.
Get timelog categoriesTool to query the list of timelog categories in Wrike.
Get timelogsRetrieves timelog records from Wrike with optional filters for dates, users, and task scope.
Get timelogs by IDsRetrieves detailed information for one or more Wrike timelogs by their unique IDs (up to 100), optionally including export and lock status.
Get timesheetsTool to query timesheets from Wrike.
Get timesheet submission rulesTool to retrieve global timesheet submission rules across all work schedules.
Get API versionTool to retrieve current Wrike API version information.
Get webhook by IDTool to retrieve details for a specific webhook by webhook_id.
Get work schedule timesheet rulesTool to retrieve timesheet submission rules for a specific work schedule.
Launch folder blueprint asyncAsynchronously launches a new project or folder structure in Wrike from a specified Folder Blueprint.
Launch Task Blueprint AsyncAsynchronously launches a Wrike Task Blueprint to create tasks/projects, requiring either `super_task_id` (parent task) or `parent_id` (parent folder/project) for placement.
List all attachmentsTool to retrieve all attachments from the Wrike account.
List Folder BlueprintsRetrieves all account-level Folder Blueprints, which are templates for standardizing folder/project creation with predefined structures, custom fields, and workflows.
List all placeholdersRetrieves all placeholders accessible to the authenticated user; placeholders are templates used in Wrike for creating standardized tasks or projects.
List space folder blueprintsLists all folder blueprints (templates for new folders/projects) within a specified Wrike space, requiring a valid and accessible space ID.
List spacesTool to list spaces the authorized user can access.
List space task blueprintsLists task blueprints (templates for creating tasks with consistent structures) available in a specific, accessible Wrike space.
List subfolders by folder idLists subfolders (metadata only, not their contents) for an existing Wrike folder specified by `folderId`, supporting recursive descent, filtering, and pagination.
List Task BlueprintsRetrieves a list of defined Task Blueprints (predefined task templates) from the Wrike account, supporting pagination.
Update account metadataUpdates or adds custom key-value metadata to the Wrike account, useful for integrations, storing app-specific data, or mapping external system identifiers.
Modify folder attributesModifies an existing Wrike folder: updates title, description, parents (not root/recycle bin), sharing, metadata, custom fields/columns; restores, converts to project, or manages access roles.
Modify groupUpdates an existing Wrike user group's attributes like title, members, parent, avatar, or metadata, using its `groupId` and specifying only the fields to change.
Modify taskModifies an existing Wrike task by its ID, allowing updates to attributes such as title, status, dates, assignees, and custom fields; `priorityBefore` and `priorityAfter` are mutually exclusive, and parent folder IDs for `addParents`/`removeParents` cannot be the Recycle Bin.
Retrieve custom field by idRetrieves a Wrike custom field's detailed information (e.
Query invitationsRetrieves all active invitations in Wrike, useful for viewing and auditing pending invitations or managing user onboarding.
Query job rolesTool to retrieve all available job roles in the Wrike account.
Get group by idRetrieves detailed information for a specific Wrike group using its `groupId`, optionally including 'metadata'.
Query workflowsFetches a list of all workflows with their detailed information from the Wrike account; this is a read-only action and does not support pagination or filtering through its parameters.
Retrieve list of groupsRetrieves a list of user groups from the Wrike account, supporting metadata filtering, pagination, and inclusion of specific fields; this is a read-only operation.
Search eDiscoveryTool to perform eDiscovery search across Wrike items (folders, projects, tasks).
Update approvalUpdates an existing Wrike approval by its ID, allowing modifications to the title, description, and due date.
Update assetTool to update a Wrike asset/equipment by ID.
Update attachmentTool to update a Wrike attachment by uploading new file content.
Update bookingUpdates a Wrike booking's date range by ID.
Update commentTool to update an existing Wrike comment.
Update custom field by idUpdates properties of an existing Wrike custom field by its ID, such as its title, type, scope, or sharing settings.
Update dependencyTool to modify an existing Wrike dependency relationship between tasks.
Update folder rollup settingsTool to update rollup settings for a folder.
Update invitationUpdates a pending Wrike invitation (`invitationId`) to resend it or change user's role/type (use EITHER `userTypeId` OR `role`/`external`).
Update job roleUpdates an existing Wrike job role by its ID, allowing modifications to the title and short title.
Update metadata on a specific contactUpdates metadata, job role, or custom fields for an existing Wrike contact specified by `contactId`; if `jobRoleId` is provided, it must be a valid ID.
Update a specific userUpdates specified profile attributes (e.
Update task rollup settingsUpdates rollup settings for a task.
Update timelog entryTool to modify an existing timelog entry in Wrike.
Update timesheet rowUpdates a Wrike timesheet row by its ID, allowing modification of the timelog category.
Update timesheetTool to update a timesheet's approval status in Wrike.
Update webhook stateTool to update the state of a Wrike webhook.
Update workflowTool to modify an existing Wrike workflow.
Update work schedule timesheet rulesTool to update timesheet submission rules for a work schedule.

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 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 { 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: ["wrike"],
  });

  const mcpUrl = session.mcp.url;
What's happening:
  • We're creating a Tool Router session that gives your agent access to Wrike 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 Wrike-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 Wrike 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 wrike, 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 Wrike 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 Wrike 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 { 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: ["wrike"],
  });

  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 wrike, 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 Wrike 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 Wrike MCP Agent with another framework

FAQ

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

With a standalone Wrike MCP server, the agents and LLMs can only access a fixed set of Wrike tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Wrike 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 v6?

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

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

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