Skip to main content
Glama

update-tag

Modify the name of an existing tag in n8n workflows to maintain organized and accurate workflow categorization.

Instructions

Update a tag's name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientIdYes
idYes
nameYes

Implementation Reference

  • The main handler for the 'update-tag' tool within the CallToolRequestSchema switch statement. It retrieves the N8nClient instance and calls its updateTag method.
    case "update-tag": {
      const { clientId, id, name } = args as { clientId: string; id: string; name: string };
      const client = clients.get(clientId);
      if (!client) {
        return {
          content: [{
            type: "text",
            text: "Client not initialized. Please run init-n8n first.",
          }],
          isError: true
        };
      }
    
      try {
        const tag = await client.updateTag(id, name);
        return {
          content: [{
            type: "text",
            text: `Successfully updated tag:\n${JSON.stringify(tag, null, 2)}`,
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: error instanceof Error ? error.message : "Unknown error occurred",
          }],
          isError: true
        };
      }
    }
  • The N8nClient method that performs the actual API call to update a tag's name via PUT /tags/{id}.
    async updateTag(id: string, name: string): Promise<N8nTag> {
      return this.makeRequest<N8nTag>(`/tags/${id}`, {
        method: 'PUT',
        body: JSON.stringify({ name }),
      });
    }
  • src/index.ts:770-782 (registration)
    Tool registration in the listTools response, including name, description, and input schema.
    {
      name: "update-tag",
      description: "Update a tag's name.",
      inputSchema: {
        type: "object",
        properties: {
          clientId: { type: "string" },
          id: { type: "string" },
          name: { type: "string" }
        },
        required: ["clientId", "id", "name"]
      }
    },
  • Type definition for N8nTag used in updateTag responses.
      id: string;
      name: string;
      createdAt?: string;
      updatedAt?: string;
    }
    
    interface N8nTagList {
      data: N8nTag[];
      nextCursor?: string;
    }
    
    interface N8nAuditResult {
      'Credentials Risk Report'?: any;
      'Database Risk Report'?: any;
      'Filesystem Risk Report'?: any;
      'Nodes Risk Report'?: any;
      'Instance Risk Report'?: any;
    }
    
    class N8nClient {
      constructor(
        private baseUrl: string,
        private apiKey: string
      ) {
        // Remove trailing slash if present
        this.baseUrl = baseUrl.replace(/\/$/, '');
      }
    
      private async makeRequest<T>(endpoint: string, options: any = {}): Promise<T> {
        const url = `${this.baseUrl}/api/v1${endpoint}`;
        const headers = {
          'X-N8N-API-KEY': this.apiKey,
          'Accept': 'application/json',
          'Content-Type': 'application/json',
        };
    
        try {
          const response = await fetch(url, {
            ...options,
            headers: {
              ...headers,
              ...options.headers,
            },
          });
    
          if (!response.ok) {
            const errorText = await response.text();
            let errorMessage: string;
            try {
              const errorJson = JSON.parse(errorText);
              // Check for license-related errors
              if (errorJson.message && errorJson.message.includes('license')) {
                errorMessage = `This operation requires an n8n Enterprise license with project management features enabled. Error: ${errorJson.message}`;
              } else {
                errorMessage = errorJson.message || errorText;
              }
            } catch {
              errorMessage = errorText;
            }
            throw new Error(`N8N API error: ${errorMessage}`);
          }
    
          // Handle 204 No Content responses
          if (response.status === 204) {
            return {} as T;
          }
    
          return await response.json() as T;
        } catch (error) {
          if (error instanceof Error) {
            throw new Error(`Failed to connect to n8n: ${error.message}`);
          }
          throw error;
        }
      }
    
      async listWorkflows(): Promise<N8nWorkflowList> {
        return this.makeRequest<N8nWorkflowList>('/workflows');
      }
    
      async getWorkflow(id: string): Promise<N8nWorkflow> {
        return this.makeRequest<N8nWorkflow>(`/workflows/${id}`);
      }
    
      async createWorkflow(name: string, nodes: any[] = [], connections: any = {}): Promise<N8nWorkflow> {
        return this.makeRequest<N8nWorkflow>('/workflows', {
          method: 'POST',
          body: JSON.stringify({
            name,
            nodes,
            connections,
            settings: {
              saveManualExecutions: true,
              saveExecutionProgress: true,
            },
          }),
        });
      }
    
      async updateWorkflow(id: string, workflow: Partial<N8nWorkflow>): Promise<N8nWorkflow> {
        return this.makeRequest<N8nWorkflow>(`/workflows/${id}`, {
          method: 'PUT',
          body: JSON.stringify(workflow),
        });
      }
    
      async deleteWorkflow(id: string): Promise<N8nWorkflow> {
        return this.makeRequest<N8nWorkflow>(`/workflows/${id}`, {
          method: 'DELETE',
        });
      }
    
      async activateWorkflow(id: string): Promise<N8nWorkflow> {
        return this.makeRequest<N8nWorkflow>(`/workflows/${id}/activate`, {
          method: 'POST',
        });
      }
    
      async deactivateWorkflow(id: string): Promise<N8nWorkflow> {
        return this.makeRequest<N8nWorkflow>(`/workflows/${id}/deactivate`, {
          method: 'POST',
        });
      }
    
      // Project management methods (requires n8n Enterprise license)
      async listProjects(): Promise<N8nProjectList> {
        return this.makeRequest<N8nProjectList>('/projects');
      }
    
      async createProject(name: string): Promise<void> {
        return this.makeRequest<void>('/projects', {
          method: 'POST',
          body: JSON.stringify({ name }),
        });
      }
    
      async deleteProject(projectId: string): Promise<void> {
        return this.makeRequest<void>(`/projects/${projectId}`, {
          method: 'DELETE',
        });
      }
    
      async updateProject(projectId: string, name: string): Promise<void> {
        return this.makeRequest<void>(`/projects/${projectId}`, {
          method: 'PUT',
          body: JSON.stringify({ name }),
        });
      }
    
      // User management methods
      async listUsers(): Promise<N8nUserList> {
        return this.makeRequest<N8nUserList>('/users');
      }
    
      async createUsers(users: Array<{ email: string; role?: 'global:admin' | 'global:member' }>): Promise<any> {
        return this.makeRequest('/users', {
          method: 'POST',
          body: JSON.stringify(users),
        });
      }
    
      async getUser(idOrEmail: string): Promise<N8nUser> {
        return this.makeRequest<N8nUser>(`/users/${idOrEmail}`);
      }
    
      async deleteUser(idOrEmail: string): Promise<void> {
        return this.makeRequest<void>(`/users/${idOrEmail}`, {
          method: 'DELETE',
        });
      }
    
      // Variable management methods
      async listVariables(): Promise<N8nVariableList> {
        return this.makeRequest<N8nVariableList>('/variables');
      }
    
      async createVariable(key: string, value: string): Promise<void> {
        return this.makeRequest<void>('/variables', {
          method: 'POST',
          body: JSON.stringify({ key, value }),
        });
      }
    
      async deleteVariable(id: string): Promise<void> {
        return this.makeRequest<void>(`/variables/${id}`, {
          method: 'DELETE',
        });
      }
    
      // Execution management methods
      async getExecutions(options: { 
        includeData?: boolean; 
        status?: 'error' | 'success' | 'waiting';
        workflowId?: string;
        limit?: number;
      } = {}): Promise<N8nExecutionList> {
        const params = new URLSearchParams();
        if (options.includeData !== undefined) params.append('includeData', String(options.includeData));
        if (options.status) params.append('status', options.status);
        if (options.workflowId) params.append('workflowId', options.workflowId);
        if (options.limit) params.append('limit', String(options.limit));
    
        return this.makeRequest<N8nExecutionList>(`/executions?${params.toString()}`);
      }
    
      async getExecution(id: number, includeData: boolean = false): Promise<N8nExecution> {
        const params = new URLSearchParams();
        if (includeData) params.append('includeData', 'true');
    
        return this.makeRequest<N8nExecution>(`/executions/${id}?${params.toString()}`);
      }
    
      async deleteExecution(id: number): Promise<N8nExecution> {
        return this.makeRequest<N8nExecution>(`/executions/${id}`, {
          method: 'DELETE',
        });
      }
    
      // Tag management methods
      async createTag(name: string): Promise<N8nTag> {
        return this.makeRequest<N8nTag>('/tags', {
          method: 'POST',
          body: JSON.stringify({ name }),
        });
      }
    
      async getTags(options: { limit?: number } = {}): Promise<N8nTagList> {
        const params = new URLSearchParams();
        if (options.limit) params.append('limit', String(options.limit));
    
        return this.makeRequest<N8nTagList>(`/tags?${params.toString()}`);
      }
    
      async getTag(id: string): Promise<N8nTag> {
        return this.makeRequest<N8nTag>(`/tags/${id}`);
      }
    
      async updateTag(id: string, name: string): Promise<N8nTag> {
        return this.makeRequest<N8nTag>(`/tags/${id}`, {
          method: 'PUT',
          body: JSON.stringify({ name }),
        });
      }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/illuminaresolutions/n8n-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server