diff --git a/packages/agent-toolkit/src/core/platform-api-tools/create-board-view-tool.ts b/packages/agent-toolkit/src/core/platform-api-tools/create-board-view-tool.ts new file mode 100644 index 00000000..29b8a148 --- /dev/null +++ b/packages/agent-toolkit/src/core/platform-api-tools/create-board-view-tool.ts @@ -0,0 +1,38 @@ +import { z } from 'zod'; +import { BaseMondayApiTool } from './base-monday-api-tool'; +import { BoardViewTypeValues } from '../../monday-graphql/generated/graphql'; +import { ToolInputType, ToolOutputType, ToolType } from '../tool'; +import { createBoardView } from '../../monday-graphql/queries.graphql'; + +export const createBoardViewToolSchema = { + boardId: z.string().describe('The ID of the board to create the view in'), + name: z.string().describe('The name of the board view'), + type: z.nativeEnum(BoardViewTypeValues).describe('The type of board view to create'), +}; + +export class CreateBoardViewTool extends BaseMondayApiTool { + name = 'create_board_view'; + type = ToolType.MUTATION; + + getDescription(): string { + return 'Create a new board view in a monday.com board'; + } + + getInputSchema(): typeof createBoardViewToolSchema { + return createBoardViewToolSchema; + } + + async execute(input: ToolInputType): Promise> { + const variables = { + boardId: input.boardId, + name: input.name, + type: input.type, + }; + + const res = await this.mondayApi.request(createBoardView, variables); + + return { + content: `Board view '${input.name}' of type ${input.type} successfully created in board ${input.boardId}`, + }; + } +} \ No newline at end of file diff --git a/packages/agent-toolkit/src/core/platform-api-tools/create-item-tool.ts b/packages/agent-toolkit/src/core/platform-api-tools/create-item-tool.ts index 10db4c80..2d89dc6f 100644 --- a/packages/agent-toolkit/src/core/platform-api-tools/create-item-tool.ts +++ b/packages/agent-toolkit/src/core/platform-api-tools/create-item-tool.ts @@ -13,7 +13,32 @@ export const createItemToolSchema = { columnValues: z .string() .describe( - `A string containing the new column values for the item following this structure: {\\"column_id\\": \\"value\\",... you can change multiple columns at once, note that for status column you must use nested value with 'label' as a key and for date column use 'date' as key} - example: "{\\"text_column_id\\":\\"New text\\", \\"status_column_id\\":{\\"label\\":\\"Done\\"}, \\"date_column_id\\":{\\"date\\":\\"2023-05-25\\"},\\"dropdown_id\\":\\"value\\", \\"phone_id\\":\\"123-456-7890\\", \\"email_id\\":\\"test@example.com\\"}"`, + `A string containing the new column values for the item following this structure: + { + "column_id": "value", + // You can change multiple columns at once + // For status columns, use nested value with 'label' as key + // For date columns, use 'date' as key + } + + Example: + { + "text_column_id": "New text", + "status_column_id": { + "label": "Done" + }, + "date_column_id": { + "date": "2023-05-25" + }, + "phone_id": { + "phone": "12025550172", + "countryShortName": "US" + }, + "email_id": { + "email": "example@example.com", + "text": "This is an example email" + } + }` ), }; diff --git a/packages/agent-toolkit/src/core/platform-api-tools/create-workspace-tool.ts b/packages/agent-toolkit/src/core/platform-api-tools/create-workspace-tool.ts new file mode 100644 index 00000000..5d0fb2de --- /dev/null +++ b/packages/agent-toolkit/src/core/platform-api-tools/create-workspace-tool.ts @@ -0,0 +1,38 @@ +import { z } from 'zod'; +import { BaseMondayApiTool } from './base-monday-api-tool'; +import { ToolInputType, ToolOutputType, ToolType } from '../tool'; +import { createWorkspace } from '../../monday-graphql/queries.graphql'; +import { Mutation, MutationCreate_WorkspaceArgs, WorkspaceKind } from '../../monday-graphql/generated/graphql'; + +export const createWorkspaceToolSchema = { + name: z.string().describe('The name of the workspace to create'), + kind: z.nativeEnum(WorkspaceKind).default(WorkspaceKind.Open).describe('The kind of workspace to create (open or closed)'), + description: z.string().optional().describe('The description of the workspace'), +}; + +export class CreateWorkspaceTool extends BaseMondayApiTool { + name = 'create_workspace'; + type = ToolType.MUTATION; + + getDescription(): string { + return 'Create a new workspace in monday.com'; + } + + getInputSchema(): typeof createWorkspaceToolSchema { + return createWorkspaceToolSchema; + } + + async execute(input: ToolInputType): Promise> { + const variables: MutationCreate_WorkspaceArgs = { + name: input.name, + kind: input.kind, + description: input.description, + }; + + const res = await this.mondayApi.request>(createWorkspace, variables); + + return { + content: `Workspace ${res.create_workspace?.id} successfully created`, + }; + } +} \ No newline at end of file diff --git a/packages/agent-toolkit/src/core/platform-api-tools/index.ts b/packages/agent-toolkit/src/core/platform-api-tools/index.ts index b3122bcd..78469242 100644 --- a/packages/agent-toolkit/src/core/platform-api-tools/index.ts +++ b/packages/agent-toolkit/src/core/platform-api-tools/index.ts @@ -15,6 +15,8 @@ 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 { CreateBoardViewTool } from './create-board-view-tool'; +import { CreateWorkspaceTool } from './create-workspace-tool'; export const allTools = [ DeleteItemTool, @@ -34,6 +36,8 @@ export const allTools = [ CreateCustomActivityTool, CreateTimelineItemTool, FetchCustomActivityTool, + CreateBoardViewTool, + CreateWorkspaceTool, ]; export * from './delete-item-tool'; @@ -53,3 +57,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 './create-board-view-tool'; +export * from './create-workspace-tool'; \ No newline at end of file diff --git a/packages/agent-toolkit/src/mcp/toolkit.ts b/packages/agent-toolkit/src/mcp/toolkit.ts index 9e989f7b..e18305cf 100644 --- a/packages/agent-toolkit/src/mcp/toolkit.ts +++ b/packages/agent-toolkit/src/mcp/toolkit.ts @@ -20,7 +20,6 @@ export class MondayAgentToolkit extends McpServer { name: 'monday.com', version: '1.0.0', }); - this.mondayApiClient = new ApiClient({ token: config.mondayApiToken, apiVersion: config.mondayApiVersion, diff --git a/packages/agent-toolkit/src/monday-graphql/generated/graphql.ts b/packages/agent-toolkit/src/monday-graphql/generated/graphql.ts index 70954ddc..cf5ff58a 100644 --- a/packages/agent-toolkit/src/monday-graphql/generated/graphql.ts +++ b/packages/agent-toolkit/src/monday-graphql/generated/graphql.ts @@ -605,6 +605,20 @@ export type BoardView = { view_specific_data_str: Scalars['String']['output']; }; +/** The available board view types. */ +export enum BoardViewTypeValues { + /** Calendar board view. */ + CalendarBoardView = 'CalendarBoardView', + /** Doc board view. */ + DocBoardView = 'DocBoardView', + /** Empty board view. */ + EmptyBoardView = 'EmptyBoardView', + /** Form board view. */ + FormBoardView = 'FormBoardView', + /** Table board view. */ + TableBoardView = 'TableBoardView' +} + /** Options to order by. */ export enum BoardsOrderBy { /** The rank order of the board creation time (desc). */ @@ -2161,6 +2175,8 @@ export type Mutation = { complexity?: Maybe; /** Create a new board. */ create_board?: Maybe; + /** Create a new board view. */ + create_board_view?: Maybe; /** Create a new column in board. */ create_column?: Maybe; create_custom_activity?: Maybe; @@ -2463,6 +2479,14 @@ export type MutationCreate_BoardArgs = { }; +/** Update your monday.com data. */ +export type MutationCreate_Board_ViewArgs = { + board_id: Scalars['ID']['input']; + name: Scalars['String']['input']; + type: BoardViewTypeValues; +}; + + /** Update your monday.com data. */ export type MutationCreate_ColumnArgs = { after_column_id?: InputMaybe; @@ -4766,6 +4790,15 @@ export type DeleteColumnMutationVariables = Exact<{ export type DeleteColumnMutation = { __typename?: 'Mutation', delete_column?: { __typename?: 'Column', id: string } | null }; +export type CreateWorkspaceMutationVariables = Exact<{ + name: Scalars['String']['input']; + kind: WorkspaceKind; + description?: InputMaybe; +}>; + + +export type CreateWorkspaceMutation = { __typename?: 'Mutation', create_workspace?: { __typename?: 'Workspace', id?: string | null } | null }; + export type GetGraphQlSchemaQueryVariables = Exact<{ [key: string]: never; }>; @@ -4785,7 +4818,7 @@ export type TypeRefFragment = { __typename?: '__Type', kind: __TypeKind, name?: export type GetTypeDetailsQueryVariables = Exact<{ [key: string]: never; }>; -export type GetTypeDetailsQuery = { __typename?: 'Query', __type?: { __typename?: '__Type', name?: string | null, description?: string | null, kind: __TypeKind, fields?: Array<{ __typename?: '__Field', name: string, description?: string | null, type: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind } | null } | null } | null } | null }, args: Array<{ __typename?: '__InputValue', name: string, description?: string | null, defaultValue?: string | null, type: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind } | null } | null } | null } }> }> | null, inputFields?: Array<{ __typename?: '__InputValue', name: string, description?: string | null, defaultValue?: string | null, type: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind } | null } | null } | null } | null } }> | null, interfaces?: Array<{ __typename?: '__Type', name?: string | null }> | null, enumValues?: Array<{ __typename?: '__EnumValue', name: string, description?: string | null }> | null, possibleTypes?: Array<{ __typename?: '__Type', name?: string | null }> | null } | null }; +export type GetTypeDetailsQuery = { __typename?: 'Query', __type?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, description?: string | null, fields?: Array<{ __typename?: '__Field', name: string, description?: string | null, type: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind } | null } | null } }> | null, enumValues?: Array<{ __typename?: '__EnumValue', name: string, description?: string | null }> | null, inputFields?: Array<{ __typename?: '__InputValue', name: string, description?: string | null, type: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind, ofType?: { __typename?: '__Type', name?: string | null, kind: __TypeKind } | null } | null } }> | null } | null }; export type CreateCustomActivityMutationVariables = Exact<{ color: CustomActivityColor; @@ -4816,3 +4849,12 @@ export type FetchCustomActivityQueryVariables = Exact<{ [key: string]: never; }> export type FetchCustomActivityQuery = { __typename?: 'Query', custom_activity?: Array<{ __typename?: 'CustomActivity', color?: CustomActivityColor | null, icon_id?: CustomActivityIcon | null, id?: string | null, name?: string | null, type?: string | null }> | null }; + +export type CreateBoardViewMutationVariables = Exact<{ + boardId: Scalars['ID']['input']; + name: Scalars['String']['input']; + type: BoardViewTypeValues; +}>; + + +export type CreateBoardViewMutation = { __typename?: 'Mutation', create_board_view?: { __typename?: 'BoardView', id: string, name: string, type: string } | null }; diff --git a/packages/agent-toolkit/src/monday-graphql/queries.graphql.ts b/packages/agent-toolkit/src/monday-graphql/queries.graphql.ts index 29845863..de6a78c1 100644 --- a/packages/agent-toolkit/src/monday-graphql/queries.graphql.ts +++ b/packages/agent-toolkit/src/monday-graphql/queries.graphql.ts @@ -122,6 +122,14 @@ export const deleteColumn = gql` } `; +export const createWorkspace = gql` + mutation createWorkspace($name: String!, $kind: WorkspaceKind!, $description: String) { + create_workspace(name: $name, kind: $kind, description: $description) { + id + } + } +`; + export const getGraphQLSchema = gql` query getGraphQLSchema { __schema { @@ -281,13 +289,12 @@ export const introspectionQuery = gql` } `; -// it cant be a variable due to a bug in the API so must be generated string. export const generateTypeDetailsQuery = (typeName: string) => gql` query getTypeDetails { __type(name: "${typeName}") { name - description kind + description fields { name description @@ -300,39 +307,14 @@ export const generateTypeDetailsQuery = (typeName: string) => gql` ofType { name kind - ofType { - name - kind - ofType { - name - kind - } - } - } - } - } - args { - name - description - type { - name - kind - ofType { - name - kind - ofType { - name - kind - ofType { - name - kind - } - } } } - defaultValue } } + enumValues { + name + description + } inputFields { name description @@ -345,28 +327,9 @@ export const generateTypeDetailsQuery = (typeName: string) => gql` ofType { name kind - ofType { - name - kind - ofType { - name - kind - } - } } } } - defaultValue - } - interfaces { - name - } - enumValues { - name - description - } - possibleTypes { - name } } } @@ -428,3 +391,21 @@ export const fetchCustomActivity = gql` } } `; + +export const createBoardView = gql` + mutation createBoardView( + $boardId: ID! + $name: String! + $type: BoardViewTypeValues! + ) { + create_board_view( + board_id: $boardId + name: $name + type: $type + ) { + id + name + type + } + } +`; diff --git a/packages/agent-toolkit/src/monday-graphql/schema.graphql b/packages/agent-toolkit/src/monday-graphql/schema.graphql index 6a87c1f7..d7fa53e5 100644 --- a/packages/agent-toolkit/src/monday-graphql/schema.graphql +++ b/packages/agent-toolkit/src/monday-graphql/schema.graphql @@ -1097,6 +1097,24 @@ enum BoardSubscriberKind { subscriber } +"""The available board view types.""" +enum BoardViewTypeValues { + """Calendar board view.""" + CalendarBoardView + + """Doc board view.""" + DocBoardView + + """Empty board view.""" + EmptyBoardView + + """Form board view.""" + FormBoardView + + """Table board view.""" + TableBoardView +} + """ A board's view. """ @@ -4776,6 +4794,19 @@ type Mutation { workspace_id: ID ): Board + + """Create a new board view.""" + create_board_view( + """The board's unique identifier.""" + board_id: ID! + + """The name of the board view.""" + name: String! + + """The type of the board view.""" + type: BoardViewTypeValues! + ): BoardView + """ Create a new column in board. """