-
Notifications
You must be signed in to change notification settings - Fork 45
Default API version to dev and add Change Item Position tool #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lorenzowritescode
wants to merge
7
commits into
mondaycom:master
Choose a base branch
from
lorenzowritescode:add_change_item_position
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5650581
Add change item position tool to MCP
lorenzowritescode 287e10c
Add tool description
lorenzowritescode 68f5a43
prettier fix
lorenzowritescode ae3e59f
Switch MCP to using the dev version of the API to always get latest c…
lorenzowritescode b8de5e6
Fix type of group_id
lorenzowritescode edb92bd
Remove local arg validation and add API version check
lorenzowritescode 5df8542
Default API version to dev
lorenzowritescode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| 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} | ||
75 changes: 75 additions & 0 deletions
75
packages/agent-toolkit/src/core/tools/platform-api-tools/change-item-position-tool.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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}` : '' | ||
| }`, | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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