This guide will help you run the Triplewhale MCP Server as an agent and access its tools in a Meshagent Room in the cloud.

Prerequisites

Required Environment Variables

  • TRIPLEWHALE_API_KEY: Your Triplewhale API key
    Example: TRIPLEWHALE_API_KEY=your-triplewhale-api-key-here

Step-by-Step

  1. Install Meshagent and all dependencies:

    pip install "meshagent[all]"
    
  2. Sign up and authenticate with Meshagent:

  3. Start the Triplewhale MCP Server in a Meshagent Room:

    meshagent service test \
      --room=test \
      --role=agent \
      --image=meshagent/mcp-triplewhale:latest \
      --env MESHAGENT_PORT=8001 \
      --env TRIPLEWHALE_API_KEY=your-triplewhale-api-key-here \
      --port="num=8001 path=/webhook liveness=/ type=meshagent.callable" \
      --name=mcp-triplewhale-service
    
    • This command launches a Meshagent Room (test) with the Triplewhale MCP Server exposed inside. The room will automatically close if it becomes inactive.
  4. Start a chatbot in the Meshagent Room with the Triplewhale Toolkit:

    meshagent chatbot join --room=test --agent-name=sample --name=sample --toolkit=mcp-triplewhale
    
    • This will start a chatbot named sample that can use the Triplewhale tools in the room.
    • Multiple toolkits can be used with the same agent in the room.
    • A link to interact with the agent and tools will appear in the output of this command.

Tools Available

Tools Provided

ToolShort Description
mobymoby tool helps users access e-commerce performance data.

Tool Details

Tool: moby

moby tool helps users access e-commerce performance data. The tool prompts the user to enter their shopId, which is then used for tool as input; shopId is required for this tool.

  • API Endpoint: /willy/moby-chat
  • Description: Sends a user question to the Triple Whale API along with their shop ID and API key.
  • Request: Requires shopId and a question.
  • Authorization: Uses a user-provided API key (x-api-key in header).

Response

The API response is a SimplifiedMobyResponse object:

export type SimplifiedResponse = {
  isError: boolean;
  errorMsg?: string;
  question: string;
  answer: Record<string, string | number | null>[];
  assistant: string;
};

export type SimplifiedMobyResponse = {
  isError: boolean;
  error?: string;
  responses: SimplifiedResponse[];
  assistantConclusion: string;
};
  • For each valid response:
    • Presents the question and a structured answer.
    • Mentions if data is available in a recommended visualization format.
    • Provides links if similar reports are suggested.
    • Concludes with an assistantConclusion to summarize results.
  • Error Handling:
    • If isError: true, the error is displayed.
    • 403 Unauthorized: “Invalid credentials. Please check your settings.”
    • Missing shopId: prompts for shopId.
    • Other errors: “Something went wrong. Please try again later.”
    • 401 Unauthorized: “API key is expired or doesn’t have access to the shop.”

Meshagent & Resources


For more on MCP servers and best practices: