Skip to main content
Glama

getProjects

Retrieve all Teamwork projects with customizable filters for date ranges, user assignments, and detailed inclusion of project metadata like budget, profitability, and custom fields.

Instructions

Get all projects from Teamwork

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
updatedAfterNoFilter projects updated after this date-time (format: ISO 8601)
timeModeNoProfitability time mode
searchTermNoFilter by project name
reportTypeNoDefine the type of the report
reportTimezoneNoConfigure the report dates displayed in a timezone
reportFormatNoDefine the format of the report
projectTypeNoFilter by project type
orderModeNoOrder mode
orderByNoOrder by field
notCompletedBeforeNoFilter by projects that have not been completed before the given date (format: YYYY-MM-DD)
minLastActivityDateNoFilter by min last activity date (format: YYYY-MM-DD)
maxLastActivityDateNoFilter by max last activity date (format: YYYY-MM-DD)
userIdNoFilter by user id
pageSizeNoNumber of items in a page (not used when generating reports)
pageNoPage number (not used when generating reports)
orderByCustomFieldIdNoOrder by custom field id when orderBy is equal to customfield
minBudgetCapacityUsedPercentNoFilter by minimum budget capacity used
maxBudgetCapacityUsedPercentNoFilter by maximum budget capacity used
includeArchivedProjectsNoInclude archived projects
includeCompletedProjectsNoInclude completed projects
includeProjectOwnerNoInclude project owner
includeProjectCreatorNoInclude project creator
includeProjectCompanyNoInclude project company
includeProjectCategoryNoInclude project category
includeProjectTagsNoInclude project tags
includeProjectStatusNoInclude project status
includeProjectHealthNoInclude project health
includeProjectBudgetNoInclude project budget
includeProjectProfitabilityNoInclude project profitability
includeProjectCustomFieldsNoInclude project custom fields
includeProjectBillingMethodNoInclude project billing method
includeProjectRateCardsNoInclude project rate cards
includeProjectRateCardRatesNoInclude project rate card rates
includeProjectRateCardCurrenciesNoInclude project rate card currencies
includeProjectRateCardUsersNoInclude project rate card users
includeProjectRateCardUserRatesNoInclude project rate card user rates
includeProjectRateCardUserCurrenciesNoInclude project rate card user currencies
includeProjectRateCardTasksNoInclude project rate card tasks
includeProjectRateCardTaskRatesNoInclude project rate card task rates
includeProjectRateCardTaskCurrenciesNoInclude project rate card task currencies

