Skip to main content
Glama

update_datasource

Update an existing Storyblok datasource by its ID, with options to change name, slug, or dimensions.

Instructions

Updates an existing datasource in a specified Storyblok space.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasource_idYesID of the datasource to update
nameNoNew name for the datasource
slugNoNew slug for the datasource
dimensionsNoArray of dimension objects

Implementation Reference

  • The 'update_datasource' tool handler. Uses apiPut to send a PUT request to '/datasources/{datasource_id}' with optional fields (name, slug, dimensions_attributes). Returns JSON response or error.
    // Tool: update_datasource
    server.tool(
      'update_datasource',
      'Updates an existing datasource in a specified Storyblok space.',
      {
        datasource_id: z.number().describe('ID of the datasource to update'),
        name: z.string().optional().describe('New name for the datasource'),
        slug: z.string().optional().describe('New slug for the datasource'),
        dimensions: z
          .array(z.record(z.unknown()))
          .optional()
          .describe('Array of dimension objects'),
      },
      async ({ datasource_id, name, slug, dimensions }) => {
        try {
          const datasource: Record<string, unknown> = {};
          if (name !== undefined) datasource.name = name;
          if (slug !== undefined) datasource.slug = slug;
          if (dimensions !== undefined) datasource.dimensions_attributes = dimensions;
    
          const payload = { datasource };
          const data = await apiPut(`/datasources/${datasource_id}`, payload);
          return createJsonResponse(data);
        } catch (error) {
          if (error instanceof APIError) {
            return createErrorResponse(error);
          }
          throw error;
        }
      }
    );
  • Zod schema for the 'update_datasource' tool: requires datasource_id (number), optional name (string), optional slug (string), optional dimensions (array of record).
    {
      datasource_id: z.number().describe('ID of the datasource to update'),
      name: z.string().optional().describe('New name for the datasource'),
      slug: z.string().optional().describe('New slug for the datasource'),
      dimensions: z
        .array(z.record(z.unknown()))
        .optional()
        .describe('Array of dimension objects'),
    },
  • Registration of the datasource tools module, which includes 'update_datasource', via registerDatasources(server) call.
    registerDatasources(server);
  • The registerDatasources function that registers all 5 datasource tools (including 'update_datasource') with the MCP server.
    export function registerDatasources(server: McpServer): void {
      // Tool: retrieve_multiple_datasources
      server.tool(
        'retrieve_multiple_datasources',
        'Retrieves multiple datasources from a specified Storyblok space.',
        {
          search: z.string().optional().describe('Search string'),
          by_ids: z.string().optional().describe('Comma-separated list of datasource IDs'),
        },
        async ({ search, by_ids }) => {
          try {
            const params: Record<string, string> = {};
            if (search) params.search = search;
            if (by_ids) params.by_ids = by_ids;
    
            const data = await apiGet('/datasources', params);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    
      // Tool: retrieve_single_datasource
      server.tool(
        'retrieve_single_datasource',
        'Retrieves a single datasource from a specified Storyblok space.',
        {
          datasource_id: z.number().describe('ID of the datasource to retrieve'),
        },
        async ({ datasource_id }) => {
          try {
            const data = await apiGet(`/datasources/${datasource_id}`);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    
      // Tool: create_datasource
      server.tool(
        'create_datasource',
        'Creates a new datasource in a specified Storyblok space.',
        {
          name: z.string().describe('Name of the datasource'),
          slug: z.string().describe('Slug of the datasource'),
          dimensions: z
            .array(z.record(z.unknown()))
            .optional()
            .describe('Array of dimension objects'),
        },
        async ({ name, slug, dimensions }) => {
          try {
            const payload = {
              datasource: {
                name,
                slug,
                dimensions_attributes: dimensions ?? [],
              },
            };
            const data = await apiPost('/datasources', payload);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    
      // Tool: update_datasource
      server.tool(
        'update_datasource',
        'Updates an existing datasource in a specified Storyblok space.',
        {
          datasource_id: z.number().describe('ID of the datasource to update'),
          name: z.string().optional().describe('New name for the datasource'),
          slug: z.string().optional().describe('New slug for the datasource'),
          dimensions: z
            .array(z.record(z.unknown()))
            .optional()
            .describe('Array of dimension objects'),
        },
        async ({ datasource_id, name, slug, dimensions }) => {
          try {
            const datasource: Record<string, unknown> = {};
            if (name !== undefined) datasource.name = name;
            if (slug !== undefined) datasource.slug = slug;
            if (dimensions !== undefined) datasource.dimensions_attributes = dimensions;
    
            const payload = { datasource };
            const data = await apiPut(`/datasources/${datasource_id}`, payload);
            return createJsonResponse(data);
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    
      // Tool: delete_datasource
      server.tool(
        'delete_datasource',
        'Deletes a datasource from a specified Storyblok space.',
        {
          datasource_id: z.number().describe('ID of the datasource to delete'),
        },
        async ({ datasource_id }) => {
          try {
            await apiDelete(`/datasources/${datasource_id}`);
            return {
              content: [{ type: 'text' as const, text: 'DataSource deleted successfully' }],
            };
          } catch (error) {
            if (error instanceof APIError) {
              return createErrorResponse(error);
            }
            throw error;
          }
        }
      );
    }
  • The apiPut helper function used by the handler to make the PUT HTTP request. Builds URL from path, sends JSON body with auth headers, and handles the response.
    export async function apiPut<T = unknown>(
      path: string,
      body: unknown
    ): Promise<T> {
      const url = buildManagementUrl(path);
      const response = await fetch(url, {
        method: 'PUT',
        headers: getManagementHeaders(),
        body: JSON.stringify(body),
      });
      return handleResponse<T>(response, url);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It only says 'updates', but does not disclose mutation specifics (partial vs full replace), required permissions, idempotency, side effects, or return behavior. This is minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It is front-loaded. However, it could be slightly expanded to include more utility without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (4 params, no output schema), the description is incomplete. It does not explain return values, error conditions, or how it interacts with the space. Many sibling tools exist but no differentiation is provided.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds no extra meaning beyond the parameter names, but the schema itself documents each field (datasource_id, name, slug, dimensions).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Updates an existing datasource') and the context ('in a specified Storyblok space'), distinguishing it from create/delete/retrieve siblings. However, 'in a specified Storyblok space' implies a space_id parameter that is not present in the schema, slightly reducing clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives (e.g., update_datasource_entry, create_datasource). It lacks prerequisites, exclusions, or context about typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/hypescale/storyblok-mcp-server'

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