Skip to main content
Glama

manage_inventory

Control character inventory in ChatRPG by adding, removing, equipping, moving, and transferring items between characters.

Instructions

Manage character inventory. Operations: give (add items), take (remove items), equip (equip to slot), unequip (remove from slot), move (change container), list (show inventory), transfer (move between characters).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
batchNo

Implementation Reference

  • Tool registration entry for 'manage_inventory'. Specifies name, description, converts manageInventorySchema to JSON schema, and provides wrapper handler that calls the actual manageInventory function from data.ts with error handling.
    manage_inventory: {
      name: 'manage_inventory',
      description: 'Manage character inventory. Operations: give (add items), take (remove items), equip (equip to slot), unequip (remove from slot), move (change container), list (show inventory), transfer (move between characters).',
      inputSchema: toJsonSchema(manageInventorySchema),
      handler: async (args) => {
        try {
          const result = await manageInventory(args);
          return result;
        } catch (err) {
          if (err instanceof z.ZodError) {
            const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ');
            return error(`Validation failed: ${messages}`);
          }
          const message = err instanceof Error ? err.message : String(err);
          return error(message);
        }
      },
    },
  • Zod schema definition for manage_inventory tool. Supports single operations (give, take, equip, unequip, move, list, transfer) via discriminated union and batch operations. Includes detailed item schema with type, quantity, weight, etc., and equipment slots.
    /** Item schema for give operation */
    const itemSchema = z.object({
      name: z.string().min(1),
      type: ItemTypeSchema,
      quantity: z.number().int().min(1),
      weight: z.number().optional(),
      value: z.number().optional(),
      description: z.string().optional(),
      properties: z.array(z.string()).optional(),
      damage: z.string().optional(),
      damageType: z.string().optional(),
      ac: z.number().optional(),
      container: z.string().optional(),
    });
    
    /** Give operation schema */
    const giveOperationSchema = z.object({
      operation: z.literal('give'),
      characterId: z.string().optional(),
      characterName: z.string().optional(),
      item: itemSchema,
    });
    
    /** Take operation schema */
    const takeOperationSchema = z.object({
      operation: z.literal('take'),
      characterId: z.string().optional(),
      characterName: z.string().optional(),
      itemName: z.string(),
      quantity: z.number().int().min(1).optional().default(1),
    });
    
    /** Equip operation schema */
    const equipOperationSchema = z.object({
      operation: z.literal('equip'),
      characterId: z.string().optional(),
      characterName: z.string().optional(),
      itemName: z.string(),
      slot: EquipmentSlotSchema,
    });
    
    /** Unequip operation schema */
    const unequipOperationSchema = z.object({
      operation: z.literal('unequip'),
      characterId: z.string().optional(),
      characterName: z.string().optional(),
      itemName: z.string().optional(),
      slot: EquipmentSlotSchema.optional(),
    });
    
    /** Move operation schema */
    const moveItemOperationSchema = z.object({
      operation: z.literal('move'),
      characterId: z.string().optional(),
      characterName: z.string().optional(),
      itemName: z.string(),
      fromContainer: z.string().optional(),
      toContainer: z.string(),
      quantity: z.number().int().min(1).optional(),
    });
    
    /** List operation schema */
    const listInventoryOperationSchema = z.object({
      operation: z.literal('list'),
      characterId: z.string().optional(),
      characterName: z.string().optional(),
      filterType: ItemTypeSchema.optional(),
    });
    
    /** Transfer operation schema */
    const transferOperationSchema = z.object({
      operation: z.literal('transfer'),
      characterId: z.string().optional(),
      characterName: z.string().optional(),
      toCharacterId: z.string().optional(),
      toCharacterName: z.string().optional(),
      itemName: z.string(),
      quantity: z.number().int().min(1).optional().default(1),
    });
    
    /** Single inventory operation schema */
    const singleInventoryOperationSchema = z.discriminatedUnion('operation', [
      giveOperationSchema,
      takeOperationSchema,
      equipOperationSchema,
      unequipOperationSchema,
      moveItemOperationSchema,
      listInventoryOperationSchema,
      transferOperationSchema,
    ]);
    
    /** Batch operation schema */
    const batchInventoryOperationSchema = z.object({
      batch: z.array(singleInventoryOperationSchema).max(20),
    });
    
    /** Combined schema for manage_inventory */
    export const manageInventorySchema = z.union([
      singleInventoryOperationSchema,
      batchInventoryOperationSchema,
    ]);
  • Core handler implementation. Parses input using manageInventorySchema, handles single operations by dispatching to specific handlers (handleInventoryGive, etc.) or processes batch up to 20 operations. Returns formatted ASCII box output in MCP content format.
    export async function manageInventory(input: unknown): Promise<{ content: { type: 'text'; text: string }[] }> {
      try {
        const parsed = manageInventorySchema.parse(input);
    
        // Check if batch operation
        if ('batch' in parsed) {
          const results: { success: boolean; result: string }[] = [];
          
          for (const op of parsed.batch) {
            try {
              const result = processSingleOperation(op);
              const isError = result.includes('ERROR');
              results.push({ success: !isError, result });
            } catch (err) {
              results.push({ 
                success: false, 
                result: createBox('ERROR', [err instanceof Error ? err.message : 'Unknown error'], DISPLAY_WIDTH) 
              });
            }
          }
    
          const successCount = results.filter(r => r.success).length;
          const failCount = results.filter(r => !r.success).length;
    
          const lines: string[] = [];
          lines.push(`Operations: ${parsed.batch.length}`);
          lines.push(`Successful: ${successCount}`);
          lines.push(`Failed: ${failCount}`);
    
          return { content: [{ type: 'text' as const, text: createBox('BATCH COMPLETE', lines, DISPLAY_WIDTH) }] };
        }
    
        // Single operation
        const result = processSingleOperation(parsed);
        return { content: [{ type: 'text' as const, text: result }] };
      } catch (error) {
        const lines: string[] = [];
    
        if (error instanceof z.ZodError) {
          for (const issue of error.issues) {
            lines.push(`${issue.path.join('.')}: ${issue.message}`);
          }
        } else if (error instanceof Error) {
          lines.push(error.message);
        } else {
          lines.push('An unknown error occurred');
        }
    
        return { content: [{ type: 'text' as const, text: createBox('ERROR', lines, DISPLAY_WIDTH) }] };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It lists operation types but doesn't describe critical behaviors: whether operations are atomic/batched, if there are permission requirements, what happens on errors (e.g., trying to take non-existent items), or how the 'batch' parameter works with the 20-item limit. The description mentions operations but lacks behavioral context needed for safe invocation.

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 appropriately concise - a single sentence listing all operations. It's front-loaded with the core purpose. However, the comma-separated operation list could be slightly more structured (e.g., grouping read vs. write operations), but it efficiently communicates scope without unnecessary elaboration.

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?

For a complex tool with 7 distinct operation types, nested input schema (batch array with 20 max items), and no annotations or output schema, the description is inadequate. It doesn't explain how operations interact, what the tool returns (especially for 'list'), error conditions, or the relationship between operation types and the schema structure. The agent would struggle to use this tool correctly based solely on the description.

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?

Schema description coverage is 0%, so the description must compensate. It mentions operations but doesn't explain the 'batch' parameter structure, how to specify character vs. item details, or the meaning of operation-specific fields like 'slot' or 'container'. The description provides high-level operation names but minimal guidance on how to structure the complex nested input schema shown.

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 tool's purpose: 'Manage character inventory' with specific operations listed (give, take, equip, unequip, move, list, transfer). It distinguishes itself from siblings like 'manage_party' or 'manage_notes' by focusing on inventory operations. However, it doesn't explicitly differentiate from potential inventory-related siblings that might not exist in the current list.

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 lists operations but provides no guidance on when to use this tool versus alternatives. For example, it doesn't specify if this should be used instead of 'update_character' for inventory changes, or whether 'list' here differs from other character query tools. No context about prerequisites, sequencing, or exclusions is mentioned.

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/Mnehmos/mnehmos.chatrpg.game'

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