> For the complete documentation index, see [llms.txt](https://docs.bluerock.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bluerock.io/bluerock-secure-mcp/mcp-sensor-observability.md).

# MCP Sensor Observability

### **Overview**

This section demonstrates how MCP-based applications generate observability events when interacting with tools, resources, and prompts.

Python and TypeScript clients interact with an MCP server that is integrated with the BlueRock sensor for observability.

These interactions emit structured events that are captured and visualized in CloudWatch.

The following operations are validated:

* Tool discovery and execution
* Resource listing and access
* Prompt discovery and execution

***

### Deploying Python MCP Applications with BlueRock Sensor

***

### **Prerequisites**

```shellscript
# Connect to the BlueRock EC2 instance
ssh -i bluerock-ec2-key.pem ec2-user@<instance-ip>
```

```shellscript
# Verify Python version
python3 --version
```

Python 3.10 or higher is required for FastMCP.

#### Setup

1. **Install uv**

```shellscript
curl -LsSf https://astral.sh/uv/install.sh | sh
```

2. **Create Project Directory**

Create a new project directory for MCP observability and navigate into it.

```shellscript
cd ~
uv init mcp-observability
cd mcp-observability
```

***

3. **Install Required Dependencies**

Install MCP framework, BlueRock sensor, and BlueRock runtime required for generating and exporting observability events.

```shellscript
# Create virtual environment
uv venv --python python3.12

# Activate virtual environment
source .venv/bin/activate

# Install MCP framework
uv pip install fastmcp

# Install BlueRock runtime
uv pip install /opt/bluerock/python-dist/bluepython-0.0.1-py3-none-any.whl

# Initialize BlueRock
python -m bluepython --install
```

***

4. **Add MCP Application File**

Create the MCP client and server scripts in the project directory using the sample code provided in the [Appendix](broken://pages/8ytQ3cH4YpkmoAsFXnix) section.

```shellscript
vi mcp_client.py
vi mcp_fileserver_stdio.py
vi mcp_fileserver.py
```

***

5. **Verify Project Files**

Ensure the required files are present in the directory.

```shellscript
ls
```

**Expected Output:**

```shellscript
mcp_client.py
mcp_fileserver_stdio.py
mcp_fileserver.py
```

***

6. **Start MCP Server**

Run the MCP server to start accepting client requests.

```shellscript
uv run mcp_fileserver.py
```

### **Observability**

***

#### Tool Events

**Tool Listing & Execution**

**Command**

```shellscript
python3 mcp_client.py \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
tools --list

python3 mcp_client.py \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
tools --tool_cmd write_file \
--tool_args '{"filename":"test.txt","content":"hello"}'

```

**Output**

<figure><img src="/files/Cv0cYVDNfarD4ByJlONf" alt=""><figcaption></figcaption></figure>

Tool interactions are captured in AWS CloudWatch telemetry logs. These logs include:

* MCP client request activity
* MCP server request handling
* Tool name and arguments
* Runtime metadata

***

#### Resource Events

**Resource Listing & Access**

**Command**

```shellscript
python3 mcp_client.py \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
resources --list

python3 mcp_client.py \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
resources --resource_uri folder://explorer
```

**Output**

<figure><img src="/files/pvZdFxw3CbgOOhDmBIGC" alt=""><figcaption></figcaption></figure>

Resource interactions are captured in CloudWatch telemetry logs and include:

* resource name
* resource type
* resource URI

***

#### Prompt Events

**Prompt Listing & Execution**

**Command**

```shellscript
python3 mcp_client.py \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
prompts --list

python3 mcp_client.py \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
prompts --prompt_name useful_helper_prompt
```

**Output**

<figure><img src="/files/NhQC57kerd0ozOJfZQWk" alt=""><figcaption></figcaption></figure>

Prompt interactions are captured in CloudWatch telemetry logs and include:

* prompt name
* input arguments
* request flow

***

### Deploying JS/TS MCP Applications with BlueRock Sensor

***

### **Prerequisites**

**Install Node.js (using NVM)**

```shellscript
# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Install Node.js
nvm install 20

# Verify installation
node -v
npm -v
```

#### Setup

**1.** **Create Project Directory**

Create a new project directory for the MCP JavaScript/TypeScript application and navigate into it.

```shellscript
cd ~
mkdir mcp-observability
cd mcp-observability
```

**2.Install Dependencies**

Install the required Node.js dependencies before executing the MCP scripts.

```shellscript
# Install BlueRock JS runtime
npm install /opt/bluerock/bluejs-dist/bluejs-0.0.1.tgz
```

**3. Add MCP Application Files**

Create the MCP client and server scripts directly on the EC2 instance using the sample code provided in the [Appendix](broken://pages/8ytQ3cH4YpkmoAsFXnix) section.

```shellscript
mkdir tests && cd tests

vi mcp_client.js
vi mcp_fileserver.js
vi mcp_fileserver_stdio.js
vi package.json

npm install
```

**4. Verify Project Files**

Verify that the required files are present.

```shellscript
ls
```

**Expected output:**

```shellscript
mcp_client.js
mcp_fileserver.js
mcp_fileserver_stdio.js
node_modules
package-lock.json
package.json
```

***

## **Observability**

To view MCP observability events in AWS CloudWatch, start the MCP server and then run the MCP client to list and execute tools.

#### Tool Events

**Tool Listing & Execution**

```shellscript
# Starting the MCP file server (JavaScript/TypeScript)
# Run the MCP server to start accepting client requests.
node --import bluejs tests/mcp_fileserver.js

node --import bluejs tests/mcp_client.js \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
tools --list

node --import bluejs tests/mcp_client.js \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
tools \
--tool_cmd write_file \
--tool_args '{"filename":"event-final.txt","content":"check"}'
```

**Output**

<figure><img src="/files/9beVl2HzxEpphtxt4qb9" alt=""><figcaption></figcaption></figure>

Tool interactions are captured in AWS CloudWatch telemetry logs. These logs include:

* MCP client request activity
* MCP server request handling
* Tool name and arguments
* Runtime metadata

***

#### Resource Events

**Resource Listing & Access**

```shellscript
cd ~/mcp-observability

node --import bluejs tests/mcp_client.js \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
resources --list

node --import bluejs tests/mcp_client.js \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
resources \
--resource_uri folder://explorer
```

**Output**

<figure><img src="/files/Wn4v1kd2g2iGvElzyXld" alt=""><figcaption></figcaption></figure>

Resource interactions are captured in AWS CloudWatch telemetry logs. These logs include:

* MCP client request activity
* MCP server request handling
* Resource name and type
* Resource URI
* Runtime metadata

***

#### Prompt Events

**Prompt Listing & Execution**

```shellscript
cd ~/mcp-observability

node --import bluejs tests/mcp_client.js \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
prompts --list

node --import bluejs tests/mcp_client.js \
--mcp_server http://0.0.0.0:8001/mcp \
--mcp_auth_token dev-token \
prompts \
--prompt_name useful_helper_prompt \
--prompt_args '{"lang":"java"}'
```

**Output**

<figure><img src="/files/IwHpIjybpmHLs4Ewx5yK" alt=""><figcaption></figcaption></figure>

Prompt interactions are captured in AWS CloudWatch telemetry logs. These logs include:

* MCP client request activity
* MCP server request handling
* Prompt name
* Input arguments
* Runtime metadata


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bluerock.io/bluerock-secure-mcp/mcp-sensor-observability.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
