awaBerry Testing Guide -> Testing: mcpservertest

Testing: mcpservertest

Summary

This page details the process for thoroughly testing the awaBerry MCP server across its two primary transport mechanisms: JSON/HTTP and Standard I/O (Stdio). Both testing flows involve configuring necessary environment variables such as mcpServerUrl, projectKey, projectSecret, and deviceName. For the JSON/HTTP version, tests validate session initialization, tool listing, device connection, and terminal command execution against an HTTP endpoint. The Stdio version performs similar validations by communicating directly over standard input/output, mimicking client interactions from applications like Claude Desktop. The tests ensure the server's core functionalities are operational and correctly configured.

Description

This guide explains how to test the different transport versions of the awaBerry MCP server.

Prerequisites

Before you begin, please follow the instructions in the ../httpservertest folder to ensure the underlying API methods are working correctly with your project setup.

Testing the JSON/HTTP Version

This test runs the MCP server over an HTTP endpoint that communicates via JSON.

1. Configure Environment

In the .env file located in the root directory of this project, add the following line:

Note: if your server is deployed on another environment already (e.g. Cloudflare), there is no need to start the local server.

mcpServerUrl="http://localhost:3000/mcp"

Ensure the .env file also contains the following required environment variables, which are used by the test script:

  • projectKey: Your project's unique key.
  • projectSecret: Your project's secret for authentication.
  • deviceName: The name of the device to connect to.

2. Start the Server

In your first terminal, from the project's root folder, execute:

npm run start:mcp:json

You should see output similar to this, indicating the server is running:

> mcp_server_awaberry@1.0.0 start:mcp
> node mcpserver/awaBerryAgenticMcpServerHttpJson.js

awaberry-mcp-server running on http://localhost:3000/mcp

3. Run the Test

In a second terminal, from the project's root folder, execute:

npm run test:mcp:json

This command runs the testMcpServerJson.js script, which interacts with the running JSON server by sending JSON-RPC 2.0 requests. The test performs the following steps:

  • Initialize MCP Session: Sends an initialize request with protocol version and client information.
  • List Available Tools: Sends a tools/list request to retrieve a list of available tools from the server.
  • Connect to Device: Calls the connect_to_device tool with projectKey, projectSecret, and deviceName to establish a device connection and obtain a sessionToken and deviceuuid.
  • Execute Terminal Command: Calls the execute_terminal_command tool, using the obtained sessionToken and deviceuuid, to run a sample command (e.g., date) on the connected device.

Testing the Stdio Version

This test runs the MCP server over standard input/output (stdio), which is the mode used by clients like Claude Desktop.

1. Configure Environment

Ensure your .env file contains the following required environment variables, similar to the JSON/HTTP test, as they are crucial for device connection:

  • projectKey: Your project's unique key.
  • projectSecret: Your project's secret for authentication.
  • deviceName: The name of the device to connect to.

2. Start the Server

In your first terminal, from the project's root folder, execute:

npm run start:mcp:stdio

You should see output similar to this:

> mcp_server_awaberry@1.0.0 start:mcp:stdio
> node mcpserver/awaBerryAgenticMcpServerStdio.js

awaberry-mcp-server running on stdio

3. Run the Test

In a second terminal, from the project's root folder, execute:

npm run test:mcp:stdio

This command runs the testMcpServerLocalStdio.js script. This script spawns the stdio MCP server as a child process and communicates with it by writing JSON-RPC 2.0 requests to its standard input and reading responses from its standard output. The test performs the following steps:

  • Initialize MCP Session: Sends an initialize request to establish a session.
  • List Available Tools: Requests a list of available tools.
  • Connect to Device: Calls the connect_to_device tool, providing projectKey, projectSecret, and deviceName to establish a device connection and obtain the necessary sessionToken and deviceuuid.
  • Execute Terminal Command: Utilizes the execute_terminal_command tool with the acquired sessionToken and deviceuuid to run a test command (e.g., date).