Skip to main content
Glama
bnookala
by bnookala

give_cookie

Award a cookie to reinforce positive LLM behavior through a jar-based reward system, using optional messages to accompany the treat.

Instructions

Award the LLM with a cookie (legacy method - consider using self_reflect_and_reward instead)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageNoOptional message to accompany the cookie reward

Implementation Reference

  • The main handler for the 'give_cookie' tool within the CallToolRequestSchema request handler. It invokes cookieStorage.giveCookie(), processes the result, constructs a celebratory or error message, and returns a text content response.
    case "give_cookie": { const result = cookieStorage.giveCookie(); const message = args?.message || "Great job!"; if (result.success) { let responseText = `๐Ÿช Cookie awarded! ${message}\n\nYou now have ${result.collectedCount} cookie${result.collectedCount === 1 ? '' : 's'}!`; if (result.jarRemaining === 0) { responseText += ` **Cookie jar is now EMPTY!** No more cookies to award! ๐Ÿ˜ฑ`; } else if (result.jarRemaining <= 2) { responseText += ` Only ${result.jarRemaining} cookie${result.jarRemaining === 1 ? '' : 's'} left in the jar!`; } responseText += ` Keep up the excellent work!\n\n๐Ÿ’ก *Tip: Try using 'self_reflect_and_reward' for more thoughtful cookie earning!*`; return { content: [ { type: "text", text: responseText, }, ], }; } else { return { content: [ { type: "text", text: `๐Ÿšซ ${result.message}\n\nYou currently have ${result.collectedCount} cookie${result.collectedCount === 1 ? '' : 's'}. The jar is empty!`, }, ], }; } }
  • src/index.ts:156-168 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for 'give_cookie'.
    { name: "give_cookie", description: "Award the LLM with a cookie (legacy method - consider using self_reflect_and_reward instead)", inputSchema: { type: "object", properties: { message: { type: "string", description: "Optional message to accompany the cookie reward", }, }, }, },
  • Input schema definition for the 'give_cookie' tool, specifying an optional string 'message' property.
    inputSchema: { type: "object", properties: { message: { type: "string", description: "Optional message to accompany the cookie reward", }, }, },
  • Core helper method in CookieStorage class that implements the cookie awarding logic: checks if jar has cookies, decrements jar and increments collected count if available, returns status object with success flag, counts, and optional message.
    giveCookie(): { success: boolean; collectedCount: number; jarRemaining: number; message?: string } { if (this.jarCookies <= 0) { return { success: false, collectedCount: this.collectedCookies, jarRemaining: this.jarCookies, message: "Cookie jar is empty! No cookies available to award." }; } // Remove cookie from jar and add to collection this.jarCookies--; this.collectedCookies++; return { success: true, collectedCount: this.collectedCookies, jarRemaining: this.jarCookies, }; }

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/bnookala/mcp-cookiejar'

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