Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<img src="https://img.shields.io/badge/TypeScript-Powered-blue" alt="TypeScript">
</p>

**Enable AI agents to operate reliably within real workflows. This MCP is monday.coms open framework for connecting agents into your work OS - giving them secure access to structured data, tools to take action, and the context needed to make smart decisions.**
**Enable AI agents to operate reliably within real workflows. This MCP is monday.com's open framework for connecting agents into your work OS - giving them secure access to structured data, tools to take action, and the context needed to make smart decisions.**

</div>

Expand Down Expand Up @@ -119,7 +119,8 @@ Our MCP server provides a rich set of tools that give AI assistants the ability
| **Item Operations** | create_item | Create a new item in a monday.com board with specified column values |
| | delete_item | Delete an item from a board permanently |
| | get_board_items_by_name | Search for items by board ID and term/name |
| | create_update | Add an update/comment to a specific item |
| | list_board_items | Lists items from a board with pagination, and optional filtering by group ID and item name. |
| | manage_item_updates | Fetches updates for an item or creates a new update on an item. |
| | change_item_column_values | Modify the column values of an existing item |
| | move_item_to_group | Move an item to a different group within the same board |
| **Board Operations** | create_board | Create a new monday.com board with specified columns |
Expand Down
3 changes: 2 additions & 1 deletion packages/agent-toolkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ The toolkit includes several pre-built tools for common Monday.com operations, o
- `CreateItemTool` - Create a new item in a monday.com board
- `DeleteItemTool` - Delete an item from a board
- `GetBoardItemsTool` - Get items by board id and term
- `CreateUpdateTool` - Create a new update on a specific item
- `ListBoardItemsTool` - Lists items from a board with pagination, and optional filtering by group ID and item name.
- `ManageItemUpdatesTool` - Fetches, creates, or deletes updates for items or fetches updates for entire boards. Supports array inputs for item and board IDs.
- `ChangeItemColumnValuesTool` - Change the column values of an item in a monday.com board
- `MoveItemToGroupTool` - Move an item to a group in a monday.com board

Expand Down
2 changes: 1 addition & 1 deletion packages/agent-toolkit/fetch-schema.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
curl "https://api.monday.com/v2/get_schema?format=sdl&version=stable" -o src/monday-graphql/schema.graphql
curl "https://api.monday.com/v2/get_schema?format=sdl&version=current" -o src/monday-graphql/schema.graphql

This file was deleted.

9 changes: 6 additions & 3 deletions packages/agent-toolkit/src/core/platform-api-tools/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DeleteItemTool } from './delete-item-tool';
import { GetBoardItemsTool } from './get-board-items-tool';
import { CreateItemTool } from './create-item-tool';
import { CreateUpdateTool } from './create-update-tool';
import { GetBoardSchemaTool } from './get-board-schema-tool';
import { GetUsersTool } from './get-users-tool';
import { ChangeItemColumnValuesTool } from './change-item-column-values-tool';
Expand All @@ -15,12 +14,13 @@ import { GetTypeDetailsTool } from './get-type-details-tool';
import { CreateCustomActivityTool } from './create-custom-activity-tool';
import { CreateTimelineItemTool } from './create-timeline-item-tool';
import { FetchCustomActivityTool } from './fetch-custom-activity-tool';
import { ManageItemUpdatesTool } from './manage-item-updates-tool';
import { ListBoardItemsTool } from './list-board-items-tool';

