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
10 changes: 10 additions & 0 deletions packages/agent-toolkit/src/mcp/toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class MondayAgentToolkit extends McpServer {
private readonly mondayApiClient: ApiClient;
private readonly mondayApiToken: string;
private readonly dynamicToolManager: DynamicToolManager = new DynamicToolManager();
private readonly readOnlyMode: boolean;

/**
* Creates a new instance of the Monday Agent Toolkit
Expand All @@ -37,6 +38,7 @@ export class MondayAgentToolkit extends McpServer {

this.mondayApiClient = this.createApiClient(config);
this.mondayApiToken = config.mondayApiToken;
this.readOnlyMode = config.toolsConfiguration?.readOnlyMode ?? false;

this.registerTools(config);
}
Expand Down Expand Up @@ -116,6 +118,14 @@ export class MondayAgentToolkit extends McpServer {
async (args: any, _extra: any) => {
try {
let result;

// Read-only mode protection: prevent WRITE and ALL_API tools from executing
if (this.readOnlyMode && (tool.type === 'write' || tool.type === 'all_api')) {
throw new Error(
`Tool '${tool.name}' cannot be executed in read-only mode. This tool performs write/modification operations which are disabled in read-only mode.`
);
}

if (inputSchema) {
const parsedArgs = z.object(inputSchema).safeParse(args);
if (!parsedArgs.success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ export const getFilteredToolInstances = (
if (config.mode === ToolMode.API && config.enableDynamicApiTools === false) {
shouldFilter = shouldFilter || toolInstance.type === ToolType.ALL_API;
}
if (config.readOnlyMode) {
shouldFilter = shouldFilter || toolInstance.type !== ToolType.READ;
}
if (config.include) {
shouldFilter = shouldFilter || !config.include?.includes(toolInstance.name);
} else if (config.exclude) {
Expand Down