Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

create-item

Add new items to your Xero accounting system, defining product or service details for sales and purchase tracking.

Instructions

Create an item in Xero.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
nameYes
descriptionNo
purchaseDescriptionNo
purchaseDetailsNo
salesDetailsNo
isTrackedAsInventoryNo
inventoryAssetAccountCodeNo

Implementation Reference

  • Core handler function that wraps the Xero API call to create an item, handling errors and returning structured response.
    export async function createXeroItem(
      itemDetails: ItemDetails
    ): Promise<XeroClientResponse<Item | null>> {
      try {
        const item = await createItem(itemDetails);
    
        return {
          result: item,
          isError: false,
          error: null,
        };
      } catch (error) {
        return {
          result: null,
          isError: true,
          error: formatError(error),
        };
      }
  • Tool-specific handler that calls the core createXeroItem handler and formats the MCP tool response.
    async ({
      code,
      name,
      description,
      purchaseDescription,
      purchaseDetails,
      salesDetails,
      isTrackedAsInventory,
      inventoryAssetAccountCode,
    }) => {
      const result = await createXeroItem({
        code,
        name,
        description,
        purchaseDescription,
        purchaseDetails,
        salesDetails,
        isTrackedAsInventory,
        inventoryAssetAccountCode,
      });
    
      if (result.isError) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error creating item: ${result.error}`,
            },
          ],
        };
      }
    
      const item = result.result;
    
      return {
        content: [
          {
            type: "text" as const,
            text: [
              "Item created successfully:",
              `ID: ${item?.itemID}`,
              `Code: ${item?.code}`,
              `Name: ${item?.name}`,
            ]
              .filter(Boolean)
              .join("\n"),
          },
        ],
      };
    },
  • Input schema for the create-item tool defined using Zod, including sub-schemas for purchase and sales details.
    const CreateItemTool = CreateXeroTool(
      "create-item",
      "Create an item in Xero.",
      {
        code: z.string(),
        name: z.string(),
        description: z.string().optional(),
        purchaseDescription: z.string().optional(),
        purchaseDetails: purchaseDetailsSchema.optional(),
        salesDetails: salesDetailsSchema.optional(),
        isTrackedAsInventory: z.boolean().optional(),
        inventoryAssetAccountCode: z.string().optional(),
      },
  • Registers all create tools, including create-item, with the MCP server using server.tool().
    CreateTools.map((tool) => tool()).forEach((tool) =>
      server.tool(tool.name, tool.description, tool.schema, tool.handler),
  • Helper factory function used to standardize the creation of Xero MCP tools with name, description, schema, and handler.
    export const CreateXeroTool =
      <Args extends ZodRawShapeCompat>(
        name: string,
        description: string,
        schema: Args,
        handler: ToolCallback<Args>,
      ): (() => ToolDefinition<ZodRawShapeCompat>) =>
      () => ({
        name: name,
        description: description,
        schema: schema,
        handler: handler,
      });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Create' which implies a write/mutation operation, but fails to describe permissions needed, whether the operation is idempotent, error handling, or what happens on success (e.g., returns the created item). For a mutation tool with zero annotation coverage, this is a significant gap.

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

Conciseness5/5

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

The description is a single, clear sentence with no wasted words. It's front-loaded with the core purpose, making it efficient and easy to parse, though this brevity contributes to gaps in other dimensions.

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 (8 parameters with nested objects, no annotations, no output schema), the description is incomplete. It doesn't cover parameter meanings, behavioral traits, or output expectations, making it inadequate for a mutation tool in a system with many similar tools.

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

Parameters2/5

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

With 0% schema description coverage and 8 parameters (including nested objects), the description provides no information about parameters. It doesn't explain what 'code', 'name', 'purchaseDetails', or other fields mean, their formats, or constraints, leaving the schema as the sole source of parameter documentation.

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 ('Create') and resource ('item in Xero'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'create-contact' or 'create-invoice' beyond the resource type, missing explicit differentiation.

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?

No guidance is provided on when to use this tool versus alternatives. With many sibling tools for creating different resources in Xero (e.g., create-contact, create-invoice), the description lacks context on prerequisites, appropriate scenarios, or exclusions, leaving the agent to infer usage.

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/XeroAPI/xero-mcp-server'

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