Skip to main content
Glama
andrewlwn77
by andrewlwn77

create_view

Create a new view for a NocoDB table to display data in different formats like grid, gallery, form, kanban, or calendar.

Instructions

Create a new view for a table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_idYesThe ID of the table
titleYesTitle of the new view
typeNoType of view (1=Grid, 2=Gallery, 3=Form, 4=Kanban, 5=Calendar)

Implementation Reference

  • Executes the create_view tool by calling the NocoDBClient's createView method and formatting the response.
    handler: async (
      client: NocoDBClient,
      args: {
        table_id: string;
        title: string;
        type?: number;
      },
    ) => {
      const view = await client.createView(
        args.table_id,
        args.title,
        args.type || 1,
      );
      return {
        view: {
          id: view.id,
          title: view.title,
          type: view.type,
          fk_model_id: view.fk_model_id,
          created_at: view.created_at,
          updated_at: view.updated_at,
        },
        message: `View '${view.title}' created successfully`,
      };
    },
  • Defines the input schema for the create_view tool, including required table_id and title, optional type.
    inputSchema: {
      type: "object",
      properties: {
        table_id: {
          type: "string",
          description: "The ID of the table",
        },
        title: {
          type: "string",
          description: "Title of the new view",
        },
        type: {
          type: "number",
          description:
            "Type of view (1=Grid, 2=Gallery, 3=Form, 4=Kanban, 5=Calendar)",
          default: 1,
        },
      },
      required: ["table_id", "title"],
    },
  • src/index.ts:55-62 (registration)
    Includes the viewTools (containing create_view) in the allTools array registered with the MCP server.
    const allTools = [
      ...databaseTools,
      ...tableTools,
      ...recordTools,
      ...viewTools,
      ...queryTools,
      ...attachmentTools,
    ];
  • NocoDBClient method invoked by the tool handler to perform the HTTP POST request creating the view.
    async createView(
      tableId: string,
      title: string,
      type: number = 1,
    ): Promise<NocoDBView> {
      const response = await this.client.post(
        `/api/v2/meta/tables/${tableId}/views`,
        {
          title,
          type,
        },
      );
      return response.data;
    }

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/andrewlwn77/nocodb-mcp'

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