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: 4 additions & 1 deletion packages/agent-toolkit/fetch-schema.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#!/bin/bash
curl "https://api.monday.com/v2/get_schema?format=sdl&version=stable" -o src/monday-graphql/schema.graphql
API_VERSION="dev"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MCP works against the current not dev as its what users use

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if in theory we add a tool from dev we should have diffrentet fetch schema for it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not work on the dev version by default in the MCP? In the MCP the contract with the user are the tools - and even then this is mediated by the agent. I don't think there's anything to lose by working on latest, if anything it makes the MCP more useful

SCHEMA_PATH="src/monday-graphql/schema.graphql"
# --fail flag will not write to file when the request fails
curl --fail "https://api.monday.com/v2/get_schema?format=sdl&version=${API_VERSION}" -o ${SCHEMA_PATH}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { z } from 'zod';
import {
ChangeItemPositionMutation,
ChangeItemPositionMutationVariables,
PositionRelative,
} from '../../../monday-graphql/generated/graphql';
import { changeItemPosition } from '../../../monday-graphql/queries.graphql';
import { ToolInputType, ToolOutputType, ToolType } from '../../tool';
import { BaseMondayApiTool, createMondayApiAnnotations } from './base-monday-api-tool';

export const changeItemPositionToolSchema = {
itemId: z.number().describe('The ID of the item to be moved'),
relativeTo: z
.number()
.optional()
.describe('The ID of the item to position relative to (required when using position_relative_method)'),
positionRelativeMethod: z
.enum(['after_at', 'before_at'])
.optional()
.describe('The position relative method to another item (after_at / before_at)'),
groupId: z.string().optional().describe('The group ID to move the item to (required when using group_top)'),
groupTop: z
.boolean()
.optional()
.describe('Whether to position the item at the top of the group (true) or bottom (false)'),
};
export type ChangeItemPositionToolInput = typeof changeItemPositionToolSchema;

const MIN_API_VERSION = '2025-10';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, what we need to do here is that if users use a different API version, they won't have access to the tools at all
I think its safer to make sure the mcp works against stable API version because of it, but we can change it to work against rc if needed maybe?
@gregra81

export class ChangeItemPositionTool extends BaseMondayApiTool<ChangeItemPositionToolInput> {
name = 'change_item_position';
type = ToolType.WRITE;
annotations = createMondayApiAnnotations({
title: 'Change Item Position',
readOnlyHint: false,
destructiveHint: false,
idempotentHint: true,
});

getDescription(): string {
return 'Change the position of an item in a monday.com board. You can move an item relative to another item (before/after) or to the top/bottom of a group.';
}

getInputSchema(): ChangeItemPositionToolInput {
return changeItemPositionToolSchema;
}

protected async executeInternal(input: ToolInputType<ChangeItemPositionToolInput>): Promise<ToolOutputType<never>> {
// Validate the input based on the positioning method
const apiVersion = this.mondayApi.apiVersion;
if (apiVersion != 'dev' || apiVersion < MIN_API_VERSION) {
throw new Error(`This tool is not supported in the ${apiVersion} API version`);
}

const variables: ChangeItemPositionMutationVariables = {
item_id: input.itemId.toString(),
relative_to: input.relativeTo?.toString(),
position_relative_method: input.positionRelativeMethod as PositionRelative,
group_id: input.groupId,
group_top: input.groupTop,
};

const res = await this.mondayApi.request<ChangeItemPositionMutation>(changeItemPosition, variables);

if (!res.change_item_position) {
throw new Error('Failed to change item position');
}

return {
content: `Item ${res.change_item_position.id} successfully moved to new position${
res.change_item_position.group?.id ? ` in group ${res.change_item_position.group.id}` : ''
}`,
};
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AllMondayApiTool } from './all-monday-api-tool';
import { BaseMondayApiToolConstructor } from './base-monday-api-tool';
import { ChangeItemColumnValuesTool } from './change-item-column-values-tool';
import { ChangeItemPositionTool } from './change-item-position-tool';
import { CreateBoardTool } from './create-board-tool';
import { CreateColumnTool } from './create-column-tool';
import { CreateCustomActivityTool } from './create-custom-activity-tool';
Expand All @@ -26,6 +27,7 @@ export const allGraphqlApiTools: BaseMondayApiToolConstructor[] = [
GetBoardSchemaTool,
GetUsersTool,
ChangeItemColumnValuesTool,
ChangeItemPositionTool,
MoveItemToGroupTool,
CreateBoardTool,
CreateColumnTool,
Expand Down
Loading