Skip to main content
Glama

Chat with a Duck

chat_with_duck

Debug your problems by explaining them to a rubber duck that maintains conversation context. Choose from various AI providers, models, and optionally include images.

Instructions

Have a conversation with a duck, maintaining context across messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversation_idYesConversation ID (creates new if not exists)
messageYesYour message to the duck
providerNoProvider to use (can switch mid-conversation)
modelNoSpecific model to use (optional)
imagesNoOptional images to include with the message (for vision-capable models)

Implementation Reference

  • Main handler for chat_with_duck tool. Manages conversation context (create/retrieve/switch), adds user messages, calls the LLM provider, records assistant responses, and returns formatted output with conversation metadata.
    export async function chatDuckTool(
      providerManager: ProviderManager,
      conversationManager: ConversationManager,
      args: Record<string, unknown>
    ) {
      const { conversation_id, message, provider, model, images } = args as {
        conversation_id?: string;
        message?: string;
        provider?: string;
        model?: string;
        images?: ImageInput[];
      };
    
      if (!conversation_id || !message) {
        throw new Error('conversation_id and message are required');
      }
    
      // Get or create conversation
      let conversation = conversationManager.getConversation(conversation_id);
    
      if (!conversation) {
        // Create new conversation with specified or default provider
        const providerName = provider || providerManager.getProviderNames()[0];
        conversation = conversationManager.createConversation(conversation_id, providerName);
        logger.info(`Created new conversation: ${conversation_id} with ${providerName}`);
      } else if (provider && provider !== conversation.provider) {
        // Switch provider if requested
        conversation = conversationManager.switchProvider(conversation_id, provider);
        logger.info(`Switched conversation ${conversation_id} to ${provider}`);
      }
    
      // Add user message to conversation
      const userContent = buildContent(message, images);
      conversationManager.addMessage(conversation_id, {
        role: 'user',
        content: userContent,
        timestamp: new Date(),
      });
    
      // Get conversation context
      const messages = conversationManager.getConversationContext(conversation_id);
    
      // Get response from provider
      const providerToUse = provider || conversation.provider;
      const response = await providerManager.askDuck(providerToUse, '', {
        messages,
        model,
      });
    
      // Add assistant response to conversation
      conversationManager.addMessage(conversation_id, {
        role: 'assistant',
        content: response.content,
        timestamp: new Date(),
        provider: providerToUse,
      });
    
      // Format response
      const formattedResponse = formatDuckResponse(response.nickname, response.content, response.model);
    
      // Add conversation info
      const conversationInfo = `\n\nšŸ’¬ Conversation: ${conversation_id} | Messages: ${messages.length + 1}`;
      const latencyInfo = `\nā±ļø Latency: ${response.latency}ms`;
    
      logger.info(`Duck ${response.nickname} responded in conversation ${conversation_id}`);
    
      return {
        content: [
          {
            type: 'text',
            text: formattedResponse + conversationInfo + latencyInfo,
          },
        ],
      };
    }
  • src/server.ts:284-317 (registration)
    Registration of the chat_with_duck tool via this.server.registerTool, including input schema with conversation_id, message, optional provider/model/images, and an async handler that delegates to chatDuckTool.
    // chat_with_duck
    this.server.registerTool(
      'chat_with_duck',
      {
        title: 'Chat with a Duck',
        description: 'Have a conversation with a duck, maintaining context across messages',
        inputSchema: {
          conversation_id: z.string().describe('Conversation ID (creates new if not exists)'),
          message: z.string().describe('Your message to the duck'),
          provider: this.providerEnum().optional().describe('Provider to use (can switch mid-conversation)'),
          model: z.string().optional().describe('Specific model to use (optional)'),
          images: z
            .array(ImageInputSchema)
            .optional()
            .describe('Optional images to include with the message (for vision-capable models)'),
        },
        annotations: {
          openWorldHint: true,
        },
      },
      async (args) => {
        try {
          return this.toolResult(
            await chatDuckTool(
              this.providerManager,
              this.conversationManager,
              args as Record<string, unknown>
            )
          );
        } catch (error) {
          return this.toolErrorResult(error);
        }
      }
    );
  • Shared Zod schema for image inputs (base64 data, URL, MIME type) used by chat_with_duck and other tools.
    const ImageInputSchema = z
      .object({
        data: z.string().optional().describe('Base64-encoded image data'),
        url: z.string().optional().describe('Image URL — passed directly to the LLM provider'),
        mimeType: z
          .string()
          .optional()
          .describe('MIME type (e.g., "image/png") — required for base64 data, optional for URLs'),
      })
  • Formats the duck's response with emoji, provider name, and optional model for display.
    export function formatDuckResponse(provider: string, message: string, model?: string): string {
      if (model) {
        return `šŸ¦† [${provider} | ${model}]: ${message}`;
      }
      return `šŸ¦† [${provider}]: ${message}`;
    }
  • Builds message content array with text and optional image parts (URL or base64) for chat_with_duck.
    export function buildContent(text: string, images?: ImageInput[]): MessageContent {
      if (!images || images.length === 0) return text;
      const parts: ContentPart[] = [{ type: 'text', text }];
      for (const img of images) {
        if (img.url) {
          const part: ImageContentPartUrl = { type: 'image', url: img.url };
          if (img.mimeType) part.mimeType = img.mimeType;
          parts.push(part);
        } else if (img.data !== undefined && img.mimeType !== undefined) {
          parts.push({ type: 'image', data: img.data, mimeType: img.mimeType });
        }
      }
      return parts;
    }
Behavior3/5

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

The description adds that it 'maintain[s] context across messages', indicating statefulness. However, it does not disclose other behavioral traits such as persistence of conversations, side effects of switching provider/model, or how images are handled. The annotation 'openWorldHint: true' signals potential side effects, but the description does not elaborate.

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 sentence that is front-loaded with the verb 'Have' and the core purpose. No redundant words; every part is relevant.

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

Completeness4/5

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

Given the tool's complexity (5 parameters, multiple providers, optional images) and no output schema, the description is adequate but could be more thorough. It captures the essential chat functionality and context maintenance, but does not mention that the tool supports multiple models or image input (though schema covers it).

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?

The input schema has 100% description coverage, so the schema already explains each parameter. The description adds minimal semantic value beyond stating that context is maintained (linking to conversation_id). Without schema coverage limitations, a baseline of 3 is appropriate.

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

Purpose5/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: 'Have a conversation with a duck, maintaining context across messages'. It uses a specific verb ('Have a conversation') and resource ('a duck'), and it implicitly distinguishes from siblings like 'ask_duck' (likely single question) and 'compare_ducks' (comparison).

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

Usage Guidelines3/5

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

The description implies usage for multi-turn conversations (by mentioning 'maintaining context') but does not explicitly state when to use this tool versus alternatives like 'duck_council' or 'duck_debate'. No guidance on when not to use it or what preconditions exist.

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/nesquikm/mcp-rubber-duck'

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