Skip to main content
Glama

addPeopleToProject

Add users to a Teamwork project by providing the project ID and an array of user IDs.

Instructions

Add people to a specific project in Teamwork

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesThe ID of the project to add people to
userIdsYesArray of user IDs to add to the project
checkTeamIdsNoOptional array of team IDs to check

Implementation Reference

  • The tool handler function that executes the 'addPeopleToProject' tool logic. Validates inputs (projectId, userIds), constructs the payload, calls the service layer, and returns the response.
    export async function handleAddPeopleToProject(input: any) {
      logger.info('=== addPeopleToProject tool called ===');
      logger.info(`Input parameters: ${JSON.stringify(input || {})}`);
      
      try {
        if (!input.projectId) {
          logger.error('Missing required parameter: projectId');
          return {
            content: [{
              type: "text",
              text: "Error: Missing required parameter 'projectId'"
            }]
          };
        }
        
        if (!input.userIds || !Array.isArray(input.userIds) || input.userIds.length === 0) {
          logger.error('Missing or invalid required parameter: userIds');
          return {
            content: [{
              type: "text",
              text: "Error: Missing or invalid required parameter 'userIds'. Must be a non-empty array of user IDs."
            }]
          };
        }
        
        const projectId = parseInt(input.projectId, 10);
        if (isNaN(projectId)) {
          logger.error(`Invalid projectId: ${input.projectId}`);
          return {
            content: [{
              type: "text",
              text: `Error: Invalid projectId. Must be a number.`
            }]
          };
        }
        
        // Prepare the payload with proper typing
        const payload: AddPeopleToProjectPayload = {
          userIds: input.userIds
        };
        
        // Add checkTeamIds if provided
        if (input.checkTeamIds && Array.isArray(input.checkTeamIds)) {
          payload.checkTeamIds = input.checkTeamIds;
        }
        
        logger.info(`Calling teamworkService.addPeopleToProject(${projectId}, ${JSON.stringify(payload)})`);
        const result = await teamworkService.addPeopleToProject(projectId, payload);
        
        // Debug the response
        logger.info(`Add people to project response type: ${typeof result}`);
        
        try {
          const jsonString = JSON.stringify(result, null, 2);
          logger.info(`Successfully stringified response`);
          logger.info('=== addPeopleToProject tool completed successfully ===');
          return {
            content: [{
              type: "text",
              text: jsonString
            }]
          };
        } catch (jsonError: any) {
          logger.error(`JSON stringify error: ${jsonError.message}`);
          return {
            content: [{
              type: "text",
              text: `Error formatting response: ${jsonError.message}`
            }]
          };
        }
      } catch (error: any) {
        return createErrorResponse(error, 'Adding people to project');
      }
    } 
  • Tool definition including inputSchema for 'addPeopleToProject' with required fields: projectId (integer), userIds (array of integers), and optional checkTeamIds (array of integers).
    export const addPeopleToProjectDefinition = {
      name: "addPeopleToProject",
      description: "Add people to a specific project in Teamwork",
      inputSchema: {
        type: "object",
        properties: {
          projectId: {
            type: "integer",
            description: "The ID of the project to add people to"
          },
          userIds: {
            type: "array",
            items: {
              type: "integer"
            },
            description: "Array of user IDs to add to the project"
          },
          checkTeamIds: {
            type: "array",
            items: {
              type: "integer"
            },
            description: "Optional array of team IDs to check"
          }
        },
        required: ["projectId", "userIds"]
      },
      annotations: {
        title: "Add People to Project",
        readOnlyHint: false,
        destructiveHint: false,
        openWorldHint: false
      }
    };
  • TypeScript interface AddPeopleToProjectPayload defining the service-layer payload shape: userIds (number[]) and optional checkTeamIds (number[]).
    export interface AddPeopleToProjectPayload {
      userIds: number[];
      checkTeamIds?: number[];
    }
  • Import and registration of the addPeopleToProject tool definition and handler in the central tools index. The tool is added to the toolPairs array at line 86, which feeds into toolDefinitions and toolHandlersMap.
    import { addPeopleToProjectDefinition as addPeopleToProject, handleAddPeopleToProject } from './people/addPeopleToProject.js';
    import { deletePersonDefinition as deletePerson, handleDeletePerson } from './people/deletePerson.js';
    import { updatePersonDefinition as updatePerson, handleUpdatePerson } from './people/updatePerson.js';
    
    // Companies
    import { createCompanyDefinition as createCompany, handleCreateCompany } from './companies/createCompany.js';
    import { updateCompanyDefinition as updateCompany, handleUpdateCompany } from './companies/updateCompany.js';
    import { deleteCompanyDefinition as deleteCompany, handleDeleteCompany } from './companies/deleteCompany.js';
    import { getCompaniesDefinition as getCompanies, handleGetCompanies } from './companies/getCompanies.js';
    import { getCompanyByIdDefinition as getCompanyById, handleGetCompanyById } from './companies/getCompanyById.js';
    
    // Reporting
    import { getProjectsPeopleMetricsPerformanceDefinition as getProjectsPeopleMetricsPerformance, handleGetProjectsPeopleMetricsPerformance } from './people/getPeopleMetricsPerformance.js';
    import { getProjectsPeopleUtilizationDefinition as getProjectsPeopleUtilization, handleGetProjectsPeopleUtilization } from './people/getPeopleUtilization.js';
    import { getProjectPersonDefinition as getProjectPerson, handleGetProjectPerson } from './people/getProjectPerson.js';
    import { getProjectsReportingUserTaskCompletionDefinition as getProjectsReportingUserTaskCompletion, handleGetProjectsReportingUserTaskCompletion } from './reporting/getUserTaskCompletion.js';
    import { getProjectsReportingUtilizationDefinition as getProjectsReportingUtilization, handleGetProjectsReportingUtilization } from './people/getUtilization.js';
    
    // Time-related imports
    import { getTimeDefinition as getTime, handleGetTime } from './time/getTime.js';
    import { getProjectsAllocationsTimeDefinition as getAllocationTime, handleGetProjectsAllocationsTime } from './time/getAllocationTime.js';
    
    // Core
    import { getTimezonesDefinition as getTimezones, handleGetTimezones } from './core/getTimezones.js';
    
    // Define a structure that pairs tool definitions with their handlers
    interface ToolPair {
      definition: any;
      handler: Function;
    }
    
    // Create an array of tool pairs
    const toolPairs: ToolPair[] = [
      { definition: getProjects, handler: handleGetProjects },
      { definition: getCurrentProject, handler: handleGetCurrentProject },
      { definition: createProject, handler: handleCreateProject },
      { definition: getTasks, handler: handleGetTasks },
      { definition: getTasksByProjectId, handler: handleGetTasksByProjectId },
      { definition: getTaskListsByProjectId, handler: handleGetTaskListsByProjectId },
      { definition: getTasksByTaskListId, handler: handleGetTasksByTaskListId },
      { definition: getTaskById, handler: handleGetTaskById },
      { definition: createTask, handler: handleCreateTask },
      { definition: createSubTask, handler: handleCreateSubTask },
      { definition: updateTask, handler: handleUpdateTask },
      { definition: deleteTask, handler: handleDeleteTask },
      { definition: getTasksMetricsComplete, handler: handleGetTasksMetricsComplete },
      { definition: getTasksMetricsLate, handler: handleGetTasksMetricsLate },
      { definition: getTaskSubtasks, handler: handleGetTaskSubtasks },
      { definition: getTaskComments, handler: handleGetTaskComments },
      { definition: createComment, handler: handleCreateComment },
      { definition: getPeople, handler: handleGetPeople },
      { definition: getPersonById, handler: handleGetPersonById },
      { definition: getProjectPeople, handler: handleGetProjectPeople },
      { definition: addPeopleToProject, handler: handleAddPeopleToProject },
  • Service-layer function that calls the Teamwork API (PUT /projects/{projectId}/people.json) to add people to a project. This is the underlying API call helper.
    export const addPeopleToProject = async (projectId: number, payload: AddPeopleToProjectPayload) => {
      try {
        logger.info(`Adding people to project ID ${projectId} in Teamwork API`);
        logger.info(`Payload: ${JSON.stringify(payload)}`);
        
        const api = ensureApiClient();
        const response = await api.put(`/projects/${projectId}/people.json`, payload);
        logger.info(`Successfully added people to project ID ${projectId}`);
        return response.data;
      } catch (error: any) {
        logger.error(`Teamwork API error: ${error.message}`);
        throw new Error(`Failed to add people to project ID ${projectId} in Teamwork API`);
      }
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description aligns with annotations: it indicates a write operation (readOnlyHint=false) and non-destructive action (destructiveHint=false). However, it provides no additional behavioral context, such as whether adding people appends or replaces existing members, or any permission requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence without any wasted words. It is appropriately front-loaded with the action and resource. However, it could include slightly more detail without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given there is no output schema, the description should provide some indication of the result (e.g., success response, error conditions, or side effects). It does not, leaving the agent without expectations for the return value or state changes beyond the basic action.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already documents all three parameters with clear descriptions (100% coverage). The description does not add any new meaning beyond what is in the schema, so the baseline score of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool adds people to a specific project. It uses a specific verb ('Add') and resource ('people to a specific project'), making the purpose understandable. However, it lacks differentiation from sibling tools like 'createProject' which might also involve adding people.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives (e.g., using project creation to include members, or other assignment tools). There is no 'when not to use' or mention of prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vizioz/Teamwork-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server