Implementation Reference

  • The handleGetProjects function is the tool handler that receives input, calls teamworkService.getProjects(), processes the response, and returns formatted content. It handles null/undefined, arrays, and paginated response objects.
    export async function handleGetProjects(input: any) {
      logger.info('=== getProjects tool called ===');
      logger.info(`Query parameters: ${JSON.stringify(input || {})}`);
      
      try {
        logger.info('Calling teamworkService.getProjects()');
        const projects = await teamworkService.getProjects(input);
        
        // Debug the response
        logger.info(`Projects response type: ${typeof projects}`);
        
        if (projects === null || projects === undefined) {
          logger.warn('Projects response is null or undefined');
          return {
            content: [{
              type: "text",
              text: "No projects found or API returned empty response."
            }]
          };
        } else if (Array.isArray(projects)) {
          logger.info(`Projects array length: ${projects.length}`);
          if (projects.length === 0) {
            return {
              content: [{
                type: "text",
                text: "No projects found. The API returned an empty array."
              }]
            };
          }
        } else if (typeof projects === 'object') {
          // Check if it's a paginated response with 'projects' property
          if (projects.projects && Array.isArray(projects.projects)) {
            logger.info(`Projects array found in response object. Length: ${projects.projects.length}`);
            if (projects.projects.length === 0) {
              return {
                content: [{
                  type: "text",
                  text: "No projects found. The API returned an empty projects array."
                }]
              };
            }
          } else {
            logger.info(`Projects response is an object: ${JSON.stringify(projects).substring(0, 200)}...`);
          }
        } else {
          logger.info(`Projects response is not an array or object: ${JSON.stringify(projects).substring(0, 200)}...`);
        }
        
        try {
          const jsonString = JSON.stringify(projects, null, 2);
          logger.info(`Successfully stringified projects response`);
          logger.info('=== getProjects 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 converting response to JSON: ${jsonError.message}`
            }]
          };
        }
      } catch (error: any) {
        return createErrorResponse(error, 'Retrieving projects');
      }
    } 
  • The getProjectsDefinition object defines the tool name 'getProjects', description, and inputSchema with all supported parameters (string, integer, boolean types) plus annotations.
    export const getProjectsDefinition = {
      name: "getProjects",
      description: "Get all projects from Teamwork",
      inputSchema: {
        type: "object",
        properties: {
          // String parameters
          updatedAfter: {
            type: "string",
            description: "Filter projects updated after this date-time (format: ISO 8601)"
          },
          timeMode: {
            type: "string",
            enum: ["timelogs", "estimated"],
            description: "Profitability time mode"
          },
          searchTerm: {
            type: "string",
            description: "Filter by project name"
          },
          reportType: {
            type: "string",
            enum: ["project", "health"],
            description: "Define the type of the report"
          },
          reportTimezone: {
            type: "string",
            description: "Configure the report dates displayed in a timezone"
          },
          reportFormat: {
            type: "string",
            enum: ["csv", "html", "pdf", "xls"],
            description: "Define the format of the report"
          },
          projectType: {
            type: "string",
            description: "Filter by project type"
          },
          orderMode: {
            type: "string",
            enum: ["asc", "desc"],
            description: "Order mode"
          },
          orderBy: {
            type: "string",
            enum: ["companyname", "datecreated", "duedate", "lastactivity", "name", "namecaseinsensitive", "ownercompany", "starred", "categoryname"],
            description: "Order by field"
          },
          notCompletedBefore: {
            type: "string",
            description: "Filter by projects that have not been completed before the given date (format: YYYY-MM-DD)"
          },
          minLastActivityDate: {
            type: "string",
            description: "Filter by min last activity date (format: YYYY-MM-DD)"
          },
          maxLastActivityDate: {
            type: "string",
            description: "Filter by max last activity date (format: YYYY-MM-DD)"
          },
          
          // Integer parameters
          userId: {
            type: "integer",
            description: "Filter by user id"
          },
          pageSize: {
            type: "integer",
            description: "Number of items in a page (not used when generating reports)"
          },
          page: {
            type: "integer",
            description: "Page number (not used when generating reports)"
          },
          orderByCustomFieldId: {
            type: "integer",
            description: "Order by custom field id when orderBy is equal to customfield"
          },
          minBudgetCapacityUsedPercent: {
            type: "integer",
            description: "Filter by minimum budget capacity used"
          },
          maxBudgetCapacityUsedPercent: {
            type: "integer",
            description: "Filter by maximum budget capacity used"
          },
          
          // Boolean parameters
          includeArchivedProjects: {
            type: "boolean",
            description: "Include archived projects"
          },
          includeCompletedProjects: {
            type: "boolean",
            description: "Include completed projects"
          },
          includeProjectOwner: {
            type: "boolean",
            description: "Include project owner"
          },
          includeProjectCreator: {
            type: "boolean",
            description: "Include project creator"
          },
          includeProjectCompany: {
            type: "boolean",
            description: "Include project company"
          },
          includeProjectCategory: {
            type: "boolean",
            description: "Include project category"
          },
          includeProjectTags: {
            type: "boolean",
            description: "Include project tags"
          },
          includeProjectStatus: {
            type: "boolean",
            description: "Include project status"
          },
          includeProjectHealth: {
            type: "boolean",
            description: "Include project health"
          },
          includeProjectBudget: {
            type: "boolean",
            description: "Include project budget"
          },
          includeProjectProfitability: {
            type: "boolean",
            description: "Include project profitability"
          },
          includeProjectCustomFields: {
            type: "boolean",
            description: "Include project custom fields"
          },
          includeProjectBillingMethod: {
            type: "boolean",
            description: "Include project billing method"
          },
          includeProjectRateCards: {
            type: "boolean",
            description: "Include project rate cards"
          },
          includeProjectRateCardRates: {
            type: "boolean",
            description: "Include project rate card rates"
          },
          includeProjectRateCardCurrencies: {
            type: "boolean",
            description: "Include project rate card currencies"
          },
          includeProjectRateCardUsers: {
            type: "boolean",
            description: "Include project rate card users"
          },
          includeProjectRateCardUserRates: {
            type: "boolean",
            description: "Include project rate card user rates"
          },
          includeProjectRateCardUserCurrencies: {
            type: "boolean",
            description: "Include project rate card user currencies"
          },
          includeProjectRateCardTasks: {
            type: "boolean",
            description: "Include project rate card tasks"
          },
          includeProjectRateCardTaskRates: {
            type: "boolean",
            description: "Include project rate card task rates"
          },
          includeProjectRateCardTaskCurrencies: {
            type: "boolean",
            description: "Include project rate card task currencies"
          }
        }
      },
      annotations: {
        title: "Get Projects",
        readOnlyHint: false,
        destructiveHint: false,
        openWorldHint: false
      }
    };
  • src/tools/index.ts:7-7 (registration)
    Imports getProjectsDefinition (aliased as getProjects) and handleGetProjects from the tool file.
    import { getProjectsDefinition as getProjects, handleGetProjects } from './projects/getProjects.js';
  • Registers the getProjects tool in the toolPairs array, pairing its definition with its handler.
    { definition: getProjects, handler: handleGetProjects },
  • The service-layer getProjects function that actually calls the Teamwork API. Tries v3 API first, falls back to v1 API. Takes ProjectQueryParams and returns response data.
    export const getProjects = async (params?: ProjectQueryParams) => {
      try {
        logger.info('Fetching projects from Teamwork API');
        
        try {
          // Try with v3 API first
          const api = ensureApiClient();
          const response = await api.get('/projects.json', { params });
          logger.info('Successfully fetched projects using v3 API');
          return response.data;
        } catch (error: any) {
          logger.warn(`V3 API request failed: ${error.message}`);
          
          // Try the v1 API format as fallback
          logger.info('Trying v1 API format as fallback');
          try {
            const v1Api = getApiClientForVersion('v1');
            const v1Response = await v1Api.get('/projects.json', { params });
            logger.info('Successfully fetched projects using v1 API');
            return v1Response.data;
          } catch (v1Error: any) {
            logger.error(`V1 API request also failed: ${v1Error.message}`);
            throw error; // Throw the original error
          }
        }
      } catch (error: any) {
        logger.error(`Teamwork API error: ${error.message}`);
        throw new Error('Failed to fetch projects from Teamwork API');
      }
    };
Behavior1/5

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

Description states 'Get' implying a read-only operation, but annotations set readOnlyHint: false, indicating possible side effects. This contradiction confuses whether the tool modifies data. No additional behavioral details are provided.

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?

Single sentence is concise and front-loaded. However, it sacrifices essential details like behavior and usage context, but it remains non-redundant.

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 40 parameters, no output schema, and no usage guidance, the description is insufficient. It does not explain pagination, the effect of include booleans, or how filters interact with the 'all' claim. Agents need more context to invoke correctly.

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?

All 40 parameters have descriptions in the schema (100% coverage). The description adds no extra parameter information beyond what the schema already provides, so baseline 3 is appropriate.

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?

Description 'Get all projects from Teamwork' clearly specifies the action (get) and resource (projects). It distinguishes from sibling tools like 'getCurrentProject' which targets a single project. However, saying 'all' is slightly misleading because the schema includes many filters, implying it can return a subset.

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?

No guidance on when to use this tool versus alternatives (e.g., getCurrentProject, createProject). An agent would need to infer the use case from the name and schema alone.

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