# How to integrate Sap successfactors MCP with Vercel AI SDK v6

```json
{
  "title": "How to integrate Sap successfactors MCP with Vercel AI SDK v6",
  "toolkit": "Sap successfactors",
  "toolkit_slug": "sap_successfactors",
  "framework": "Vercel AI SDK",
  "framework_slug": "ai-sdk",
  "url": "https://composio.dev/toolkits/sap_successfactors/framework/ai-sdk",
  "markdown_url": "https://composio.dev/toolkits/sap_successfactors/framework/ai-sdk.md",
  "updated_at": "2026-05-12T10:24:40.837Z"
}
```

## Introduction

This guide walks you through connecting Sap successfactors to Vercel AI SDK v6 using the Composio tool router. By the end, you'll have a working Sap successfactors agent that can show your current employee profile details, check your job title and department info, display your contact information in successfactors through natural language commands.
This guide will help you understand how to give your Vercel AI SDK agent real control over a Sap successfactors account through Composio's Sap successfactors MCP server.
Before we dive in, let's take a quick look at the key ideas and tools involved.

## Also integrate Sap successfactors with

- [ChatGPT](https://composio.dev/toolkits/sap_successfactors/framework/chatgpt)
- [OpenAI Agents SDK](https://composio.dev/toolkits/sap_successfactors/framework/open-ai-agents-sdk)
- [Claude Agent SDK](https://composio.dev/toolkits/sap_successfactors/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/sap_successfactors/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/sap_successfactors/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/sap_successfactors/framework/codex)
- [Cursor](https://composio.dev/toolkits/sap_successfactors/framework/cursor)
- [VS Code](https://composio.dev/toolkits/sap_successfactors/framework/vscode)
- [OpenCode](https://composio.dev/toolkits/sap_successfactors/framework/opencode)
- [OpenClaw](https://composio.dev/toolkits/sap_successfactors/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/sap_successfactors/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/sap_successfactors/framework/cli)
- [Google ADK](https://composio.dev/toolkits/sap_successfactors/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/sap_successfactors/framework/langchain)
- [Mastra AI](https://composio.dev/toolkits/sap_successfactors/framework/mastra-ai)
- [LlamaIndex](https://composio.dev/toolkits/sap_successfactors/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/sap_successfactors/framework/crew-ai)

## TL;DR

Here's what you'll learn:
- How to set up and configure a Vercel AI SDK agent with Sap successfactors integration
- Using Composio's Tool Router to dynamically load and access Sap successfactors 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 Sap successfactors MCP server, and what's possible with it?

The Sap successfactors MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Sap successfactors account. It provides structured and secure access to your HR data, so your agent can retrieve user information, access employee details, and drive workforce automation on your behalf.
- Current user profile retrieval: Instantly fetch the authenticated user's profile and access up-to-date information about their SAP SuccessFactors account.
- Employee data access: Allow your agent to securely obtain details about employees, enabling streamlined HR and workforce management workflows.
- Personalized onboarding support: Use user data to personalize onboarding experiences, helping new hires get up to speed faster with relevant, contextual information.
- Automated reporting: Enable your agent to pull user-related reports or summaries, supporting HR analytics and decision-making.
- Seamless integration with enterprise HR processes: Connect user data to other HR tools or workflows, making it easier to automate tasks like leave approvals or performance tracking.

## Supported Tools

| Tool slug | Name | Description |
|---|---|---|
| `SAP_SUCCESSFACTORS_APPROVE_CALIBRATION_SESSION` | Approve Calibration Session | Finalize a calibration session that is in the In Progress or Approving status. |
| `SAP_SUCCESSFACTORS_CREATE_A_FEEDBACK_REQUEST` | Create a Feedback Request | Create a feedback request in SAP SuccessFactors Continuous Feedback. Use when you need to request performance feedback from one employee about another. At least one question must be provided. |
| `SAP_SUCCESSFACTORS_CREATE_LEARNING_ACTIVITIES_BULK` | Create Learning Activities Bulk | Create learning activities and associate them with development goals in bulk (requires third-party LMS integration). |
| `SAP_SUCCESSFACTORS_CREATE_ONBOARDEE` | Create Onboardee | Creates a new onboardee in SAP SuccessFactors Onboarding 2.0 system. Use when initiating the onboarding process for a new hire or rehire. Requires admin create user permissions. |
| `SAP_SUCCESSFACTORS_CREATE_UPDATE_SUCCESSOR_NOMINATION` | Create or Update Successor Nomination | Create or update a successor nomination for a position or talent pool in succession planning. Use when you need to nominate or update a successor for a specific position or talent pool. |
| `SAP_SUCCESSFACTORS_DELETE_NOMINATION_POSITION_TALENT_POOL` | Delete Nomination | Delete a nomination for a position or talent pool in succession planning. Use when you need to remove a nominee from a position or talent pool nomination. |
| `SAP_SUCCESSFACTORS_GET_APPLICATION_INTERVIEW` | Get Application Interview | Retrieves interview information related to job applications from Interview Central. Use when you need to query interview schedules, statuses, or details for applicants. Note: This entity checks only the first 1000 records, so filtering by applicationId is recommended. |
| `SAP_SUCCESSFACTORS_GET_BACKGROUND_EDUCATION` | Get Background Education | Tool to retrieve background education records for employees from SAP SuccessFactors. Use when you need to query education history with support for filtering, field selection, and pagination via OData query options. Background entities use backgroundElementId as the unique key field. |
| `SAP_SUCCESSFACTORS_GET_BACKGROUND_MOBILITY` | Get Background Mobility | Retrieves mobility background records showing employee willingness to relocate. Use when you need to query employee geographic mobility preferences and location data. Results can be filtered and ordered by bgOrderPos to maintain screen display order. |
| `SAP_SUCCESSFACTORS_GET_CALIBRATION_SESSION_BY_ID` | Get Calibration Session By ID | Get a specific calibration session by session ID. |
| `SAP_SUCCESSFACTORS_GET_CALIBRATION_SESSIONS` | Get Calibration Sessions | Query all the calibration sessions that a user can access. |
| `SAP_SUCCESSFACTORS_GET_CALIBRATION_SUBJECT_BY_ID` | Get Calibration Subject By ID | Query a specific subject's competency ratings and ratings within a calibration session. |
| `SAP_SUCCESSFACTORS_GET_CALIBRATION_SUBJECT_RATINGS` | Get Calibration Subject Ratings | Query a subject's ratings, competency ratings, and comments by using session ID. |
| `SAP_SUCCESSFACTORS_GET_CDP_LEARNING_METADATA` | Get CDP Learning Metadata | Get metadata for Career Development Planning Learning service. |
| `SAP_SUCCESSFACTORS_GET_CURRENT_USER` | Get Current User | Retrieves the currently authenticated user's information from SAP SuccessFactors. |
| `SAP_SUCCESSFACTORS_GET_CUSTOM_MDF_OBJECT` | Get Custom MDF Object | Tool to retrieve custom MDF (Metadata Framework) objects from SAP SuccessFactors. Custom object names begin with cust_ prefix in the API. Use when you need to query custom business objects defined in the MDF framework. |
| `SAP_SUCCESSFACTORS_GET_EMP_EMPLOYMENT_TERMINATION` | Get Employee Employment Termination | Retrieves employee termination information records from SAP SuccessFactors. Contains details about employment terminations including termination date and reason. Use when you need to query termination records with support for filtering, field selection, expansion of related entities, and pagination via OData query options. |
| `SAP_SUCCESSFACTORS_GET_EMPLOYEE_TIME` | Get Employee Time | Retrieves employee time entries including time off records from SAP SuccessFactors. Use when you need to query approved leaves, time-off requests, or employee time tracking data. Supports filtering by userId, approvalStatus, timeType, and date ranges. |
| `SAP_SUCCESSFACTORS_GET_EMPLOYEE_TIMESHEET` | Get Employee Timesheet | Retrieves employee timesheet records for attendances, overtime, on-call times, and allowances. Use when you need to query employee timesheet data from SAP SuccessFactors. |
| `SAP_SUCCESSFACTORS_GET_EMP_PAY_COMP_NON_RECURRING` | Get Non-Recurring Pay Components | Tool to retrieve non-recurring pay component information including bonuses and one-time payments from SAP SuccessFactors. Use when you need data about employee bonuses, commissions, or other non-recurring compensation components. |
| `SAP_SUCCESSFACTORS_GET_EMP_PAY_COMP_RECURRING` | Get Recurring Pay Components | Tool to retrieve recurring pay component information including salary and benefits data from SAP SuccessFactors. Use when you need to query employee compensation data with recurring payments such as salary, allowances, or benefits. Supports filtering by userId and payComponent code. |
| `SAP_SUCCESSFACTORS_GET_FEEDBACK_RECORDS_SERVICE_AVAILABLE` | Get Feedback Records | Tool to retrieve continuous feedback records from SAP SuccessFactors Performance and Goals module using OData V4 protocol. Use when you need to query and retrieve feedback data with filtering, sorting, pagination, and field selection capabilities. Supports standard OData v4 query operations for flexible data retrieval. |
| `SAP_SUCCESSFACTORS_GET_FO_BUSINESS_UNIT` | Get FOBusinessUnit | Retrieves foundation object business unit records for organizational structure hierarchy. Use when querying business unit information with support for filtering, sorting, and pagination. |
| `SAP_SUCCESSFACTORS_GET_FO_COMPANY` | Get FOCompany Records | Retrieves foundation object company records from SAP SuccessFactors. Returns company information including display_name, legal_name, and entityOID for One Domain Model integration. |
| `SAP_SUCCESSFACTORS_GET_FO_COST_CENTER` | Get Foundation Object Cost Centers | Retrieves foundation object cost center records for organizational structure. Contains cost center information with entityOID for One Domain Model integration. Use standard OData query parameters to filter, sort, and paginate results. |
| `SAP_SUCCESSFACTORS_GET_FO_DEPARTMENT` | Get FODepartment Records | Tool to retrieve foundation object department records from SAP SuccessFactors. Use when you need to access organizational department structure information including team and group details. |
| `SAP_SUCCESSFACTORS_GET_FO_JOB_CODE` | Get Foundation Object Job Codes | Retrieves foundation object job code records containing job classification information. Use when you need to fetch job codes with their associated metadata for positions. |
| `SAP_SUCCESSFACTORS_GET_FO_JOB_FUNCTION` | Get Job Functions | Tool to retrieve foundation object job function records for categorizing job roles. Use when you need to query job function data with support for filtering, field selection, and pagination via OData query options. |
| `SAP_SUCCESSFACTORS_GET_FO_LOCATION` | Get Foundation Object Location | Tool to retrieve foundation object location records for work locations. Use when you need to query organizational location data including names, status, timezones, and address details. |
| `SAP_SUCCESSFACTORS_GET_FO_PAY_GROUP` | Get FOPayGroup | Retrieves foundation object pay group records for compensation and payroll groupings. Use when querying pay group data from SAP SuccessFactors. |
| `SAP_SUCCESSFACTORS_GET_FORM_CONTENT` | Get Form Content | Retrieves performance form content from SAP SuccessFactors. Use to query forms with filters like form template ID or modification date. |
| `SAP_SUCCESSFACTORS_GET_GOAL_PLAN_TEMPLATE` | Get Goal Plan Template | Retrieves goal plan template information from SAP SuccessFactors. Use when you need to fetch goal plan template configurations that define the structure of goals via DTD file. |
| `SAP_SUCCESSFACTORS_GET_GOALS_BY_PLAN` | Get Goals By Plan | Retrieves performance goals data using the goal plan ID. Use this to query goals for a specific plan (e.g., Goal_11) with optional filtering by userId or other fields. |
| `SAP_SUCCESSFACTORS_GET_INTERVIEW_OVERALL_ASSESSMENT` | Get Interview Overall Assessment | Tool to retrieve overall interview ratings and navigation for assessments from Interview Central. Use when you need to fetch overall interview assessment data including ratings, recommendations, and comments. |
| `SAP_SUCCESSFACTORS_GET_JOB_APPLICATION` | Get Job Application | Retrieves job application records linking candidates to job requisitions. Use when you need to query application data, filter by status, or retrieve candidate application information. |
| `SAP_SUCCESSFACTORS_GET_JOB_REQ_SCREENING_QUESTION` | Get Job Requisition Screening Questions | Tool to retrieve screening questions related to job requisitions from SAP SuccessFactors Recruiting. Use when you need to access screening questions for candidate assessment in the recruitment process. |
| `SAP_SUCCESSFACTORS_GET_JOB_REQUISITION` | Get Job Requisition | Tool to retrieve job requisition records from SAP SuccessFactors Recruiting Management. Use when you need to read job requisitions, send them to third-party systems, or manage the recruiting workflow. |
| `SAP_SUCCESSFACTORS_GET_ODATA_METADATA_CALIB_SESSION_SERVICE` | Get Calibration Session Metadata | Get OData metadata for Calibration Session service. Returns the service metadata including available entity sets. Use this to discover available entities in the CalSession.svc service. |
| `SAP_SUCCESSFACTORS_GET_ODATA_METADATA_CLOCK_INCLOCK_OUT` | Get Clock In/Out Integration Metadata | Get OData metadata for Clock In/Clock Out Integration service. Returns the complete service schema including entity types, enum types, complex types, and entity container definitions. |
| `SAP_SUCCESSFACTORS_GET_ODATA_METADATA_FOR_NOMINATION_SERVICE` | Get Nomination Service Metadata | Get OData metadata for Nomination service. Returns the service metadata including available entity sets for successor and talent pool nominations. Use this to discover available entities in the NominationService.svc service. |
| `SAP_SUCCESSFACTORS_GET_ODATA_METADATA_ONBOARDING_ADDL` | Get Onboarding Additional Services Metadata | Get OData metadata for Onboarding Additional Services. Returns the complete service schema including available operations like updateUserNamePostHiring and getUserNameOfNewlyHiredEmployee. |
| `SAP_SUCCESSFACTORS_GET_ODATA_USER_METADATA` | Get User Entity Metadata | Retrieves the OData metadata document for the User entity describing its properties and operations. Use this to discover available fields, data types, and navigation properties for the User entity. |
| `SAP_SUCCESSFACTORS_GET_ONB2_PROCESS` | Get Onboarding 2.0 Processes | Tool to retrieve Onboarding 2.0 process records for new hires from SAP SuccessFactors using OData V2 protocol. Use when you need to query onboarding workflow information with filtering, sorting, and field selection capabilities. |
| `SAP_SUCCESSFACTORS_GET_PENDING_FEEDBACK_REQUESTS_FEEDBACK` | Get Pending Feedback Requests | Tool to retrieve pending feedback requests or feedback request records from SAP SuccessFactors Continuous Feedback. Use when you need to query feedback requests with filtering, sorting, pagination, and field selection capabilities. Supports standard OData v4 query operations for flexible data retrieval. |
| `SAP_SUCCESSFACTORS_GET_PER_PERSONAL` | Get Personal Information Records | Tool to retrieve personal information records from SAP SuccessFactors Employee Central. The PerPersonal entity contains non-effective-dated biographical information, emergency contacts, social media accounts, and email addresses. Use when you need to access personal information data. |
| `SAP_SUCCESSFACTORS_GET_PER_PERSON_BY_ID` | Get Person by ID | Tool to retrieve person information for an employee by their external person ID. Use when you need to access core personal information data from SAP SuccessFactors Employee Central PerPerson entity. |
| `SAP_SUCCESSFACTORS_GET_PICKLIST` | Get Picklist | Tool to retrieve picklist definitions from SAP SuccessFactors. Use when you need to fetch selectable value lists (picklists) that are used across various SuccessFactors entities. |
| `SAP_SUCCESSFACTORS_GET_PICKLIST_OPTION` | Get Picklist Option | Retrieves picklist option values with localized labels from SAP SuccessFactors. Use the localeLabel property to get text in the locale of the logged-in user. Supports OData query parameters for filtering, selection, and pagination. |
| `SAP_SUCCESSFACTORS_GET_POSITION` | Get Position | Retrieves position management records from SAP SuccessFactors Employee Central. Use when you need to query position structure and hierarchy information. |
| `SAP_SUCCESSFACTORS_GET_TALENT_POOL` | Get Talent Pool | Retrieves talent pool records including members and nomination details. Use when you need to access talent pool information for succession planning. |
| `SAP_SUCCESSFACTORS_GET_TEMPORARY_TIME_INFORMATION` | Get Temporary Time Information | Retrieves temporary time information records from Time Management module. Use when you need to query temporary work schedules assigned to employees. |
| `SAP_SUCCESSFACTORS_GET_TIME_ACCOUNT_SNAPSHOT` | Get Time Account Snapshot | Retrieves time account snapshot data for leave liability calculation and payroll. Use when you need balance information for employee time accounts as of a specific point in time. |
| `SAP_SUCCESSFACTORS_GET_WORK_ORDER` | Get Work Order | Tool to retrieve work order records for contingent worker management from SAP SuccessFactors. Use when you need to query work order information with support for filtering, field selection, and pagination via OData query options. |
| `SAP_SUCCESSFACTORS_GIVE_OR_RESPOND_FEEDBACK` | Give Feedback or Respond to Feedback Request | Tool to give performance feedback or respond to a feedback request in SAP SuccessFactors Continuous Performance Management. Use when you need to provide feedback on employee performance, strengths, development areas, or respond to existing feedback requests. Supports up to 3 question-answer pairs with extended field lengths (4000 characters per answer). |
| `SAP_SUCCESSFACTORS_LIST_CANDIDATES` | List Candidates | Tool to retrieve a list of candidates from SAP SuccessFactors. Use when you need to query candidate data with OData filtering and pagination options. |
| `SAP_SUCCESSFACTORS_LIST_EMP_EMPLOYMENT` | List Employee Employment Records | Tool to retrieve a list of all employment records from SAP SuccessFactors. Use when you need to query employment data including start dates, employment types, and assignment classes. Supports filtering by custom string fields (custom-string1, custom-string2, custom-string3) and userId. |
| `SAP_SUCCESSFACTORS_LIST_PER_PERSON` | List Person Records | Tool to retrieve a list of person records from SAP SuccessFactors Employee Central. Use when you need to query employee personal information. The PerPerson entity is the foundation for all employee data in Employee Central and always returns the latest active record for each person. |
| `SAP_SUCCESSFACTORS_LIST_USERS` | List Users | Tool to retrieve a list of all employee users from SAP SuccessFactors. Use when you need to query user information with support for filtering, field selection, and pagination via OData query options. |
| `SAP_SUCCESSFACTORS_QUERY_ALL_AVAILABLE_CLOCK_CLOCK_OUT` | Query All Available Clock In/Clock Out Groups | Query all available clock in/clock out groups. Use when you need to retrieve a list of all clock in/clock out groups configured in SAP SuccessFactors. |
| `SAP_SUCCESSFACTORS_QUERY_CLOCK_CLOCK_OUT_GROUP_CODE_TIME` | Query Clock In/Clock Out Group By Code | Query a clock in/clock out group by code with time event types. Use when you need to retrieve details of a specific Clock In Clock Out Group including its configuration and optionally related Time Event Types. |
| `SAP_SUCCESSFACTORS_REFRESH_CDP_LEARNING_METADATA` | Refresh CDP Learning Metadata | Refresh metadata for Career Development Planning Learning service. |
| `SAP_SUCCESSFACTORS_REFRESH_METADATA_CONT_FEEDBACK_SERVICE` | Refresh Metadata for Continuous Feedback | Refresh metadata cache for Continuous Feedback service. Use when metadata changes need to be applied without service interruption. |
| `SAP_SUCCESSFACTORS_UPDATE_CALIBRATION_SUBJECT_RATINGS` | Update Calibration Subject Ratings | Update a subject's competency ratings in a calibration session. |
| `SAP_SUCCESSFACTORS_UPDATE_INTERNAL_USERNAME_NEW_HIRES_AFTER` | Update Username Post Hiring | Update the internal username of new hires after hiring process is completed from Active Directory. Use after Manage Pending Hire (MPH) submit and before day 1 (pre-conversion). Requires 'Manage Onboarding 2.0 or Offboarding 2.0 Update New Hire Data for External HRIS' permission. |

## Supported Triggers

None listed.

## Creating MCP Server - Stand-alone vs Composio SDK

The Sap successfactors MCP server is an implementation of the Model Context Protocol that connects your AI agent to Sap successfactors. It provides structured and secure access so your agent can perform Sap successfactors operations on your behalf through a secure, permission-based interface.
With Composio's managed implementation, you don't have to create your own developer app. For production, if you're building an end product, we recommend using your own credentials. The managed server helps you prototype fast and go from 0-1 faster.

## Step-by-step Guide

### 1. Prerequisites

Before you begin, make sure you have:
- Node.js and npm installed
- A Composio account with API key
- An OpenAI API key

### 1. Getting API Keys for OpenAI and Composio

OpenAI API Key
- Go to the [OpenAI dashboard](https://platform.openai.com/settings/organization/api-keys) 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](https://dashboard.composio.dev?utm_source=toolkits&utm_medium=framework_docs).
- Navigate to your API settings and generate a new API key.
- Store this key securely as you'll need it for authentication.

### 2. Install required dependencies

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
```bash
npm install @ai-sdk/openai @ai-sdk/mcp @composio/core ai dotenv
```

### 3. Set up environment variables

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
```bash
OPENAI_API_KEY=your_openai_api_key_here
COMPOSIO_API_KEY=your_composio_api_key_here
COMPOSIO_USER_ID=your_user_id_here
```

### 4. Import required modules and validate environment

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
```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,
});
```

### 5. Create Tool Router session and initialize MCP client

What's happening:
- We're creating a Tool Router session that gives your agent access to Sap successfactors 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 Sap successfactors-related tools through the MCP protocol
```typescript
async function main() {
  // Create a tool router session for the user
  const session = await composio.create(composioUserID!, {
    toolkits: ["sap_successfactors"],
  });

  const mcpUrl = session.mcp.url;
```

### 6. Connect to MCP server and retrieve 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 Sap successfactors tools that the agent can use
```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();
```

### 7. Initialize conversation and CLI interface

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
```typescript
let messages: ModelMessage[] = [];

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

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

rl.prompt();
```

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

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 Sap successfactors 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
```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);
});
```

## Complete Code

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

  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 sap_successfactors, 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 Sap successfactors 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 Sap successfactors MCP Agent with another framework

- [ChatGPT](https://composio.dev/toolkits/sap_successfactors/framework/chatgpt)
- [OpenAI Agents SDK](https://composio.dev/toolkits/sap_successfactors/framework/open-ai-agents-sdk)
- [Claude Agent SDK](https://composio.dev/toolkits/sap_successfactors/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/sap_successfactors/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/sap_successfactors/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/sap_successfactors/framework/codex)
- [Cursor](https://composio.dev/toolkits/sap_successfactors/framework/cursor)
- [VS Code](https://composio.dev/toolkits/sap_successfactors/framework/vscode)
- [OpenCode](https://composio.dev/toolkits/sap_successfactors/framework/opencode)
- [OpenClaw](https://composio.dev/toolkits/sap_successfactors/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/sap_successfactors/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/sap_successfactors/framework/cli)
- [Google ADK](https://composio.dev/toolkits/sap_successfactors/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/sap_successfactors/framework/langchain)
- [Mastra AI](https://composio.dev/toolkits/sap_successfactors/framework/mastra-ai)
- [LlamaIndex](https://composio.dev/toolkits/sap_successfactors/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/sap_successfactors/framework/crew-ai)

## Related Toolkits

- [Ashby](https://composio.dev/toolkits/ashby) - Ashby is an applicant tracking system that handles job postings, candidate management, and hiring analytics.
- [Async interview](https://composio.dev/toolkits/async_interview) - Async interview is an on-demand video interview platform for streamlined hiring. Candidates record responses on their schedule, so employers can review anytime.
- [Bamboohr](https://composio.dev/toolkits/bamboohr) - BambooHR is a cloud-based HR management platform for small and mid-sized businesses. It streamlines employee data, HR workflows, and reporting in one easy interface.
- [Breathe HR](https://composio.dev/toolkits/breathehr) - Breathe HR is cloud-based HR software for SMEs to manage employee data, absences, and performance. It simplifies HR admin, making it easy to keep employee records accurate and up to date.
- [Connecteam](https://composio.dev/toolkits/connecteam) - Connecteam is a workforce management platform for deskless teams, streamlining operations, HR, and team communication. It helps businesses save time by automating scheduling, time tracking, and staff engagement tasks.
- [Lever](https://composio.dev/toolkits/lever) - Lever is an applicant tracking system that blends sourcing, CRM, and analytics for recruiting. It helps companies scale hiring with collaborative workflows and actionable insights.
- [Recruitee](https://composio.dev/toolkits/recruitee) - Recruitee is collaborative hiring software that centralizes recruitment tasks for teams. It streamlines sourcing, interviewing, and hiring so you can fill roles faster.
- [Remote retrieval](https://composio.dev/toolkits/remote_retrieval) - Remote retrieval is a logistics automation tool for managing laptop and monitor returns. It streamlines return tracking, saving time and hassle for IT and ops teams.
- [Talenthr](https://composio.dev/toolkits/talenthr) - TalentHR is an intuitive, all-in-one HR tool for managing employee records, leave, and HR workflows. It streamlines HR operations so businesses can focus on people, not paperwork.
- [Workable](https://composio.dev/toolkits/workable) - Workable is an all-in-one HR software platform that streamlines hiring, employee management, and payroll. It helps teams simplify recruiting, onboarding, and staff operations in one place.
- [Workday](https://composio.dev/toolkits/workday) - Workday is a cloud-based ERP platform for HR, finance, and workforce analytics. It streamlines employee management, payroll, and business operations in a single system.
- [Gmail](https://composio.dev/toolkits/gmail) - Gmail is Google's email service with powerful spam protection, search, and G Suite integration. It keeps your inbox organized and makes communication fast and reliable.
- [Google Calendar](https://composio.dev/toolkits/googlecalendar) - Google Calendar is a time management service for scheduling meetings, events, and reminders. It streamlines personal and team organization with integrated notifications and sharing options.
- [Google Drive](https://composio.dev/toolkits/googledrive) - Google Drive is a cloud storage platform for uploading, sharing, and collaborating on files. It's perfect for keeping your documents accessible and organized across devices.
- [Outlook](https://composio.dev/toolkits/outlook) - Outlook is Microsoft's email and calendaring platform for unified communications and scheduling. It helps users stay organized with powerful email, contacts, and calendar management.
- [Twitter](https://composio.dev/toolkits/twitter) - Twitter is a social media platform for sharing real-time updates, conversations, and news. Stay connected, informed, and engaged with communities worldwide.
- [Google Sheets](https://composio.dev/toolkits/googlesheets) - Google Sheets is a cloud-based spreadsheet tool for real-time collaboration and data analysis. It lets teams work together from anywhere, updating information instantly.
- [Supabase](https://composio.dev/toolkits/supabase) - Supabase is an open-source backend platform offering scalable Postgres databases, authentication, storage, and real-time APIs. It lets developers build modern apps without managing infrastructure.
- [Composio](https://composio.dev/toolkits/composio) - Composio is an integration platform that connects AI agents with hundreds of business tools. It streamlines authentication and lets you trigger actions across services—no custom code needed.
- [Notion](https://composio.dev/toolkits/notion) - Notion is a collaborative workspace for notes, docs, wikis, and tasks. It streamlines team knowledge, project tracking, and workflow customization in one place.

## Frequently Asked Questions

### What are the differences in Tool Router MCP and Sap successfactors MCP?

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

### Can I manage the permissions and scopes for Sap successfactors while using Tool Router?

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

---
[See all toolkits](https://composio.dev/toolkits) · [Composio docs](https://docs.composio.dev/llms.txt)