export const allTools = [
DeleteItemTool,
GetBoardItemsTool,
CreateItemTool,
CreateUpdateTool,
GetBoardSchemaTool,
GetUsersTool,
ChangeItemColumnValuesTool,
Expand All @@ -34,12 +34,13 @@ export const allTools = [
CreateCustomActivityTool,
CreateTimelineItemTool,
FetchCustomActivityTool,
ManageItemUpdatesTool,
ListBoardItemsTool,
];

export * from './delete-item-tool';
export * from './get-board-items-tool';
export * from './create-item-tool';
export * from './create-update-tool';
export * from './get-board-schema-tool';
export * from './get-users-tool';
export * from './change-item-column-values-tool';
Expand All @@ -53,3 +54,5 @@ export * from './get-type-details-tool';
export * from './create-custom-activity-tool';
export * from './create-timeline-item-tool';
export * from './fetch-custom-activity-tool';
export * from './manage-item-updates-tool';
export * from './list-board-items-tool';
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { z } from 'zod';
import { BaseMondayApiTool } from './base-monday-api-tool';
import { ToolInputType, ToolOutputType, ToolType } from '../tool';
import { listBoardItems } from '../../monday-graphql/queries.graphql';
import {
ListBoardItemsQuery,
ListBoardItemsQueryVariables,
ItemsQuery, // Actual input type for query_params
ItemsQueryRuleOperator, // Import the enum for operators
// ItemsQueryRule, // Not directly needed if constructing inline
} from '../../monday-graphql/generated/graphql';

/**
* Zod schema for the input of the ListBoardItemsTool.
* Defines the arguments required to list items from a board, including pagination and filtering options.
*/
export const listBoardItemsToolSchema = {
/** The ID of the monday.com board from which to list items. */
boardId: z.number().describe('The ID of the board from which to list items.'),
/** Optional: Maximum number of items to return per page. Defaults to 25. */
limit: z.number().optional().default(25).describe('Maximum number of items to return per page. Defaults to 25.'),
/** Optional: Cursor for fetching the next page of items. Obtained from a previous call to this tool. */
cursor: z.string().optional().describe('Cursor for fetching the next page of items. Obtained from a previous call.'),
/** Optional: ID of a specific group within the board to filter items by. */
groupId: z.string().optional().describe('Optional: ID of a specific group to filter items by.'),
/** Optional: Text to search for within item names. If empty or undefined, no name-based filtering is applied. */
nameQuery: z
.string()
.optional()
.describe('Optional: Text to search for in item names. If empty or undefined, no name filter is applied.'),
};

/**
* A tool for listing items from a monday.com board with comprehensive support for
* pagination and optional filtering by group ID and/or item name.
*
* Key Features:
* - **Pagination**: Use `limit` (default 25) to specify page size and `cursor` (from a previous call) to fetch subsequent pages.
* - **Name Filtering**: Provide `nameQuery` to search for items containing that text in their name. An empty or omitted `nameQuery` applies no name filter.
* - **Group Filtering**: Provide `groupId` to retrieve items only from that specific group.
* - **Combined Filtering**: Both `nameQuery` and `groupId` can be used together.
*
* The tool dynamically constructs query parameters for the Monday.com API based on the provided filters.
* It returns an object containing the `boardName`, an array of `items` for the current page (each item includes `id`, `name`, and `group` details), and a `cursor` string for the next page (or `null` if no more items).
*
* Example Usage:
* - To get the first 10 items: `{ boardId: 123, limit: 10 }`
* - To get items from group 'g123' containing "Task": `{ boardId: 123, groupId: "g123", nameQuery: "Task" }`
* - To get the next page from a previous call: `{ boardId: 123, cursor: "some_cursor_string" }`
*/
export class ListBoardItemsTool extends BaseMondayApiTool<typeof listBoardItemsToolSchema> {
/** The unique name of the tool. */
name = 'list_board_items';
/** The type of the tool, indicating it performs read-only query operations. */
type = ToolType.QUERY;

/**
* Provides a detailed, human-readable description of what the tool does,
* intended for an AI model to understand its capabilities and parameters.
* @returns A string describing the tool's purpose, inputs, pagination, filtering, and output structure.
*/
getDescription(): string {
return (
'Lists items from a specified monday.com board. Required input: `boardId`. ' +
'Supports pagination via optional `limit` (default 25) and `cursor` (string from previous call). ' +
'Optionally filters by `groupId` (string) to get items from a specific group, and/or by `nameQuery` (string) for a text search within item names. ' +
'If `nameQuery` is empty or omitted, no name filter is applied. ' +
'Returns an object with `boardName` (string), `items` (array of item objects, each with `id`, `name`, `group`), and `cursor` (string or null for next page).'
);
}

/**
* Returns the Zod schema defining the input structure for this tool.
*/
getInputSchema(): typeof listBoardItemsToolSchema {
return listBoardItemsToolSchema;
}

/**
* Executes the tool's logic to list board items.
* @param input - The input arguments for the tool.
* @returns A promise resolving to an object containing the list of items and a cursor for the next page.
*/
async execute(input: ToolInputType<typeof listBoardItemsToolSchema>): Promise<ToolOutputType<never>> {
// Initialize queryParams with the correct type. Cast to any initially to allow dynamic property assignment.
const queryParams: Partial<ItemsQuery> = {};
queryParams.rules = []; // Initialize rules array

if (input.nameQuery && input.nameQuery.trim() !== '') {
queryParams.rules.push({
column_id: 'name', // Standard column ID for item name
compare_value: input.nameQuery,
operator: ItemsQueryRuleOperator.ContainsText, // Use the enum value
});
}

if (input.groupId) {
// Based on common Monday.com API patterns, filtering by group in items_page
// often involves specifying the group_id directly within query_params, if supported by ItemsQuery type.
// However, ItemsQuery revealed it doesn't have a direct `group_id` field.
// So, we must use a rule. The exact column_id for group might be 'group'.
// This assumes 'group' is a queryable column ID for group association.
queryParams.rules.push({
column_id: 'group', // This is an assumption for the group column ID in rules.
// It might need to be different, e.g., a specific system ID for the group column.
compare_value: [input.groupId], // compare_value for AnyOf is typically an array
operator: ItemsQueryRuleOperator.AnyOf, // To match if the item is in any of the specified group_ids (here, just one)
});
}

// If no rules were added, rules array should be undefined or not present
if (queryParams.rules.length === 0) {
delete queryParams.rules; // Or set to undefined, depending on API/client preference for empty arrays
}

const variables: ListBoardItemsQueryVariables = {
boardId: input.boardId.toString(),
limit: input.limit,
cursor: input.cursor,
// Only include queryParams if it has been populated (e.g., with rules)
queryParams:
(queryParams.rules && queryParams.rules.length > 0) || queryParams.groups
? (queryParams as ItemsQuery)
: undefined,
};

try {
const res = await this.mondayApi.request<ListBoardItemsQuery>(listBoardItems, variables);
const boardData = res.boards?.[0];

if (!boardData) {
return { content: `Board with ID ${input.boardId} not found or access denied.` };
}

const itemsPage = boardData.items_page;
const response = {
boardName: boardData.name,
items: itemsPage?.items || [],
cursor: itemsPage?.cursor || null,
};
return { content: JSON.stringify(response, null, 2) };
} catch (error: any) {
// console.error(`Error listing items for board ${input.boardId}:`, error);
return { content: `Failed to list items for board ${input.boardId}. Error: ${error.message || 'Unknown error'}` };
}
}
}
Loading