This page outlines the process for testing the HTTP server component. It involves starting a local Node.js HTTP server and then executing a test client script. The test client (testHttpServer.js) connects to the server using projectKey, projectSecret, and deviceName from a .env file, and subsequently sends an execute command (defaulting to 'date') to retrieve information from a configured device.
Ensure your .env file contains the following environment variables:
projectKey: Your project's unique key.projectSecret: Your project's secret.deviceName: The name of the device to connect to.The testHttpServer.js script will check for these variables and report an error if they are missing.
First, navigate to the project directory and run the HTTP server using Node.js:
node httpserver/server.js
Upon successful execution, you should see output similar to:
MCP Server running on http://localhost:8080
Endpoints:
POST /connect
POST /execute
In a separate terminal, execute the test client script:
node test/httpservertest/testHttpServer.js
The expected output from this command will be the current date, as received from the configured device via the 'date' command.
testHttpServer.js) OverviewThe testHttpServer.js script performs the following actions:
projectKey, projectSecret, deviceName, and an optional command) from the .env file located two directories up from the script's location.http://localhost:8090/connect) using the configured projectKey, projectSecret, and deviceName.sessionToken and deviceuuid from the connection response. It then sends an execute command (defaulting to 'date' or using the command variable from .env) to the server's /execute endpoint, along with the sessionToken and deviceuuid.